1
0
mirror of https://github.com/mt-mods/pipeworks.git synced 2025-06-29 14:50:41 +02:00

Use 6d for pipes too

This commit is contained in:
Novatux
2014-01-01 17:40:22 +01:00
parent 1dab36812a
commit 4895aa6a0c
3 changed files with 112 additions and 144 deletions

View File

@ -1,31 +1,26 @@
-- autorouting for pipes
local function autoroute_pipes(pos, state)
local tube_table = {[0] = 1, 2, 2, 4, 2, 4, 4, 5, 2, 3, 4, 6, 4, 6, 5, 7, 2, 4, 3, 6, 4, 5, 6, 7, 4, 6, 6, 8, 5, 7, 7, 9, 2, 4, 4, 5, 3, 6, 6, 7, 4, 6, 5, 7, 6, 8, 7, 9, 4, 5, 6, 7, 6, 7, 8, 9, 5, 7, 7, 9, 7, 9, 9, 10}
local tube_table_facedirs = {[0] = 0, 0, 5, 0, 3, 4, 3, 0, 2, 0, 2, 0, 6, 4, 3, 0, 7, 12, 5, 12, 7, 4, 5, 5, 18, 20, 16, 0, 7, 4, 7, 0, 1, 8, 1, 1, 1, 13, 1, 1, 10, 8, 2, 2, 17, 4, 3, 6, 9, 9, 9, 9, 21, 13, 1, 1, 10, 10, 11, 2, 19, 4, 3, 0}
local function autoroute_pipes(pos)
local nctr = minetest.get_node(pos)
local state = "_empty"
if (string.find(nctr.name, "pipeworks:pipe_") == nil) then return end
if (string.find(nctr.name, "_loaded") ~= nil) then state = "_loaded" end
local nsurround = pipeworks.scan_pipe_surroundings(pos)
if nsurround == "000000" then nsurround = "110000" end
minetest.add_node(pos, { name = "pipeworks:pipe_"..nsurround..state })
if nsurround == 0 then nsurround = 9 end
minetest.add_node(pos, {name = "pipeworks:pipe_"..tube_table[nsurround]..state,
param2 = tube_table_facedirs[nsurround]})
end
function pipeworks.scan_for_pipe_objects(pos)
autoroute_pipes({ x=pos.x-1, y=pos.y , z=pos.z }, "_loaded")
autoroute_pipes({ x=pos.x+1, y=pos.y , z=pos.z }, "_loaded")
autoroute_pipes({ x=pos.x , y=pos.y-1, z=pos.z }, "_loaded")
autoroute_pipes({ x=pos.x , y=pos.y+1, z=pos.z }, "_loaded")
autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z-1 }, "_loaded")
autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z+1 }, "_loaded")
autoroute_pipes(pos, "_loaded")
autoroute_pipes({ x=pos.x-1, y=pos.y , z=pos.z }, "_empty")
autoroute_pipes({ x=pos.x+1, y=pos.y , z=pos.z }, "_empty")
autoroute_pipes({ x=pos.x , y=pos.y-1, z=pos.z }, "_empty")
autoroute_pipes({ x=pos.x , y=pos.y+1, z=pos.z }, "_empty")
autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z-1 }, "_empty")
autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z+1 }, "_empty")
autoroute_pipes(pos, "_empty")
autoroute_pipes({ x=pos.x-1, y=pos.y , z=pos.z })
autoroute_pipes({ x=pos.x+1, y=pos.y , z=pos.z })
autoroute_pipes({ x=pos.x , y=pos.y-1, z=pos.z })
autoroute_pipes({ x=pos.x , y=pos.y+1, z=pos.z })
autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z-1 })
autoroute_pipes({ x=pos.x , y=pos.y , z=pos.z+1 })
autoroute_pipes(pos)
end
-- auto-rotation code for various devices the tubes attach to
@ -191,7 +186,7 @@ function pipeworks.scan_pipe_surroundings(pos)
-- end
--
return pxm..pxp..pym..pyp..pzm..pzp
return pxm+8*pxp+2*pym+16*pyp+4*pzm+32*pzp
end
function pipeworks.look_for_stackable_tanks(pos)