2013-12-15 10:35:59 +01:00
|
|
|
-- This file supplies the steel pipes
|
2020-02-18 18:34:52 +01:00
|
|
|
local S = minetest.get_translator("pipeworks")
|
2013-07-14 04:39:25 +02:00
|
|
|
|
2014-01-01 18:04:45 +01:00
|
|
|
local REGISTER_COMPATIBILITY = true
|
|
|
|
|
2013-12-15 10:35:59 +01:00
|
|
|
local pipes_empty_nodenames = {}
|
|
|
|
local pipes_full_nodenames = {}
|
2013-07-14 04:39:25 +02:00
|
|
|
|
2017-10-01 17:54:24 +02:00
|
|
|
local new_flow_logic_register = pipeworks.flowables.register
|
|
|
|
|
2017-10-26 10:11:30 +02:00
|
|
|
local polys = ""
|
|
|
|
if pipeworks.enable_lowpoly then polys = "_lowpoly" end
|
|
|
|
|
2014-01-01 17:40:22 +01:00
|
|
|
local vti = {4, 3, 2, 1, 6, 5}
|
|
|
|
local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}}
|
|
|
|
for index, connects in ipairs(cconnects) do
|
|
|
|
local outsel = {}
|
|
|
|
|
|
|
|
local jx = 0
|
|
|
|
local jy = 0
|
|
|
|
local jz = 0
|
|
|
|
for _, v in ipairs(connects) do
|
|
|
|
if v == 1 or v == 2 then
|
|
|
|
jx = jx + 1
|
|
|
|
elseif v == 3 or v == 4 then
|
|
|
|
jy = jy + 1
|
|
|
|
else
|
|
|
|
jz = jz + 1
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
2014-01-01 17:40:22 +01:00
|
|
|
table.insert(outsel, pipeworks.pipe_selectboxes[v])
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
|
|
|
|
2014-01-01 17:40:22 +01:00
|
|
|
if #connects == 1 then
|
|
|
|
local v = connects[1]
|
|
|
|
v = v-1 + 2*(v%2) -- Opposite side
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
2014-01-01 17:40:22 +01:00
|
|
|
|
|
|
|
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1}
|
2020-02-18 18:34:52 +01:00
|
|
|
local pipedesc = S("Pipe Segment").." "..dump(connects)
|
2013-12-15 11:59:31 +01:00
|
|
|
|
2014-01-01 17:40:22 +01:00
|
|
|
if #connects == 0 then
|
|
|
|
pgroups = {snappy = 3, tube = 1}
|
2020-02-18 18:34:52 +01:00
|
|
|
pipedesc = S("Pipe Segment")
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
2014-01-01 17:40:22 +01:00
|
|
|
|
2015-01-15 12:25:41 +01:00
|
|
|
local outimg_e = { "pipeworks_pipe_plain.png" }
|
|
|
|
local outimg_l = { "pipeworks_pipe_plain.png" }
|
|
|
|
|
|
|
|
if index == 3 then
|
|
|
|
outimg_e = { "pipeworks_pipe_3_empty.png" }
|
|
|
|
outimg_l = { "pipeworks_pipe_3_loaded.png" }
|
|
|
|
end
|
|
|
|
|
2017-10-26 10:11:30 +02:00
|
|
|
local mesh = "pipeworks_pipe_"..index..polys..".obj"
|
2015-01-15 12:25:41 +01:00
|
|
|
|
|
|
|
if index == 1 then
|
2017-10-26 10:11:30 +02:00
|
|
|
mesh = "pipeworks_pipe_3"..polys..".obj"
|
2015-01-15 12:25:41 +01:00
|
|
|
end
|
|
|
|
|
2014-01-01 17:40:22 +01:00
|
|
|
minetest.register_node("pipeworks:pipe_"..index.."_empty", {
|
2013-07-14 04:39:25 +02:00
|
|
|
description = pipedesc,
|
2015-01-15 12:25:41 +01:00
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = mesh,
|
|
|
|
tiles = outimg_e,
|
2014-01-01 17:40:22 +01:00
|
|
|
sunlight_propagates = true,
|
2013-07-14 04:39:25 +02:00
|
|
|
paramtype = "light",
|
2014-01-01 17:40:22 +01:00
|
|
|
paramtype2 = "facedir",
|
2013-07-14 04:39:25 +02:00
|
|
|
selection_box = {
|
2015-01-15 12:25:41 +01:00
|
|
|
type = "fixed",
|
2013-07-14 04:39:25 +02:00
|
|
|
fixed = outsel
|
|
|
|
},
|
2015-01-15 12:25:41 +01:00
|
|
|
collision_box = {
|
2013-07-14 04:39:25 +02:00
|
|
|
type = "fixed",
|
2015-01-15 12:25:41 +01:00
|
|
|
fixed = outsel
|
2013-07-14 04:39:25 +02:00
|
|
|
},
|
|
|
|
groups = pgroups,
|
2019-09-23 21:36:33 +02:00
|
|
|
sounds = default.node_sound_metal_defaults(),
|
2013-07-14 04:39:25 +02:00
|
|
|
walkable = true,
|
2014-01-01 17:40:22 +01:00
|
|
|
drop = "pipeworks:pipe_1_empty",
|
2013-07-14 04:39:25 +02:00
|
|
|
after_place_node = function(pos)
|
2013-12-15 08:53:10 +01:00
|
|
|
pipeworks.scan_for_pipe_objects(pos)
|
2013-07-14 04:39:25 +02:00
|
|
|
end,
|
|
|
|
after_dig_node = function(pos)
|
2013-12-15 08:53:10 +01:00
|
|
|
pipeworks.scan_for_pipe_objects(pos)
|
2017-03-17 14:02:34 +01:00
|
|
|
end,
|
2019-09-23 18:21:54 +02:00
|
|
|
on_rotate = false,
|
|
|
|
check_for_pole = pipeworks.check_for_vert_pipe,
|
|
|
|
check_for_horiz_pole = pipeworks.check_for_horiz_pipe,
|
|
|
|
pipenumber = index
|
2013-07-14 04:39:25 +02:00
|
|
|
})
|
2014-01-01 17:40:22 +01:00
|
|
|
|
2014-01-01 19:21:40 +01:00
|
|
|
local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1}
|
|
|
|
|
2014-01-01 17:40:22 +01:00
|
|
|
minetest.register_node("pipeworks:pipe_"..index.."_loaded", {
|
|
|
|
description = pipedesc,
|
2015-01-15 12:25:41 +01:00
|
|
|
drawtype = "mesh",
|
|
|
|
mesh = mesh,
|
|
|
|
tiles = outimg_l,
|
2013-07-14 04:39:25 +02:00
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype = "light",
|
2014-01-01 17:40:22 +01:00
|
|
|
paramtype2 = "facedir",
|
2013-07-14 04:39:25 +02:00
|
|
|
selection_box = {
|
2015-01-15 12:25:41 +01:00
|
|
|
type = "fixed",
|
2013-07-14 04:39:25 +02:00
|
|
|
fixed = outsel
|
|
|
|
},
|
2015-01-15 12:25:41 +01:00
|
|
|
collision_box = {
|
2013-07-14 04:39:25 +02:00
|
|
|
type = "fixed",
|
2015-01-15 12:25:41 +01:00
|
|
|
fixed = outsel
|
2013-07-14 04:39:25 +02:00
|
|
|
},
|
2014-01-01 17:40:22 +01:00
|
|
|
groups = pgroups,
|
2019-09-23 21:36:33 +02:00
|
|
|
sounds = default.node_sound_metal_defaults(),
|
2013-07-14 04:39:25 +02:00
|
|
|
walkable = true,
|
2014-01-01 17:40:22 +01:00
|
|
|
drop = "pipeworks:pipe_1_empty",
|
2013-07-14 04:39:25 +02:00
|
|
|
after_place_node = function(pos)
|
2017-03-17 16:04:59 +01:00
|
|
|
minetest.set_node(pos, { name = "pipeworks:pipe_"..index.."_empty" })
|
2013-12-15 08:53:10 +01:00
|
|
|
pipeworks.scan_for_pipe_objects(pos)
|
2013-07-14 04:39:25 +02:00
|
|
|
end,
|
|
|
|
after_dig_node = function(pos)
|
2013-12-15 08:53:10 +01:00
|
|
|
pipeworks.scan_for_pipe_objects(pos)
|
2017-03-17 14:02:34 +01:00
|
|
|
end,
|
2019-09-23 18:21:54 +02:00
|
|
|
on_rotate = false,
|
|
|
|
check_for_pole = pipeworks.check_for_vert_pipe,
|
|
|
|
check_for_horiz_pole = pipeworks.check_for_horiz_pipe,
|
|
|
|
pipenumber = index
|
2013-07-14 04:39:25 +02:00
|
|
|
})
|
2014-01-01 17:40:22 +01:00
|
|
|
|
2017-10-01 17:54:24 +02:00
|
|
|
local emptypipe = "pipeworks:pipe_"..index.."_empty"
|
|
|
|
local fullpipe = "pipeworks:pipe_"..index.."_loaded"
|
|
|
|
table.insert(pipes_empty_nodenames, emptypipe)
|
|
|
|
table.insert(pipes_full_nodenames, fullpipe)
|
|
|
|
new_flow_logic_register.simple(emptypipe)
|
|
|
|
new_flow_logic_register.simple(fullpipe)
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
2014-01-01 17:40:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if REGISTER_COMPATIBILITY then
|
2014-01-01 18:04:45 +01:00
|
|
|
local cempty = "pipeworks:pipe_compatibility_empty"
|
|
|
|
local cloaded = "pipeworks:pipe_compatibility_loaded"
|
2014-01-01 17:40:22 +01:00
|
|
|
minetest.register_node(cempty, {
|
|
|
|
drawtype = "airlike",
|
2014-01-01 19:34:30 +01:00
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype = "light",
|
2020-02-18 18:34:52 +01:00
|
|
|
description = S("Pipe Segment (legacy)"),
|
2014-01-01 17:40:22 +01:00
|
|
|
groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
|
2014-01-01 19:26:25 +01:00
|
|
|
drop = "pipeworks:pipe_1_empty",
|
2014-01-01 19:34:30 +01:00
|
|
|
after_place_node = function(pos)
|
|
|
|
pipeworks.scan_for_pipe_objects(pos)
|
|
|
|
end,
|
2017-03-17 14:02:34 +01:00
|
|
|
on_rotate = false
|
|
|
|
|
2014-01-01 17:40:22 +01:00
|
|
|
})
|
|
|
|
minetest.register_node(cloaded, {
|
|
|
|
drawtype = "airlike",
|
2014-01-01 19:34:30 +01:00
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype = "light",
|
2014-01-01 17:40:22 +01:00
|
|
|
groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
|
2014-01-01 19:26:25 +01:00
|
|
|
drop = "pipeworks:pipe_1_empty",
|
2014-01-01 19:34:30 +01:00
|
|
|
after_place_node = function(pos)
|
|
|
|
pipeworks.scan_for_pipe_objects(pos)
|
|
|
|
end,
|
2017-03-17 14:02:34 +01:00
|
|
|
on_rotate = false
|
|
|
|
|
2014-01-01 17:40:22 +01:00
|
|
|
})
|
|
|
|
for xm = 0, 1 do
|
|
|
|
for xp = 0, 1 do
|
|
|
|
for ym = 0, 1 do
|
|
|
|
for yp = 0, 1 do
|
|
|
|
for zm = 0, 1 do
|
|
|
|
for zp = 0, 1 do
|
|
|
|
local pname = xm..xp..ym..yp..zm..zp
|
2014-01-01 18:04:45 +01:00
|
|
|
minetest.register_alias("pipeworks:pipe_"..pname.."_empty", cempty)
|
|
|
|
minetest.register_alias("pipeworks:pipe_"..pname.."_loaded", cloaded)
|
2014-01-01 17:40:22 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"group:pipe_to_update"},
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2014-01-01 18:26:33 +01:00
|
|
|
local minp = {x = pos.x-1, y = pos.y-1, z = pos.z-1}
|
|
|
|
local maxp = {x = pos.x+1, y = pos.y+1, z = pos.z+1}
|
|
|
|
if table.getn(minetest.find_nodes_in_area(minp, maxp, "ignore")) == 0 then
|
|
|
|
pipeworks.scan_for_pipe_objects(pos)
|
|
|
|
end
|
2014-01-01 17:40:22 +01:00
|
|
|
end
|
|
|
|
})
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
|
|
|
|
2017-10-01 17:54:24 +02:00
|
|
|
local valve_on = "pipeworks:valve_on_empty"
|
|
|
|
local valve_off = "pipeworks:valve_off_empty"
|
|
|
|
local entry_panel_empty = "pipeworks:entry_panel_empty"
|
|
|
|
local flow_sensor_empty = "pipeworks:flow_sensor_empty"
|
2017-11-04 03:09:25 +01:00
|
|
|
local sp_empty = "pipeworks:straight_pipe_empty"
|
2017-10-01 18:36:03 +02:00
|
|
|
-- XXX: why aren't these in devices.lua!?
|
2017-10-01 17:54:24 +02:00
|
|
|
table.insert(pipes_empty_nodenames, valve_on)
|
|
|
|
table.insert(pipes_empty_nodenames, valve_off)
|
|
|
|
table.insert(pipes_empty_nodenames, entry_panel_empty)
|
|
|
|
table.insert(pipes_empty_nodenames, flow_sensor_empty)
|
2017-11-04 03:09:25 +01:00
|
|
|
table.insert(pipes_empty_nodenames, sp_empty)
|
2013-07-14 04:39:25 +02:00
|
|
|
|
2017-10-01 17:54:24 +02:00
|
|
|
local valve_on_loaded = "pipeworks:valve_on_loaded"
|
|
|
|
local entry_panel_loaded = "pipeworks:entry_panel_loaded"
|
|
|
|
local flow_sensor_loaded = "pipeworks:flow_sensor_loaded"
|
2017-11-04 03:09:25 +01:00
|
|
|
local sp_loaded = "pipeworks:straight_pipe_loaded"
|
2017-10-01 17:54:24 +02:00
|
|
|
table.insert(pipes_full_nodenames, valve_on_loaded)
|
|
|
|
table.insert(pipes_full_nodenames, entry_panel_loaded)
|
|
|
|
table.insert(pipes_full_nodenames, flow_sensor_loaded)
|
2017-11-04 03:09:25 +01:00
|
|
|
table.insert(pipes_full_nodenames, sp_loaded)
|
2013-07-14 04:39:25 +02:00
|
|
|
|
2017-09-27 18:00:18 +02:00
|
|
|
pipeworks.pipes_full_nodenames = pipes_full_nodenames
|
|
|
|
pipeworks.pipes_empty_nodenames = pipes_empty_nodenames
|
|
|
|
|
2017-10-20 23:46:51 +02:00
|
|
|
if pipeworks.toggles.pipe_mode == "classic" then
|
2017-10-01 17:54:24 +02:00
|
|
|
|
2013-07-14 04:39:25 +02:00
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = pipes_empty_nodenames,
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2013-12-15 08:53:10 +01:00
|
|
|
pipeworks.check_for_inflows(pos,node)
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = pipes_full_nodenames,
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2013-12-15 08:53:10 +01:00
|
|
|
pipeworks.check_sources(pos,node)
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"pipeworks:spigot","pipeworks:spigot_pouring"},
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2013-12-15 08:53:10 +01:00
|
|
|
pipeworks.spigot_check(pos,node)
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
|
|
|
})
|
2013-10-28 03:38:19 +01:00
|
|
|
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = {"pipeworks:fountainhead","pipeworks:fountainhead_pouring"},
|
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
2013-12-15 08:53:10 +01:00
|
|
|
pipeworks.fountainhead_check(pos,node)
|
2013-10-28 03:38:19 +01:00
|
|
|
end
|
|
|
|
})
|
|
|
|
|
2017-09-27 15:14:33 +02:00
|
|
|
|
2017-09-27 16:19:20 +02:00
|
|
|
|
2017-09-27 17:20:07 +02:00
|
|
|
end
|