mirror of
https://github.com/joe7575/techpack.git
synced 2024-10-05 17:23:07 +02:00
Change the HP pusher and chest so that partial stacks can also be moved
This commit is contained in:
parent
786cc85a1e
commit
881696e9bc
@ -151,7 +151,14 @@ tubelib.register_node("tubelib_addons3:chest", {}, {
|
|||||||
end,
|
end,
|
||||||
on_push_item = function(pos, side, item)
|
on_push_item = function(pos, side, item)
|
||||||
local meta = minetest.get_meta(pos)
|
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,
|
end,
|
||||||
on_unpull_item = function(pos, side, item)
|
on_unpull_item = function(pos, side, item)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
@ -42,12 +42,16 @@ local function pushing(pos, meta)
|
|||||||
local player_name = meta:get_string("player_name")
|
local player_name = meta:get_string("player_name")
|
||||||
local items = tubelib.pull_stack(pos, "L", player_name)
|
local items = tubelib.pull_stack(pos, "L", player_name)
|
||||||
if items ~= nil then
|
if items ~= nil then
|
||||||
|
local count = items:get_count()
|
||||||
if tubelib.push_items(pos, "R", items, player_name) == false then
|
if tubelib.push_items(pos, "R", items, player_name) == false then
|
||||||
-- place item back
|
-- place item back
|
||||||
tubelib.unpull_items(pos, "L", items, player_name)
|
tubelib.unpull_items(pos, "L", items, player_name)
|
||||||
|
-- Complete stack rejected
|
||||||
|
if count == items:get_count() then
|
||||||
State:blocked(pos, meta)
|
State:blocked(pos, meta)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
end
|
||||||
if State.get_state(pos, meta) ~= tubelib.STOPPED then
|
if State.get_state(pos, meta) ~= tubelib.STOPPED then
|
||||||
State:keep_running(pos, meta, COUNTDOWN_TICKS, 1)
|
State:keep_running(pos, meta, COUNTDOWN_TICKS, 1)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user