forked from MineClone5/MineClone5
Disallow to put non-armor items into armor slots
This commit is contained in:
parent
635b60c17f
commit
fd053e5c0b
|
@ -389,13 +389,29 @@ minetest.register_on_joinplayer(function(player)
|
||||||
armor:update_inventory(player)
|
armor:update_inventory(player)
|
||||||
end,
|
end,
|
||||||
allow_put = function(inv, listname, index, stack, player)
|
allow_put = function(inv, listname, index, stack, player)
|
||||||
return 1
|
local iname = stack:get_name()
|
||||||
|
local g
|
||||||
|
local groupcheck
|
||||||
|
if index == 2 then
|
||||||
|
g = minetest.get_item_group(iname, "armor_head")
|
||||||
|
elseif index == 3 then
|
||||||
|
g = minetest.get_item_group(iname, "armor_torso")
|
||||||
|
elseif index == 4 then
|
||||||
|
g = minetest.get_item_group(iname, "armor_legs")
|
||||||
|
elseif index == 5 then
|
||||||
|
g = minetest.get_item_group(iname, "armor_feet")
|
||||||
|
end
|
||||||
|
if g ~= 0 and g ~= nil then
|
||||||
|
return stack:get_count()
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
allow_take = function(inv, listname, index, stack, player)
|
allow_take = function(inv, listname, index, stack, player)
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end,
|
end,
|
||||||
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
allow_move = function(inv, from_list, from_index, to_list, to_index, count, player)
|
||||||
return count
|
return 0
|
||||||
end,
|
end,
|
||||||
}, name)
|
}, name)
|
||||||
if inv_mod == "inventory_plus" then
|
if inv_mod == "inventory_plus" then
|
||||||
|
|
Loading…
Reference in New Issue