Skip to content

Instantly share code, notes, and snippets.

@DonBatman
Created July 25, 2016 15:28
Show Gist options
  • Save DonBatman/8778fc34ec29375a26f94568f2f97c7b to your computer and use it in GitHub Desktop.
Save DonBatman/8778fc34ec29375a26f94568f2f97c7b to your computer and use it in GitHub Desktop.
local skin = {}
-- Default player appearance
local c = math.random(10)
local col = tostring(c*10+80)
local tex = {"character2.png^character3.png^[colorize:#411600:"..col.."^character1.png",}
local function read_skin()
local f, err = io.open(minetest.get_worldpath() .. "/players.txt", "r")
local data = minetest.deserialize(f:read("*a"))
f:close()
return data
end
local function save_skin()
local file = io.open(minetest.get_worldpath().."/players.txt", "w")
file:write(minetest.serialize(skin))
file:close()
end
--Sets Player color on first join
minetest.register_on_newplayer(function(player)
local name = player:get_player_name()
skin[name].texture = tex
skin[name].color = col
save_skin()
default.player_register_model("character.b3d", {
animation_speed = 30,
textures = skin[name].texture or tex,
animations = {
stand = {x=0, y=79},
lay = {x=162, y=166},
walk = {x=168, y=187},
mine = {x=189, y=198},
walk_mine = {x=200, y=219},
sit = {x=81, y=160},
},
})
end)
local pcol = ""
-- Update appearance when the player joins
minetest.register_on_joinplayer(function(player)
-- read_skin()
skin = read_skin()
local name = player:get_player_name()
pcol = skin[name].col
player:set_properties({
mesh = "character.b3d",
textures = skin[name].texture or tex,
visual = "mesh",
visual_size = {x=1, y=1},
})
end)
--[[ The hand
minetest.register_item(":", {
type = "none",
wield_image = "default_dirt.png^[colorize:#411600:200",
wield_scale = {x=1,y=1,z=2.5},
tool_capabilities = {
full_punch_interval = 0.9,
max_drop_level = 0,
groupcaps = {
crumbly = {times={[2]=3.00, [3]=0.70}, uses=0, maxlevel=1},
snappy = {times={[3]=0.40}, uses=0, maxlevel=1},
oddly_breakable_by_hand = {times={[1]=3.50,[2]=2.00,[3]=0.70}, uses=0}
},
damage_groups = {fleshy=1},
}
})
--]]
minetest.override_item("",{
wield_image = "default_dirt.png^[colorize:#411600:200",
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment