mirror of
https://github.com/joe7575/techpack.git
synced 2025-02-16 18:02:25 +01:00
Change the HP pusher and chest so that partial stacks can also be moved
This commit is contained in:
@ -151,7 +151,14 @@ tubelib.register_node("tubelib_addons3:chest", {}, {
|
||||
end,
|
||||
on_push_item = function(pos, side, item)
|
||||
local meta = minetest.get_meta(pos)
|
||||
return tubelib.put_item(meta, "main", item)
|
||||
local res = tubelib.put_item(meta, "main", item)
|
||||
if res == false then
|
||||
local inv = meta:get_inventory()
|
||||
local leftover = inv:add_item("main", item)
|
||||
item:set_count(leftover:get_count())
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end,
|
||||
on_unpull_item = function(pos, side, item)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
@ -42,11 +42,15 @@ local function pushing(pos, meta)
|
||||
local player_name = meta:get_string("player_name")
|
||||
local items = tubelib.pull_stack(pos, "L", player_name)
|
||||
if items ~= nil then
|
||||
local count = items:get_count()
|
||||
if tubelib.push_items(pos, "R", items, player_name) == false then
|
||||
-- place item back
|
||||
tubelib.unpull_items(pos, "L", items, player_name)
|
||||
State:blocked(pos, meta)
|
||||
return
|
||||
-- Complete stack rejected
|
||||
if count == items:get_count() then
|
||||
State:blocked(pos, meta)
|
||||
return
|
||||
end
|
||||
end
|
||||
if State.get_state(pos, meta) ~= tubelib.STOPPED then
|
||||
State:keep_running(pos, meta, COUNTDOWN_TICKS, 1)
|
||||
|
Reference in New Issue
Block a user