summaryrefslogtreecommitdiff
path: root/autoplace.lua
diff options
context:
space:
mode:
authorVanessa Ezekowitz <vanessaezekowitz@gmail.com>2012-08-21 13:52:25 -0400
committerVanessa Ezekowitz <vanessaezekowitz@gmail.com>2012-08-21 13:52:25 -0400
commit564abfe45a856f75d7b711decaebb22cdf062118 (patch)
tree8dc9c0fb584fce1a792d1c9baec833fb22f796b8 /autoplace.lua
parente103143ea72c77733d8026f3dc81a332832b77f6 (diff)
downloadpipeworks-564abfe45a856f75d7b711decaebb22cdf062118.tar
pipeworks-564abfe45a856f75d7b711decaebb22cdf062118.tar.gz
pipeworks-564abfe45a856f75d7b711decaebb22cdf062118.tar.bz2
pipeworks-564abfe45a856f75d7b711decaebb22cdf062118.tar.xz
pipeworks-564abfe45a856f75d7b711decaebb22cdf062118.zip
Made storage tank participate in autoplace algorithm. Tuned API a
little to allow for more flexible placement.
Diffstat (limited to 'autoplace.lua')
-rw-r--r--autoplace.lua63
1 files changed, 37 insertions, 26 deletions
diff --git a/autoplace.lua b/autoplace.lua
index 2b9a92f..04c2acb 100644
--- a/autoplace.lua
+++ b/autoplace.lua
@@ -25,9 +25,8 @@ function pipe_autoroute(pos, state)
if (string.find(nzm.name, "pipeworks:pipe_") ~= nil) then pzm=1 end
if (string.find(nzp.name, "pipeworks:pipe_") ~= nil) then pzp=1 end
- pipe_checkfordevice(pos, "valve")
- pipe_checkfordevice(pos, "pump")
-
+ pipe_checkfordevice(pos)
+
nsurround = pxm..pxp..pym..pyp..pzm..pzp
if nsurround == "000000" then nsurround = "110000" end
@@ -37,6 +36,12 @@ end
function pipe_device_autorotate(pos, state, bname)
+ if state == nil then
+ nname = bname
+ else
+ nname = bname.."_"..state
+ end
+
local nctr = minetest.env:get_node(pos)
pxm=0
@@ -54,39 +59,45 @@ function pipe_device_autorotate(pos, state, bname)
if (string.find(nzm.name, "pipeworks:pipe_") ~= nil) then pzm=1 end
if (string.find(nzp.name, "pipeworks:pipe_") ~= nil) then pzp=1 end
- pipe_checkfordevice(pos, "pump")
- pipe_checkfordevice(pos, "valve")
+ pipe_checkfordevice(pos)
if (pxm+pxp) ~= 0 then
- minetest.env:add_node(pos, { name = bname..state.."_x" })
+ minetest.env:add_node(pos, { name = nname.."_x" })
return
end
if (pzm+pzp) ~= 0 then
- minetest.env:add_node(pos, { name = bname..state.."_z" })
+ minetest.env:add_node(pos, { name = nname.."_z" })
end
end
-pipe_checkfordevice = function(pos, bname)
- if (string.find(nxm.name, "pipeworks:"..bname.."_off_x") ~= nil) or
- (string.find(nxm.name, "pipeworks:"..bname.."_on_x") ~= nil) then
- pxm=1
- end
-
- if (string.find(nxp.name, "pipeworks:"..bname.."_off_x") ~= nil) or
- (string.find(nxp.name, "pipeworks:"..bname.."_on_x") ~= nil) then
- pxp=1
- end
-
- if (string.find(nzm.name, "pipeworks:"..bname.."_off_z") ~= nil) or
- (string.find(nzm.name, "pipeworks:"..bname.."_on_z") ~= nil) then
- pzm=1
- end
-
- if (string.find(nzp.name, "pipeworks:"..bname.."_off_z") ~= nil) or
- (string.find(nzp.name, "pipeworks:"..bname.."_on_z") ~= nil) then
- pzp=1
+pipe_checkfordevice = function(pos)
+ for p in ipairs(pipes_devicelist) do
+ pdev = pipes_devicelist[p]
+ if (string.find(nxm.name, "pipeworks:"..pdev.."_off_x") ~= nil) or
+ (string.find(nxm.name, "pipeworks:"..pdev.."_on_x") ~= nil) or
+ (string.find(nxm.name, "pipeworks:"..pdev.."_x") ~= nil) then
+ pxm=1
+ end
+
+ if (string.find(nxp.name, "pipeworks:"..pdev.."_off_x") ~= nil) or
+ (string.find(nxp.name, "pipeworks:"..pdev.."_on_x") ~= nil) or
+ (string.find(nxp.name, "pipeworks:"..pdev.."_x") ~= nil) then
+ pxp=1
+ end
+
+ if (string.find(nzm.name, "pipeworks:"..pdev.."_off_z") ~= nil) or
+ (string.find(nzm.name, "pipeworks:"..pdev.."_on_z") ~= nil) or
+ (string.find(nzm.name, "pipeworks:"..pdev.."_z") ~= nil) then
+ pzm=1
+ end
+
+ if (string.find(nzp.name, "pipeworks:"..pdev.."_off_z") ~= nil) or
+ (string.find(nzp.name, "pipeworks:"..pdev.."_on_z") ~= nil) or
+ (string.find(nzp.name, "pipeworks:"..pdev.."_z") ~= nil) then
+ pzp=1
+ end
end
end