mirror of
https://github.com/minetest-mods/digilines.git
synced 2024-09-27 22:30:22 +02:00
Review changes
This commit is contained in:
parent
765699e290
commit
24b94661fd
|
@ -373,27 +373,26 @@ if minetest.global_exists("tubelib") and minetest.global_exists("tubelib2") then
|
||||||
end,
|
end,
|
||||||
on_push_item = function(pos, side, item, player_name)
|
on_push_item = function(pos, side, item, player_name)
|
||||||
local dir_vec = tube_side(pos, side)
|
local dir_vec = tube_side(pos, side)
|
||||||
if tube_can_insert(pos, nil, item, dir_vec) then
|
if not tube_can_insert(pos, nil, item, dir_vec) then
|
||||||
|
return false
|
||||||
|
end
|
||||||
tube_insert_object(pos, nil, item, dir_vec)
|
tube_insert_object(pos, nil, item, dir_vec)
|
||||||
return true
|
return true
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
end,
|
||||||
on_unpull_item = function(pos, side, item, player_name)
|
on_unpull_item = function(pos, side, item, player_name)
|
||||||
local inv = minetest.get_meta(pos):get_inventory()
|
local inv = minetest.get_meta(pos):get_inventory()
|
||||||
if inv:room_for_item("main", item) then
|
if not inv:room_for_item("main", item) then
|
||||||
local existing_stack = inv:get_stack("main", speculative_pull.index)
|
return false
|
||||||
local is_empty = existing_stack:is_empty()
|
|
||||||
if is_empty or (
|
|
||||||
existing_stack:get_name() == item:get_name() and
|
|
||||||
existing_stack:get_count()+item:get_count() <= existing_stack:get_stack_max())
|
|
||||||
then
|
|
||||||
local stack = item
|
|
||||||
if not is_empty then
|
|
||||||
stack = existing_stack
|
|
||||||
stack:add_item(item)
|
|
||||||
end
|
end
|
||||||
inv:set_stack("main", speculative_pull.index, stack)
|
|
||||||
|
local existing_stack = inv:get_stack("main", speculative_pull.index)
|
||||||
|
local leftover = existing_stack:add_item(item)
|
||||||
|
if not leftover:is_empty() then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
inv:set_stack("main", speculative_pull.index, existing_stack)
|
||||||
|
|
||||||
-- Cancel speculative pull
|
-- Cancel speculative pull
|
||||||
-- this on_unpull_item callback should be called
|
-- this on_unpull_item callback should be called
|
||||||
-- immediately after on_pull_item if it fails
|
-- immediately after on_pull_item if it fails
|
||||||
|
@ -401,9 +400,6 @@ if minetest.global_exists("tubelib") and minetest.global_exists("tubelib2") then
|
||||||
speculative_pull.canceled = true
|
speculative_pull.canceled = true
|
||||||
speculative_pull = nil
|
speculative_pull = nil
|
||||||
return true
|
return true
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user