Fix ta4 chest take_item bug

master
Joachim Stolberg 2021-05-16 19:56:44 +02:00
parent 6e54f2b820
commit c5a030b9e5
1 changed files with 17 additions and 16 deletions

View File

@ -16,6 +16,8 @@
local M = minetest.get_meta
local S = techage.S
local TA4_INV_SIZE = 50
local MP = minetest.get_modpath(minetest.get_current_modname())
local mConf = dofile(MP.."/basis/conf_inv.lua")
@ -345,30 +347,31 @@ techage.register_node({"techage:chest_ta4"}, {
local inv = meta:get_inventory()
local mem = techage.get_mem(pos)
mem.filter = mem.filter or mConf.item_filter(pos, 50)
mem.chest_configured = mem.chest_configured or
not mem.filter["unconfigured"] or #mem.filter["unconfigured"] < 50
mem.filter = mem.filter or mConf.item_filter(pos, TA4_INV_SIZE)
mem.chest_configured = mem.chest_configured or not inv:is_empty("conf")
if inv:is_empty("main") then
return nil
end
print(1)
if item_name then
if mem.filter[item_name] then -- configured item
local taken = inv:remove_item("main", {name = item_name, count = num})
if taken:get_count() > 0 then
return taken
end
elseif not mem.chest_configured then
print(2)
if mem.filter[item_name] or not mem.chest_configured then
print(3)
local taken = inv:remove_item("main", {name = item_name, count = num})
if taken:get_count() > 0 then
print(4)
return taken
end
end
else -- no item given
print(5)
if mem.chest_configured then
return mConf.take_item(pos, inv, "main", num, mem.filter["unconfigured"] or {})
print(6)
return mConf.take_item(pos, inv, "main", num, mem.filter["unconfigured"])
else
print(7)
return techage.get_items(pos, inv, "main", num)
end
end
@ -378,9 +381,8 @@ techage.register_node({"techage:chest_ta4"}, {
local inv = meta:get_inventory()
local mem = techage.get_mem(pos)
mem.filter = mem.filter or mConf.item_filter(pos, 50)
mem.chest_configured = mem.chest_configured or
not mem.filter["unconfigured"] or #mem.filter["unconfigured"] < 50
mem.filter = mem.filter or mConf.item_filter(pos, TA4_INV_SIZE)
mem.chest_configured = mem.chest_configured or not inv:is_empty("conf")
if mem.chest_configured then
local name = item:get_name()
@ -395,9 +397,8 @@ techage.register_node({"techage:chest_ta4"}, {
local inv = meta:get_inventory()
local mem = techage.get_mem(pos)
mem.filter = mem.filter or mConf.item_filter(pos, 50)
mem.chest_configured = mem.chest_configured or
not mem.filter["unconfigured"] or #mem.filter["unconfigured"] < 50
mem.filter = mem.filter or mConf.item_filter(pos, TA4_INV_SIZE)
mem.chest_configured = mem.chest_configured or not inv:is_empty("conf")
if mem.chest_configured then
local name = item:get_name()