mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-11-08 16:33:58 +01:00
allow_metadata_inventory_take returns a number, not a bool
This commit is contained in:
parent
466d8af41d
commit
9f66fd40ad
@ -38,7 +38,7 @@ function pipeworks.tube_item(pos, item)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- adding two tube functions
|
-- adding two tube functions
|
||||||
-- can_remove(pos,node,stack,dir) returns true if an item can be removed from that stack on that node
|
-- can_remove(pos,node,stack,dir) returns the maximum number of items of that stack that can be removed
|
||||||
-- remove_items(pos,node,stack,dir,count) removes count items and returns them
|
-- remove_items(pos,node,stack,dir,count) removes count items and returns them
|
||||||
-- both optional w/ sensible defaults and fallback to normal allow_* function
|
-- both optional w/ sensible defaults and fallback to normal allow_* function
|
||||||
-- XXX: possibly change insert_object to insert_item
|
-- XXX: possibly change insert_object to insert_item
|
||||||
@ -48,18 +48,18 @@ end
|
|||||||
local function grabAndFire(frominv,frominvname,frompos,fromnode,sname,tube,idef,dir,all)
|
local function grabAndFire(frominv,frominvname,frompos,fromnode,sname,tube,idef,dir,all)
|
||||||
for spos,stack in ipairs(frominv:get_list(frominvname)) do
|
for spos,stack in ipairs(frominv:get_list(frominvname)) do
|
||||||
if (sname == nil and stack:get_name() ~= "") or stack:get_name() == sname then
|
if (sname == nil and stack:get_name() ~= "") or stack:get_name() == sname then
|
||||||
local doRemove = true
|
local doRemove = stack:get_count()
|
||||||
if tube.can_remove then
|
if tube.can_remove then
|
||||||
doRemove = tube.can_remove(frompos, fromnode, stack, dir)
|
doRemove = tube.can_remove(frompos, fromnode, stack, dir)
|
||||||
elseif idef.allow_metadata_inventory_take then
|
elseif idef.allow_metadata_inventory_take then
|
||||||
doRemove = idef.allow_metadata_inventory_take(frompos,"main",spos, stack, fakePlayer)
|
doRemove = idef.allow_metadata_inventory_take(frompos,"main",spos, stack, fakePlayer)
|
||||||
end
|
end
|
||||||
-- stupid lack of continue statements grumble
|
-- stupid lack of continue statements grumble
|
||||||
if doRemove then
|
if doRemove > 0 then
|
||||||
local item
|
local item
|
||||||
local count
|
local count
|
||||||
if all then
|
if all then
|
||||||
count = stack:get_count()
|
count = math.min(stack:get_count(), doRemove)
|
||||||
else
|
else
|
||||||
count = 1
|
count = 1
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user