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
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
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
+-- List of devices for use by the autoplace algorithm
+
+pipes_devicelist = {
+ "pump",
+ "valve",
+ "storage_tank"
+}
+
-- tables
minetest.register_alias("pipeworks:pump", "pipeworks:pump_off_x")
walkable = true,
stack_max = 99,
after_place_node = function(pos)
- pipe_device_autorotate(pos, states[s], "pipeworks:pump_")
+ pipe_device_autorotate(pos, states[s], "pipeworks:pump")
pipe_scanforobjects(pos)
end,
after_dig_node = function(pos)
walkable = true,
stack_max = 99,
after_place_node = function(pos)
- pipe_device_autorotate(pos, states[s], "pipeworks:pump_")
+ pipe_device_autorotate(pos, states[s], "pipeworks:pump")
pipe_scanforobjects(pos)
end,
after_dig_node = function(pos)
walkable = true,
stack_max = 99,
after_place_node = function(pos)
- pipe_device_autorotate(pos, states[s], "pipeworks:valve_")
+ pipe_device_autorotate(pos, states[s], "pipeworks:valve")
pipe_scanforobjects(pos)
end,
after_dig_node = function(pos)
walkable = true,
stack_max = 99,
after_place_node = function(pos)
- pipe_device_autorotate(pos, states[s], "pipeworks:valve_")
+ pipe_device_autorotate(pos, states[s], "pipeworks:valve")
pipe_scanforobjects(pos)
end,
sounds = default.node_sound_wood_defaults(),
walkable = true,
stack_max = 99,
+ after_place_node = function(pos)
+ pipe_scanforobjects(pos)
+ end,
+ after_dig_node = function(pos)
+ pipe_scanforobjects(pos)
+ end,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
sounds = default.node_sound_wood_defaults(),
walkable = true,
stack_max = 99,
+ after_place_node = function(pos)
+ pipe_device_autorotate(pos, nil, "pipeworks:storage_tank")
+ pipe_scanforobjects(pos)
+ end,
+ after_dig_node = function(pos)
+ pipe_scanforobjects(pos)
+ end,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
sounds = default.node_sound_wood_defaults(),
walkable = true,
stack_max = 99,
+ drop = "pipeworks:storage_tank_x",
+ after_place_node = function(pos)
+ pipe_device_autorotate(pos, nil, "pipeworks:storage_tank")
+ pipe_scanforobjects(pos)
+ end,
+ after_dig_node = function(pos)
+ pipe_scanforobjects(pos)
+ end,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)