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

local-ize a few more functions

This commit is contained in:
Vanessa Ezekowitz
2013-12-15 05:35:11 -05:00
parent 2481c06bf0
commit 53f6e67399
2 changed files with 142 additions and 140 deletions

View File

@ -1,24 +1,13 @@
-- autorouting for pneumatic tubes
function pipeworks.scan_for_tube_objects(pos)
if pos == nil then return end
tube_autoroute({ x=pos.x-1, y=pos.y , z=pos.z })
tube_autoroute({ x=pos.x+1, y=pos.y , z=pos.z })
tube_autoroute({ x=pos.x , y=pos.y-1, z=pos.z })
tube_autoroute({ x=pos.x , y=pos.y+1, z=pos.z })
tube_autoroute({ x=pos.x , y=pos.y , z=pos.z-1 })
tube_autoroute({ x=pos.x , y=pos.y , z=pos.z+1 })
tube_autoroute(pos)
end
function in_table(table,element)
local function in_table(table,element)
for _,el in ipairs(table) do
if el==element then return true end
end
return false
end
function is_tube(nodename)
local function is_tube(nodename)
return in_table(tubenodes,nodename)
end
@ -84,7 +73,7 @@ local function nodeside(node, tubedir)
minetest.log("error", "nodeside has been confused by its parameters; see pipeworks autoplace_tubes.lua, line 78")
end
function tube_autoroute(pos)
local function tube_autoroute(pos)
local active = {0, 0, 0, 0, 0, 0}
local nctr = minetest.get_node(pos)
if not is_tube(nctr.name) then return end
@ -135,6 +124,17 @@ function tube_autoroute(pos)
local nctr = minetest.get_node(pos)
end
function pipeworks.scan_for_tube_objects(pos)
if pos == nil then return end
tube_autoroute({ x=pos.x-1, y=pos.y , z=pos.z })
tube_autoroute({ x=pos.x+1, y=pos.y , z=pos.z })
tube_autoroute({ x=pos.x , y=pos.y-1, z=pos.z })
tube_autoroute({ x=pos.x , y=pos.y+1, z=pos.z })
tube_autoroute({ x=pos.x , y=pos.y , z=pos.z-1 })
tube_autoroute({ x=pos.x , y=pos.y , z=pos.z+1 })
tube_autoroute(pos)
end
minetest.register_on_placenode(function(pos, newnode, placer, oldnode, itemstack)
if minetest.registered_items[newnode.name]
and minetest.registered_items[newnode.name].tube