bug fixes

master
Joachim Stolberg 2017-10-02 22:31:23 +02:00
parent adf73a2119
commit e28dd689d6
4 changed files with 27 additions and 19 deletions

View File

@ -388,6 +388,7 @@ end
-- is incremented each time so that different item stacks will be considered.
-- Returns nil if ItemList is empty.
function tubelib.get_item(meta, listname)
if meta == nil or meta.get_inventory == nil then return nil end
local inv = meta:get_inventory()
if inv:is_empty(listname) then
return nil
@ -411,6 +412,7 @@ end
-- Get one item from the given ItemList, specified by stack number (1..n).
-- Returns nil if ItemList is empty.
function tubelib.get_this_item(meta, listname, number)
if meta == nil or meta.get_inventory == nil then return nil end
local inv = meta:get_inventory()
if inv:is_empty(listname) then
return nil
@ -429,6 +431,7 @@ end
-- Put the given item into the given ItemList.
-- Function returns false if ItemList is full.
function tubelib.put_item(meta, listname, item)
if meta == nil or meta.get_inventory == nil then return false end
local inv = meta:get_inventory()
if inv:room_for_item(listname, item) then
inv:add_item(listname, item)
@ -440,6 +443,7 @@ end
-- Get the number of items from the given ItemList.
-- Returns nil if the number is not available.
function tubelib.get_num_items(meta, listname, num)
if meta == nil or meta.get_inventory == nil then return nil end
local inv = meta:get_inventory()
if inv:is_empty(listname) then
return nil

View File

@ -441,19 +441,3 @@ tubelib.register_node("tubelib:distributor", {"tubelib:distributor_active"}, {
end,
})
--------------------------------------------------------------- tubelib
--------------------------- conversion to v2
minetest.register_lbm({
label = "[Tubelib] Distributor update",
name = "tubelib:update",
nodenames = {"tubelib:distributor", "tubelib:distributor_active"},
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
if minetest.deserialize(meta:get_string("filter")) == nil then
local filter = {false,false,false,false}
meta:set_string("filter", minetest.serialize(filter))
meta:set_string("formspec", distributor_formspec(tubelib.STOPPED, filter))
end
end
})

View File

@ -21,6 +21,27 @@ tubelib = {
NodeDef = {}, -- node registration info
}
--------------------------- conversion to v0.04
minetest.register_lbm({
label = "[Tubelib] Distributor update",
name = "tubelib:update",
nodenames = {"tubelib:distributor", "tubelib:distributor_active"},
run_at_every_load = false,
action = function(pos, node)
local meta = minetest.get_meta(pos)
if minetest.deserialize(meta:get_string("filter")) == nil then
local filter = {false,false,false,false}
meta:set_string("filter", minetest.serialize(filter))
end
local inv = meta:get_inventory()
inv:set_size('yellow', 6)
inv:set_size('green', 6)
inv:set_size('red', 6)
inv:set_size('blue', 6)
end
})
dofile(minetest.get_modpath("tubelib") .. "/tubes.lua")
dofile(minetest.get_modpath("tubelib") .. "/command.lua")

View File

@ -80,9 +80,8 @@ local function keep_running(pos, elapsed)
if tubelib.push_items(pos, "R", items) == false then -- <<=== tubelib
-- place item back
tubelib.unpull_items(pos, "L", items) -- <<=== tubelib
meta:set_string("infotext", "Pusher "..number..": blocked")
else
meta:set_string("infotext", "Pusher "..number..": running")
local node = minetest.get_node(pos)
return goto_sleep(pos, node)
end
else
if running <= 0 then