tube bugfixes

master
Joachim Stolberg 2017-09-12 19:14:15 +02:00
parent 0a46b71271
commit 5fb623b5f3
3 changed files with 14 additions and 7 deletions

View File

@ -108,9 +108,11 @@ function tubelib.get_pos(pos, facedir, side)
-- 1) wrong side of a single tube node
-- 2) node connected with itself. In this case "dest_pos2" is not available
if vector.equals(_pos, pos) then --
dst_pos = minetest.string_to_pos(minetest.get_meta(dst_pos):get_string("dest_pos2"))
_pos = minetest.string_to_pos(minetest.get_meta(dst_pos):get_string("dest_pos2"))
end
if dst_pos == nil then
if _pos == nil then
dst_pos = pos
else
dst_pos = _pos
end
node = minetest.get_node(dst_pos)
@ -276,7 +278,6 @@ end
-- Param 'item' is an item stack with one element like ItemStack("default:cobble")
function tubelib.push_items(pos, facedir, side, items)
local node, dst_pos = tubelib.get_pos(pos, facedir, side)
--print(node.name, items:get_name())
if tubelib_NodeDef[node.name] and tubelib_NodeDef[node.name].on_push_item then
return tubelib_NodeDef[node.name].on_push_item(dst_pos, items)
elseif legacy_node(node) then

View File

@ -206,7 +206,9 @@ local function keep_running(pos, elapsed)
if kvSrc[name] then
local item = tubelib.get_this_item(inv, "src", kvSrc[name]) -- <<=== tubelib
if item then
tubelib.push_items(pos, facedir, side, item) -- <<=== tubelib
if not tubelib.push_items(pos, facedir, side, item) then -- <<=== tubelib
tubelib.put_item(inv, "src", item)
end
end
end
end
@ -218,7 +220,9 @@ local function keep_running(pos, elapsed)
if kvFilterItemNames[name] == nil then -- not in the filter so far?
local item = tubelib.get_this_item(inv, "src", kvSrc[name]) -- <<=== tubelib
if item then
tubelib.push_items(pos, facedir, side, item) -- <<=== tubelib
if not tubelib.push_items(pos, facedir, side, item) then -- <<=== tubelib
tubelib.put_item(inv, "src", item)
end
end
end
end

View File

@ -134,9 +134,9 @@ local function update_head_tubes(pos)
local cnt1, peer1, dest1 = walk_to_peer(pos, pos1)
local cnt2, peer2, dest2 = walk_to_peer(pos, pos2)
if cnt1 == 0 and cnt2 == 0 then -- first tube node placed?
-- we have to store both dest positions, used by
-- we have to store both dest positions
minetest.get_meta(peer1):set_string("dest_pos", minetest.pos_to_string(dest2))
minetest.get_meta(peer2):set_string("dest_pos2", minetest.pos_to_string(dest1))
minetest.get_meta(peer1):set_string("dest_pos2", minetest.pos_to_string(dest1))
minetest.get_meta(peer1):set_string("infotext", minetest.pos_to_string(dest1)..":"..minetest.pos_to_string(dest2))
else
minetest.get_meta(peer1):set_string("dest_pos", minetest.pos_to_string(dest2))
@ -147,10 +147,12 @@ local function update_head_tubes(pos)
-- delete meta data from old head nodes
if cnt1 > 1 then
minetest.get_meta(pos1):set_string("dest_pos", nil)
minetest.get_meta(pos1):set_string("dest_pos2", nil)
minetest.get_meta(pos1):set_string("infotext", nil)
end
if cnt2 > 1 then
minetest.get_meta(pos2):set_string("dest_pos", nil)
minetest.get_meta(pos2):set_string("dest_pos2", nil)
minetest.get_meta(pos2):set_string("infotext", nil)
end
end