diff options
author | Novatux <nathanael.courant@laposte.net> | 2014-01-11 08:04:11 +0100 |
---|---|---|
committer | Novatux <nathanael.courant@laposte.net> | 2014-01-11 08:04:11 +0100 |
commit | 9f66fd40ad45d80d7f3e3a7dd61a6789e101a9e5 (patch) | |
tree | b96e4db99dd101809a14774a8d2bc3f4d42daf1d | |
parent | 466d8af41dcd2d9c7949b9cc40527973f4884d0b (diff) | |
download | pipeworks-9f66fd40ad45d80d7f3e3a7dd61a6789e101a9e5.tar pipeworks-9f66fd40ad45d80d7f3e3a7dd61a6789e101a9e5.tar.gz pipeworks-9f66fd40ad45d80d7f3e3a7dd61a6789e101a9e5.tar.bz2 pipeworks-9f66fd40ad45d80d7f3e3a7dd61a6789e101a9e5.tar.xz pipeworks-9f66fd40ad45d80d7f3e3a7dd61a6789e101a9e5.zip |
allow_metadata_inventory_take returns a number, not a bool
-rw-r--r-- | item_transport.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/item_transport.lua b/item_transport.lua index e67ef35..b97d5bb 100644 --- a/item_transport.lua +++ b/item_transport.lua @@ -38,7 +38,7 @@ function pipeworks.tube_item(pos, item) end -- 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 -- both optional w/ sensible defaults and fallback to normal allow_* function -- 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) for spos,stack in ipairs(frominv:get_list(frominvname)) do 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 doRemove = tube.can_remove(frompos, fromnode, stack, dir) elseif idef.allow_metadata_inventory_take then doRemove = idef.allow_metadata_inventory_take(frompos,"main",spos, stack, fakePlayer) end -- stupid lack of continue statements grumble - if doRemove then + if doRemove > 0 then local item local count if all then - count = stack:get_count() + count = math.min(stack:get_count(), doRemove) else count = 1 end |