mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-26 00:53:44 +01:00
Perform warehouse push action on unpull, and stop removing things from the cache on unpull
This commit is contained in:
parent
51fdab3c8a
commit
0fd949b496
@ -144,7 +144,14 @@ tubelib.register_node(NODE_NAME,
|
||||
return tubelib.get_item(M(pos), "main")
|
||||
end,
|
||||
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,
|
||||
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
|
@ -144,7 +144,14 @@ tubelib.register_node(NODE_NAME,
|
||||
return tubelib.get_item(M(pos), "main")
|
||||
end,
|
||||
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,
|
||||
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
|
@ -144,7 +144,14 @@ tubelib.register_node(NODE_NAME,
|
||||
return tubelib.get_item(M(pos), "main")
|
||||
end,
|
||||
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,
|
||||
|
||||
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
|
||||
local stack_size = inv:get_stack("main", idx):get_count()
|
||||
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?
|
||||
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
|
||||
num_items = num_items - (self.inv_size - stack_size)
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user