Perform warehouse push action on unpull, and stop removing things from the cache on unpull

This commit is contained in:
Cam B 2020-12-17 00:56:05 +00:00
parent 51fdab3c8a
commit 0fd949b496
4 changed files with 24 additions and 5 deletions

@ -144,7 +144,14 @@ tubelib.register_node(NODE_NAME,
return tubelib.get_item(M(pos), "main") return tubelib.get_item(M(pos), "main")
end, end,
on_unpull_item = function(pos, side, item) on_unpull_item = function(pos, side, item)
return tubelib.put_item(M(pos), "main", item) local meta = M(pos)
local num = wh.numbers_to_shift(Box, meta, item)
if num > 0 then
-- this should never happen, but better safe than sorry
item:set_count(num)
return tubelib.put_item(meta, "shift", item)
end
return true
end, end,
on_recv_message = function(pos, topic, payload) on_recv_message = function(pos, topic, payload)

@ -144,7 +144,14 @@ tubelib.register_node(NODE_NAME,
return tubelib.get_item(M(pos), "main") return tubelib.get_item(M(pos), "main")
end, end,
on_unpull_item = function(pos, side, item) on_unpull_item = function(pos, side, item)
return tubelib.put_item(M(pos), "main", item) local meta = M(pos)
local num = wh.numbers_to_shift(Box, meta, item)
if num > 0 then
-- this should never happen, but better safe than sorry
item:set_count(num)
return tubelib.put_item(meta, "shift", item)
end
return true
end, end,
on_recv_message = function(pos, topic, payload) on_recv_message = function(pos, topic, payload)

@ -144,7 +144,14 @@ tubelib.register_node(NODE_NAME,
return tubelib.get_item(M(pos), "main") return tubelib.get_item(M(pos), "main")
end, end,
on_unpull_item = function(pos, side, item) on_unpull_item = function(pos, side, item)
return tubelib.put_item(M(pos), "main", item) local meta = M(pos)
local num = wh.numbers_to_shift(Box, meta, item)
if num > 0 then
-- this should never happen, but better safe than sorry
item:set_count(num)
return tubelib.put_item(meta, "shift", item)
end
return true
end, end,
on_recv_message = function(pos, topic, payload) on_recv_message = function(pos, topic, payload)

@ -188,10 +188,8 @@ function techpack_warehouse.numbers_to_shift(self, meta, item)
if item_name == name then if item_name == name then
local stack_size = inv:get_stack("main", idx):get_count() local stack_size = inv:get_stack("main", idx):get_count()
if stack_size == self.inv_size then -- full? if stack_size == self.inv_size then -- full?
Cache[number][idx] = "" -- delete for searching
elseif (stack_size + num_items) > self.inv_size then -- limit will be reached? elseif (stack_size + num_items) > self.inv_size then -- limit will be reached?
inv:set_stack("main", idx, ItemStack({name = item_name, count = self.inv_size})) inv:set_stack("main", idx, ItemStack({name = item_name, count = self.inv_size}))
Cache[number][idx] = "" -- delete for searching
-- search with the rest for further slots -- search with the rest for further slots
num_items = num_items - (self.inv_size - stack_size) num_items = num_items - (self.inv_size - stack_size)
else else