Fix ta4 chest bugs

master
Joachim Stolberg 2020-09-20 12:11:26 +02:00
parent 73c4b95051
commit e13cd8b924
3 changed files with 15 additions and 15 deletions

View File

@ -304,10 +304,10 @@ techage.register_node({"techage:chest_ta4"}, {
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local mem = techage.get_mem(pos)
if not mem.filter or not mem.filter["unconfigured"] then
mem.filter = mConf.item_filter(pos, 50)
end
mem.chest_configured = mem.chest_configured or #mem.filter["unconfigured"] < 50
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
if inv:is_empty("main") then
return nil
@ -337,10 +337,10 @@ techage.register_node({"techage:chest_ta4"}, {
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local mem = techage.get_mem(pos)
if not mem.filter or not mem.filter["unconfigured"] then
mem.filter = mConf.item_filter(pos, 50)
end
mem.chest_configured = mem.chest_configured or #mem.filter["unconfigured"] < 50
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
if mem.chest_configured then
local name = item:get_name()
@ -354,10 +354,10 @@ techage.register_node({"techage:chest_ta4"}, {
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
local mem = techage.get_mem(pos)
if not mem.filter or not mem.filter["unconfigured"] then
mem.filter = mConf.item_filter(pos, 50)
end
mem.chest_configured = mem.chest_configured or #mem.filter["unconfigured"] < 50
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
if mem.chest_configured then
local name = item:get_name()

View File

@ -219,7 +219,7 @@ local function push_item(pos, filter, itemstack, num_items, nvm)
local idx = 1
local num_pushed = 0
local num_ports = #filter
local randidx = permIdx[num_ports][math.random(1, #permIdx[num_ports])]
local randidx = permIdx[num_ports][math.random(1, #(permIdx[num_ports] or {0}))]
local amount = math.floor(math.max((num_items + 1) / num_ports, 1))
local num_of_trials = 0
while num_pushed < num_items and num_of_trials <= 8 do

View File

@ -25,7 +25,7 @@ function inv_lib.preassigned_stacks(pos, xsize, ysize)
local item_name = inv:get_stack("conf", idx):get_name()
if item_name ~= "" then
local x = (idx - 1) % xsize
local y = math.floor(idx / xsize)
local y = math.floor((idx - 1) / xsize)
tbl[#tbl+1] = "item_image["..x..","..y..";1,1;"..item_name.."]"
end
end
@ -76,7 +76,7 @@ function inv_lib.allow_conf_inv_move(pos, from_list, from_index, to_list, to_ind
end
function inv_lib.put_items(pos, inv, listname, item, stacks, idx)
for _, i in ipairs(stacks) do
for _, i in ipairs(stacks or {}) do
if not idx or idx == i then
local stack = inv:get_stack(listname, i)
if stack:item_fits(item) then