2013-12-15 10:35:59 +01:00
|
|
|
-- This file supplies the steel pipes
|
2013-07-14 04:39:25 +02:00
|
|
|
|
2013-12-15 10:35:59 +01:00
|
|
|
local pipes_empty_nodenames = {}
|
|
|
|
local pipes_full_nodenames = {}
|
2013-07-14 04:39:25 +02:00
|
|
|
|
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 outboxes = {}
|
|
|
|
local outsel = {}
|
|
|
|
local outimgs = {}
|
|
|
|
|
|
|
|
for i = 1, 6 do
|
|
|
|
outimgs[vti[i]] = "pipeworks_plain.png"
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
2014-01-01 17:40:22 +01:00
|
|
|
|
|
|
|
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
|
|
|
pipeworks.add_node_box(outboxes, pipeworks.pipe_boxes[v])
|
|
|
|
table.insert(outsel, pipeworks.pipe_selectboxes[v])
|
|
|
|
outimgs[vti[v]] = "pipeworks_pipe_end.png"
|
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
|
|
|
|
outimgs[vti[v]] = "^pipeworks_plain.png"
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
|
|
|
|
2014-01-01 17:40:22 +01:00
|
|
|
if #connects >= 2 then
|
|
|
|
pipeworks.add_node_box(outboxes, pipeworks.pipe_bendsphere)
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
2014-01-01 17:40:22 +01:00
|
|
|
|
|
|
|
if jx == 2 and jy ~= 2 and jz ~= 2 then
|
|
|
|
outimgs[5] = pipeworks.liquid_texture.."^pipeworks_windowed_XXXXX.png"
|
|
|
|
outimgs[6] = outimgs[5]
|
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}
|
|
|
|
local pipedesc = "Pipe segement".." "..dump(connects).."... You hacker, you."
|
2013-12-15 11:59:31 +01:00
|
|
|
local image = nil
|
|
|
|
|
2014-01-01 17:40:22 +01:00
|
|
|
if #connects == 0 then
|
|
|
|
pgroups = {snappy = 3, tube = 1}
|
|
|
|
pipedesc = "Pipe segment"
|
2013-07-14 04:39:25 +02:00
|
|
|
image = "pipeworks_plain.png"
|
|
|
|
end
|
2014-01-01 17:40:22 +01:00
|
|
|
|
|
|
|
--table.insert(pipeworks.tubenodes, name.."_"..tname)
|
|
|
|
|
|
|
|
minetest.register_node("pipeworks:pipe_"..index.."_empty", {
|
2013-07-14 04:39:25 +02:00
|
|
|
description = pipedesc,
|
|
|
|
drawtype = "nodebox",
|
2013-12-15 08:53:10 +01:00
|
|
|
tiles = pipeworks.fix_image_names(outimgs, "_empty"),
|
2014-01-01 17:40:22 +01:00
|
|
|
sunlight_propagates = true,
|
2013-07-14 04:39:25 +02:00
|
|
|
inventory_image = image,
|
|
|
|
paramtype = "light",
|
2014-01-01 17:40:22 +01:00
|
|
|
paramtype2 = "facedir",
|
2013-07-14 04:39:25 +02:00
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = outsel
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = outboxes
|
|
|
|
},
|
|
|
|
groups = pgroups,
|
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
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)
|
2014-01-01 17:40:22 +01:00
|
|
|
end
|
2013-07-14 04:39:25 +02:00
|
|
|
})
|
2014-01-01 17:40:22 +01:00
|
|
|
|
|
|
|
minetest.register_node("pipeworks:pipe_"..index.."_loaded", {
|
|
|
|
description = pipedesc,
|
2013-07-14 04:39:25 +02:00
|
|
|
drawtype = "nodebox",
|
2013-12-15 08:53:10 +01:00
|
|
|
tiles = pipeworks.fix_image_names(outimgs, "_loaded"),
|
2013-07-14 04:39:25 +02:00
|
|
|
sunlight_propagates = true,
|
2014-01-01 17:40:22 +01:00
|
|
|
inventory_image = image,
|
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 = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = outsel
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = outboxes
|
|
|
|
},
|
2014-01-01 17:40:22 +01:00
|
|
|
groups = pgroups,
|
2013-07-14 04:39:25 +02:00
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
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)
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
|
|
|
})
|
2014-01-01 17:40:22 +01:00
|
|
|
|
|
|
|
table.insert(pipes_empty_nodenames, "pipeworks:pipe_"..index.."_empty")
|
|
|
|
table.insert(pipes_empty_nodenames, "pipeworks:pipe_"..index.."_loaded")
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
2014-01-01 17:40:22 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if REGISTER_COMPATIBILITY then
|
|
|
|
local cempty = "pipeworks:tube_compatibility_empty"
|
|
|
|
local cloaded = "pipeworks:tube_compatibility_loaded"
|
|
|
|
minetest.register_node(cempty, {
|
|
|
|
drawtype = "airlike",
|
|
|
|
groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
|
|
|
|
})
|
|
|
|
minetest.register_node(cloaded, {
|
|
|
|
drawtype = "airlike",
|
|
|
|
groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
|
|
|
|
})
|
|
|
|
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
|
|
|
|
minetest.register_alias("pipeworks_"..pname.."_empty", cempty)
|
|
|
|
minetest.register_alias("pipeworks_"..pname.."_loaded", cloaded)
|
|
|
|
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)
|
|
|
|
pipeworks.scan_for_pipe_objects(pos)
|
|
|
|
end
|
|
|
|
})
|
2013-07-14 04:39:25 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
table.insert(pipes_empty_nodenames,"pipeworks:valve_on_empty")
|
|
|
|
table.insert(pipes_empty_nodenames,"pipeworks:valve_off_empty")
|
|
|
|
table.insert(pipes_empty_nodenames,"pipeworks:entry_panel_empty")
|
|
|
|
table.insert(pipes_empty_nodenames,"pipeworks:flow_sensor_empty")
|
|
|
|
|
|
|
|
table.insert(pipes_full_nodenames,"pipeworks:valve_on_loaded")
|
|
|
|
table.insert(pipes_full_nodenames,"pipeworks:entry_panel_loaded")
|
|
|
|
table.insert(pipes_full_nodenames,"pipeworks:flow_sensor_loaded")
|
|
|
|
|
|
|
|
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
|
|
|
|
})
|
|
|
|
|