Skip to content

Instantly share code, notes, and snippets.

@Jordach

Jordach/.lua

Created Feb 22, 2017
Embed
What would you like to do?
function wardrobe.load_user_data(player)
local pname = player:get_player_name()
-- load non-RGB choices
if player:get_attribute("wardrobe_choices") == nil then
wardrobe.formspec_selections[pname] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}
print ("[Wardrobe] Failed Loading Texture Data for Player: " .. pname)
player:set_attribute("wardrobe_choices", minetest.serialize(wardrobe.formspec_selections[pname]))
else
wardrobe.formspec_selections[pname] = minetest.deserialize(player:get_attribute("wardrobe_choices"))
print ("[Wardrobe] Loaded Texture Data for Player: " .. pname)
end
-- load RGB
if player:get_attribute("wardrobe_rgb") == nil then
wardrobe.formspec_selections_rgb[pname] = {}
for i=1,22 do -- if you think i'm writing ffffff for each table line, think again
wardrobe.formspec_selections_rgb[pname][i] = "ffffff"
end
print ("[Wardrobe] Failed Loading RGB Data for Player: " .. pname)
player:set_attribute("wardrobe_rgb", minetest.serialize(wardrobe.formspec_selections_rgb[pname]))
else
wardrobe.formspec_selections_rgb[pname] = minetest.deserialize(player:get_attribute("wardrobe_rgb"))
print ("[Wardrobe] Loaded RGB Data for Player: " .. pname)
end
end
function wardrobe.save_user_data(player)
local pname = player:get_player_name()
player:set_attribute("wardrobe_choices", minetest.serialize(wardrobe.formspec_selections[pname]))
player:set_attribute("wardrobe_rgb", minetest.serialize(wardrobe.formspec_selections_rgb[pname]))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment