[invtweak] Fix strange crash with wielders

This commit is contained in:
LeMagnesium 2015-10-14 14:49:44 +02:00
parent 13974157c2
commit be6f213b8a
1 changed files with 9 additions and 7 deletions

View File

@ -194,13 +194,15 @@ function refill(player, stck_name, index)
local inv = player:get_inventory()
local old_stack = inv:get_stack("main", index)
if old_stack:get_name() == stck_name then return end
for i,stack in ipairs(inv:get_list("main")) do
if i ~= index and stack:get_name() == stck_name then
inv:set_stack("main", index, stack)
stack:clear()
inv:set_stack("main", i, stack)
minetest.log("action", "Inventory Tweaks: refilled stack("..stck_name..") of " .. player:get_player_name() )
return
if inv:get_list("main") then
for i,stack in ipairs(inv:get_list("main")) do
if i ~= index and stack:get_name() == stck_name then
inv:set_stack("main", index, stack)
stack:clear()
inv:set_stack("main", i, stack)
minetest.log("action", "Inventory Tweaks: refilled stack("..stck_name..") of " .. player:get_player_name() )
return
end
end
end
end