function get_num_items added
parent
bcde34dd80
commit
75b900aaba
19
command.lua
19
command.lua
|
@ -357,3 +357,22 @@ function tubelib.put_item(inv, listname, item)
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get the number of items from the given ItemList.
|
||||||
|
-- Returns nil if the number is not available.
|
||||||
|
function tubelib.get_num_items(inv, listname, num)
|
||||||
|
if inv:is_empty(listname) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
local size = inv:get_size(listname)
|
||||||
|
for idx = 1, size do
|
||||||
|
local items = inv:get_stack(listname, idx)
|
||||||
|
if items:get_count() >= num then
|
||||||
|
local taken = items:take_item(num)
|
||||||
|
inv:set_stack(listname, idx, items)
|
||||||
|
return taken
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
|
3
init.lua
3
init.lua
|
@ -11,6 +11,7 @@
|
||||||
History:
|
History:
|
||||||
2017-09-08 v0.01 first version
|
2017-09-08 v0.01 first version
|
||||||
2017-09-12 v0.02 bugfix in tubelib.get_pos() and others
|
2017-09-12 v0.02 bugfix in tubelib.get_pos() and others
|
||||||
|
2017-09-21 v0.03 function get_num_items added
|
||||||
|
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
@ -40,6 +41,8 @@ tubelib.knownNodes = {
|
||||||
tubelib.legacyNodes = {
|
tubelib.legacyNodes = {
|
||||||
["default:chest_locked"] = true,
|
["default:chest_locked"] = true,
|
||||||
["default:chest"] = true,
|
["default:chest"] = true,
|
||||||
|
["default:chest_locked_open"] = true,
|
||||||
|
["default:chest_open"] = true,
|
||||||
["default:furnace"] = true,
|
["default:furnace"] = true,
|
||||||
["default:furnace_active"] = true,
|
["default:furnace_active"] = true,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue