Skip to content

Instantly share code, notes, and snippets.

@Andrey2470T
Last active August 31, 2018 20:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andrey2470T/080ae49fbfefce22ad54e5ae33ef2cfd to your computer and use it in GitHub Desktop.
Save Andrey2470T/080ae49fbfefce22ad54e5ae33ef2cfd to your computer and use it in GitHub Desktop.
sfinv.register_page("medicine:doctor`s_clothes_section", {
title = "Dr`s Clothes",
get = function (self, player, context)
minetest.create_detached_inventory("doctors_inv", {
allow_put = function (inv, listname, index, stack, player)
minetest.debug("hghghghgh")
for _, item in ipairs(items_to_allow_to_put) do
if "medicine:doctors_"..item == stack:get_name() then
local inv = minetest.get_inventory({type = "detached", name = "craft"})
local list = inv:get_list("craft")
for _, item in ipairs(list) do
if item == stack:get_name() then
return 0
end
end
--[[player:get_meta():set_string("texture", player:get_meta():get_string("texture") .. "^doctors_"..item..".png")
local textures_list = player:get_meta():get_string("textures_list")
textures_list[#textures_list+1] = "^doctors_"..item..".png"
player:get_meta():set_string(minetest.serialize(textures_list))
player:set_properties({textures = player:get_properties().textures[1] .. "^doctors_"..item..".png"})]]
misc.add_player_texture(player, "^doctors_"..item.."_preview.png")
return stack:get_count(), -1
end
end
return 0
end,
on_take = function (inv, listname, index, stack, player)
misc.replace_player_texture(player, "^doctors_"..item.."_preview.png")
end }, player:get_player_name())
return sfinv.make_formspec(player, context,
"label[1.1,0.2;Insert your medclothes into corresponding slots to dress!]" ..
"list[current_player;craft;0.7,0.8;2,2]", true)
end
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment