Merge pull request #43 from oversword/master

#42 bls#168 fixed infinite item on scroll bug
This commit is contained in:
Joachim Stolberg 2019-12-21 12:35:52 +01:00 committed by GitHub
commit 8e0852f2fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -75,7 +75,9 @@ local function move_to_main(pos, index)
end
end
local function move_to_player_inv(player_name, pos, main_stack, index)
local function move_to_player_inv(player_name, pos, index)
local node_inv = M(pos):get_inventory()
local main_stack = node_inv:get_stack("main", index)
local player_inv = minetest.get_inventory({type="player", name=player_name})
local num = main_stack:get_count()
if num > 99 then
@ -83,7 +85,6 @@ local function move_to_player_inv(player_name, pos, main_stack, index)
end
local leftover = player_inv:add_item("main", ItemStack(main_stack:get_name().." "..num))
main_stack:set_count(main_stack:get_count() - num + leftover:get_count())
local node_inv = M(pos):get_inventory()
node_inv:set_stack("main", index, main_stack)
end
@ -238,7 +239,7 @@ function techpack_warehouse.allow_metadata_inventory_take(pos, listname, index,
local number = M(pos):get_string("tubelib_number")
if listname == "main" then
Cache[number] = nil
minetest.after(0.1, move_to_player_inv, player:get_player_name(), pos, main_stack, index)
minetest.after(0.1, move_to_player_inv, player:get_player_name(), pos, index)
return 0
elseif listname == "filter" and main_stack:is_empty() then
Cache[number] = nil
@ -331,4 +332,4 @@ function techpack_warehouse.get_num_items(meta, index)
if index > 8 then index = 8 end
local inv = meta:get_inventory()
return inv:get_stack("main", index):get_count()
end
end