mirror of
https://github.com/mt-mods/pipeworks.git
synced 2024-11-17 15:58:29 +01:00
Made storage tank participate in autoplace algorithm. Tuned API a
little to allow for more flexible placement.
This commit is contained in:
parent
e103143ea7
commit
564abfe45a
@ -25,9 +25,8 @@ function pipe_autoroute(pos, state)
|
|||||||
if (string.find(nzm.name, "pipeworks:pipe_") ~= nil) then pzm=1 end
|
if (string.find(nzm.name, "pipeworks:pipe_") ~= nil) then pzm=1 end
|
||||||
if (string.find(nzp.name, "pipeworks:pipe_") ~= nil) then pzp=1 end
|
if (string.find(nzp.name, "pipeworks:pipe_") ~= nil) then pzp=1 end
|
||||||
|
|
||||||
pipe_checkfordevice(pos, "valve")
|
pipe_checkfordevice(pos)
|
||||||
pipe_checkfordevice(pos, "pump")
|
|
||||||
|
|
||||||
nsurround = pxm..pxp..pym..pyp..pzm..pzp
|
nsurround = pxm..pxp..pym..pyp..pzm..pzp
|
||||||
|
|
||||||
if nsurround == "000000" then nsurround = "110000" end
|
if nsurround == "000000" then nsurround = "110000" end
|
||||||
@ -37,6 +36,12 @@ end
|
|||||||
|
|
||||||
function pipe_device_autorotate(pos, state, bname)
|
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)
|
local nctr = minetest.env:get_node(pos)
|
||||||
|
|
||||||
pxm=0
|
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(nzm.name, "pipeworks:pipe_") ~= nil) then pzm=1 end
|
||||||
if (string.find(nzp.name, "pipeworks:pipe_") ~= nil) then pzp=1 end
|
if (string.find(nzp.name, "pipeworks:pipe_") ~= nil) then pzp=1 end
|
||||||
|
|
||||||
pipe_checkfordevice(pos, "pump")
|
pipe_checkfordevice(pos)
|
||||||
pipe_checkfordevice(pos, "valve")
|
|
||||||
|
|
||||||
if (pxm+pxp) ~= 0 then
|
if (pxm+pxp) ~= 0 then
|
||||||
minetest.env:add_node(pos, { name = bname..state.."_x" })
|
minetest.env:add_node(pos, { name = nname.."_x" })
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if (pzm+pzp) ~= 0 then
|
if (pzm+pzp) ~= 0 then
|
||||||
minetest.env:add_node(pos, { name = bname..state.."_z" })
|
minetest.env:add_node(pos, { name = nname.."_z" })
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
pipe_checkfordevice = function(pos, bname)
|
pipe_checkfordevice = function(pos)
|
||||||
if (string.find(nxm.name, "pipeworks:"..bname.."_off_x") ~= nil) or
|
for p in ipairs(pipes_devicelist) do
|
||||||
(string.find(nxm.name, "pipeworks:"..bname.."_on_x") ~= nil) then
|
pdev = pipes_devicelist[p]
|
||||||
pxm=1
|
if (string.find(nxm.name, "pipeworks:"..pdev.."_off_x") ~= nil) or
|
||||||
end
|
(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:"..bname.."_off_x") ~= nil) or
|
if (string.find(nxp.name, "pipeworks:"..pdev.."_off_x") ~= nil) or
|
||||||
(string.find(nxp.name, "pipeworks:"..bname.."_on_x") ~= nil) then
|
(string.find(nxp.name, "pipeworks:"..pdev.."_on_x") ~= nil) or
|
||||||
pxp=1
|
(string.find(nxp.name, "pipeworks:"..pdev.."_x") ~= nil) then
|
||||||
end
|
pxp=1
|
||||||
|
end
|
||||||
|
|
||||||
if (string.find(nzm.name, "pipeworks:"..bname.."_off_z") ~= nil) or
|
if (string.find(nzm.name, "pipeworks:"..pdev.."_off_z") ~= nil) or
|
||||||
(string.find(nzm.name, "pipeworks:"..bname.."_on_z") ~= nil) then
|
(string.find(nzm.name, "pipeworks:"..pdev.."_on_z") ~= nil) or
|
||||||
pzm=1
|
(string.find(nzm.name, "pipeworks:"..pdev.."_z") ~= nil) then
|
||||||
end
|
pzm=1
|
||||||
|
end
|
||||||
|
|
||||||
if (string.find(nzp.name, "pipeworks:"..bname.."_off_z") ~= nil) or
|
if (string.find(nzp.name, "pipeworks:"..pdev.."_off_z") ~= nil) or
|
||||||
(string.find(nzp.name, "pipeworks:"..bname.."_on_z") ~= nil) then
|
(string.find(nzp.name, "pipeworks:"..pdev.."_on_z") ~= nil) or
|
||||||
pzp=1
|
(string.find(nzp.name, "pipeworks:"..pdev.."_z") ~= nil) then
|
||||||
|
pzp=1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
Changelog
|
Changelog
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
2012-08-21: Made storage tank participate in autoplace algorithm. Tuned API a
|
||||||
|
little to allow for more flexible placement.
|
||||||
|
|
||||||
|
2012-08-20: Added temporary nodes for storage tank and intake grating, but
|
||||||
|
without autoplace.
|
||||||
|
|
||||||
2012-08-19: Pumps and valves now fully participate in the
|
2012-08-19: Pumps and valves now fully participate in the
|
||||||
auto-rotate/auto-place algorithm.
|
auto-rotate/auto-place algorithm.
|
||||||
|
|
||||||
|
37
devices.lua
37
devices.lua
@ -1,3 +1,11 @@
|
|||||||
|
-- List of devices for use by the autoplace algorithm
|
||||||
|
|
||||||
|
pipes_devicelist = {
|
||||||
|
"pump",
|
||||||
|
"valve",
|
||||||
|
"storage_tank"
|
||||||
|
}
|
||||||
|
|
||||||
-- tables
|
-- tables
|
||||||
|
|
||||||
minetest.register_alias("pipeworks:pump", "pipeworks:pump_off_x")
|
minetest.register_alias("pipeworks:pump", "pipeworks:pump_off_x")
|
||||||
@ -82,7 +90,7 @@ for s in ipairs(states) do
|
|||||||
walkable = true,
|
walkable = true,
|
||||||
stack_max = 99,
|
stack_max = 99,
|
||||||
after_place_node = function(pos)
|
after_place_node = function(pos)
|
||||||
pipe_device_autorotate(pos, states[s], "pipeworks:pump_")
|
pipe_device_autorotate(pos, states[s], "pipeworks:pump")
|
||||||
pipe_scanforobjects(pos)
|
pipe_scanforobjects(pos)
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos)
|
after_dig_node = function(pos)
|
||||||
@ -121,7 +129,7 @@ for s in ipairs(states) do
|
|||||||
walkable = true,
|
walkable = true,
|
||||||
stack_max = 99,
|
stack_max = 99,
|
||||||
after_place_node = function(pos)
|
after_place_node = function(pos)
|
||||||
pipe_device_autorotate(pos, states[s], "pipeworks:pump_")
|
pipe_device_autorotate(pos, states[s], "pipeworks:pump")
|
||||||
pipe_scanforobjects(pos)
|
pipe_scanforobjects(pos)
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos)
|
after_dig_node = function(pos)
|
||||||
@ -167,7 +175,7 @@ for s in ipairs(states) do
|
|||||||
walkable = true,
|
walkable = true,
|
||||||
stack_max = 99,
|
stack_max = 99,
|
||||||
after_place_node = function(pos)
|
after_place_node = function(pos)
|
||||||
pipe_device_autorotate(pos, states[s], "pipeworks:valve_")
|
pipe_device_autorotate(pos, states[s], "pipeworks:valve")
|
||||||
pipe_scanforobjects(pos)
|
pipe_scanforobjects(pos)
|
||||||
end,
|
end,
|
||||||
after_dig_node = function(pos)
|
after_dig_node = function(pos)
|
||||||
@ -216,7 +224,7 @@ for s in ipairs(states) do
|
|||||||
walkable = true,
|
walkable = true,
|
||||||
stack_max = 99,
|
stack_max = 99,
|
||||||
after_place_node = function(pos)
|
after_place_node = function(pos)
|
||||||
pipe_device_autorotate(pos, states[s], "pipeworks:valve_")
|
pipe_device_autorotate(pos, states[s], "pipeworks:valve")
|
||||||
pipe_scanforobjects(pos)
|
pipe_scanforobjects(pos)
|
||||||
|
|
||||||
end,
|
end,
|
||||||
@ -258,6 +266,12 @@ minetest.register_node("pipeworks:intake", {
|
|||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
walkable = true,
|
walkable = true,
|
||||||
stack_max = 99,
|
stack_max = 99,
|
||||||
|
after_place_node = function(pos)
|
||||||
|
pipe_scanforobjects(pos)
|
||||||
|
end,
|
||||||
|
after_dig_node = function(pos)
|
||||||
|
pipe_scanforobjects(pos)
|
||||||
|
end,
|
||||||
pipelike=1,
|
pipelike=1,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
@ -282,6 +296,13 @@ minetest.register_node("pipeworks:storage_tank_x", {
|
|||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
walkable = true,
|
walkable = true,
|
||||||
stack_max = 99,
|
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,
|
pipelike=1,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
@ -304,6 +325,14 @@ minetest.register_node("pipeworks:storage_tank_z", {
|
|||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
walkable = true,
|
walkable = true,
|
||||||
stack_max = 99,
|
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,
|
pipelike=1,
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.env:get_meta(pos)
|
local meta = minetest.env:get_meta(pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user