mirror of
https://github.com/joe7575/techpack.git
synced 2024-12-25 23:17:36 +01:00
Further "tubing" improvements:
- ignore none inventory nodes (lamps,...) - connect tubes for inventory nodes
This commit is contained in:
parent
b291a3171b
commit
16fefca1fa
@ -203,12 +203,17 @@ end
|
||||
function tubelib.register_node(name, add_names, node_definition)
|
||||
tubelib_NodeDef[name] = node_definition
|
||||
-- store facedir table for all known node names
|
||||
tubelib.KnownNodes[name] = true
|
||||
Name2Name[name] = name
|
||||
for _,n in ipairs(add_names) do
|
||||
tubelib.KnownNodes[n] = true
|
||||
Name2Name[n] = name
|
||||
end
|
||||
if node_definition.on_pull_item or node_definition.on_push_item or
|
||||
node_definition.is_pusher then
|
||||
tubelib.KnownNodes[name] = true
|
||||
for _,n in ipairs(add_names) do
|
||||
tubelib.KnownNodes[n] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-------------------------------------------------------------------
|
||||
|
@ -226,6 +226,7 @@ tubelib.register_node("tubelib:pusher", {"tubelib:pusher_active"}, {
|
||||
on_pull_item = nil, -- pusher has no inventory
|
||||
on_push_item = nil, -- pusher has no inventory
|
||||
on_unpull_item = nil, -- pusher has no inventory
|
||||
is_pusher = true, -- is a pulling/pushing node
|
||||
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
local node = minetest.get_node(pos)
|
||||
|
@ -141,13 +141,15 @@ function tubelib.get_next_tube(pos, dir)
|
||||
return pos, nil
|
||||
end
|
||||
|
||||
local function get_next_node(pos, dir)
|
||||
pos = get_tube_pos(pos, dir)
|
||||
local node = minetest.get_node_or_nil(pos) or tubelib.read_node_with_vm(pos)
|
||||
if tubelib.KnownNodes[node.name] then
|
||||
return node
|
||||
local function is_known_node(pos, dir)
|
||||
if dir then
|
||||
pos = get_tube_pos(pos, dir)
|
||||
local node = minetest.get_node_or_nil(pos) or tubelib.read_node_with_vm(pos)
|
||||
if tubelib.KnownNodes[node.name] and not tubelib.TubeNames[node.name] then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return nil
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
@ -204,7 +206,7 @@ local function is_connected(pos, dir)
|
||||
local dir1,dir2 = get_tube_dirs(pos)
|
||||
-- return true if connected
|
||||
dir = Turn180Deg[dir]
|
||||
return dir == dir1 or dir == dir2
|
||||
return dir == dir1 or dir == dir2
|
||||
end
|
||||
return false
|
||||
end
|
||||
@ -222,8 +224,8 @@ end
|
||||
local function update_next_tube(dir, pos)
|
||||
-- test if tube is connected with neighbor tubes
|
||||
local dir1, dir2 = get_tube_dirs(pos)
|
||||
local conn1 = is_connected(pos, dir1)
|
||||
local conn2 = is_connected(pos, dir2)
|
||||
local conn1 = is_connected(pos, dir1) or is_known_node(pos, dir1)
|
||||
local conn2 = is_connected(pos, dir2) or is_known_node(pos, dir2)
|
||||
-- already connected or no tube arround?
|
||||
if conn1 == conn2 then
|
||||
return
|
||||
@ -246,12 +248,17 @@ local function update_tube(pos, dir)
|
||||
for dir = 1,6 do
|
||||
if not dir1 and is_connected(pos, dir) then
|
||||
dir1 = dir
|
||||
elseif not dir1 and get_next_node(pos, dir) then
|
||||
dir1 = dir
|
||||
elseif not dir2 and is_connected(pos, dir) then
|
||||
dir2 = dir
|
||||
elseif not dir2 and get_next_node(pos, dir) then
|
||||
dir2 = dir
|
||||
end
|
||||
end
|
||||
if not dir1 or not dir2 then
|
||||
for dir = 1,6 do
|
||||
if not dir1 and is_known_node(pos, dir) then
|
||||
dir1 = dir
|
||||
elseif not dir2 and is_known_node(pos, dir) then
|
||||
dir2 = dir
|
||||
end
|
||||
end
|
||||
end
|
||||
dir1 = dir1 or dir
|
||||
|
@ -226,6 +226,7 @@ tubelib.register_node("tubelib_addons1:pusher_fast", {"tubelib_addons1:pusher_fa
|
||||
on_pull_item = nil, -- pusher has no inventory
|
||||
on_push_item = nil, -- pusher has no inventory
|
||||
on_unpull_item = nil, -- pusher has no inventory
|
||||
is_pusher = true, -- is a pulling/pushing node
|
||||
|
||||
on_recv_message = function(pos, topic, payload)
|
||||
local node = minetest.get_node(pos)
|
||||
|
Loading…
Reference in New Issue
Block a user