local skin_selection = 'formspec_version[3]'.. 'size[9,7]'.. 'textarea[.5,.5;8,2.5;;;Enter the number of the skin tone in the box below. This change is free, future changes will cost 500XP.]'.. 'image[1,3;7,1;gamer_skin_swatch.png]'.. 'field[1,5.5;2,1;tone;What skin tone would you like?;]'.. 'button_exit[3.5,5.5;2,1;exit;Close]'.. 'button_exit[6,5.5;2,1;save;Save]'.. 'tooltip[save;!!!You can only do this once!!!]' local skin_selection_1 = 'formspec_version[3]'.. 'size[9,7]'.. 'textarea[.5,.5;8,2.5;;;Enter the number of the skin tone in the box below. If you do not have 500XP you will not be able to change skin color.]'.. 'image[1,3;7,1;gamer_skin_swatch.png]'.. 'field[1,5.5;2,1;tone;What skin tone would you like?;]'.. 'button_exit[3.5,5.5;2,1;exit;Close]'.. 'button_exit[6,5.5;2,1;save;Save]'.. 'tooltip[save;!!!This will cost 500XP!!!]' minetest.register_chatcommand('skin', { description = 'Change your skin.', privs = {server=true}, func = function(name) local player = minetest.get_player_by_name(name) local player_attributes = player:get_meta() local tone = player_attributes:get_int('tone') print (tone) if tone == 0 or nil then minetest.show_formspec(name, 'gamer:skin_selection', skin_selection) else minetest.show_formspec(name, 'gamer:skin_selection_1', skin_selection_1) end end }) minetest.register_on_player_receive_fields(function(player, formname, fields) local name = player:get_player_name() if formname == 'gamer:skin_selection' then if fields.save then local tone = tonumber(fields.tone) if tone >= 1 and tone <= 7 then local player_attributes = player:get_meta() local skin_col = 'gamer_skin_'..tone..'.png' player_attributes:set_int('tone', tone) gamer.player_set_textures(player, {skin_col}) minetest.chat_send_player(name, 'Skin tone updated!') gamer.save_skins() else minetest.chat_send_player(name, 'Select a valid skin tone.') end end elseif formname == 'gamer:skin_selection_1' then if fields.save then local tone = tonumber(fields.tone) if tone >= 1 and tone <= 7 then if lobby.take_xp(player, 500) then local player_attributes = player:get_meta() local skin_col = 'gamer_skin_'..tone..'.png' player_attributes:set_int('tone', tone) gamer.player_set_textures(player, {skin_col}) minetest.chat_send_player(name, 'Skin tone updated!') gamer.save_skins() else minetest.chat_send_player(name, 'Sorry, you need more XP.') end else minetest.chat_send_player(name, 'Select a valid skin tone.') end end end end)