2020-02-18 18:34:52 +01:00
|
|
|
local S = minetest.get_translator("pipeworks")
|
2021-03-30 14:15:23 +02:00
|
|
|
|
|
|
|
-- the minetest.after() calls below can sometimes trigger after a tube
|
|
|
|
-- breaks, at which point item_exit() is no longer valid, so we have to make
|
|
|
|
-- sure that there even IS a callback to run, first.
|
|
|
|
|
|
|
|
local function after_break(pos)
|
|
|
|
local name = minetest.get_node(pos).name
|
|
|
|
if minetest.registered_nodes[name].item_exit then
|
|
|
|
minetest.registered_nodes[name].item_exit(pos)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-01-29 22:24:14 +01:00
|
|
|
if pipeworks.enable_detector_tube then
|
2017-05-18 11:33:56 +02:00
|
|
|
local detector_tube_step = 5 * tonumber(minetest.settings:get("dedicated_server_step"))
|
2015-01-31 16:10:25 +01:00
|
|
|
pipeworks.register_tube("pipeworks:detector_tube_on", {
|
2020-02-18 18:34:52 +01:00
|
|
|
description = S("Detecting Pneumatic Tube Segment on"),
|
2015-01-31 16:10:25 +01:00
|
|
|
inventory_image = "pipeworks_detector_tube_inv.png",
|
|
|
|
plain = { "pipeworks_detector_tube_plain.png" },
|
|
|
|
node_def = {
|
|
|
|
tube = {can_go = function(pos, node, velocity, stack)
|
2015-01-29 22:24:14 +01:00
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local name = minetest.get_node(pos).name
|
|
|
|
local nitems = meta:get_int("nitems")+1
|
|
|
|
meta:set_int("nitems", nitems)
|
|
|
|
local saved_pos = vector.new(pos)
|
2021-03-30 14:15:23 +02:00
|
|
|
minetest.after(detector_tube_step, after_break, saved_pos)
|
2015-01-29 22:24:14 +01:00
|
|
|
return pipeworks.notvel(pipeworks.meseadjlist,velocity)
|
|
|
|
end},
|
|
|
|
groups = {mesecon = 2, not_in_creative_inventory = 1},
|
|
|
|
drop = "pipeworks:detector_tube_off_1",
|
2015-01-31 16:10:25 +01:00
|
|
|
mesecons = {receptor = {state = "on", rules = pipeworks.mesecons_rules}},
|
2015-01-29 22:24:14 +01:00
|
|
|
item_exit = function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
local nitems = meta:get_int("nitems")-1
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
local name = node.name
|
|
|
|
local fdir = node.param2
|
|
|
|
if nitems == 0 then
|
|
|
|
minetest.set_node(pos, {name = string.gsub(name, "on", "off"), param2 = fdir})
|
|
|
|
mesecon.receptor_off(pos, pipeworks.mesecons_rules)
|
|
|
|
else
|
|
|
|
meta:set_int("nitems", nitems)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
on_construct = function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_int("nitems", 1)
|
|
|
|
local name = minetest.get_node(pos).name
|
|
|
|
local saved_pos = vector.new(pos)
|
2021-03-30 14:15:23 +02:00
|
|
|
minetest.after(detector_tube_step, after_break, pos)
|
2015-01-31 16:10:25 +01:00
|
|
|
end,
|
|
|
|
},
|
2015-01-29 22:24:14 +01:00
|
|
|
})
|
2015-01-31 16:10:25 +01:00
|
|
|
pipeworks.register_tube("pipeworks:detector_tube_off", {
|
2020-02-18 18:34:52 +01:00
|
|
|
description = S("Detecting Pneumatic Tube Segment"),
|
2015-01-31 16:10:25 +01:00
|
|
|
inventory_image = "pipeworks_detector_tube_inv.png",
|
|
|
|
plain = { "pipeworks_detector_tube_plain.png" },
|
|
|
|
node_def = {
|
|
|
|
tube = {can_go = function(pos, node, velocity, stack)
|
2015-01-29 22:24:14 +01:00
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
local name = node.name
|
|
|
|
local fdir = node.param2
|
|
|
|
minetest.set_node(pos,{name = string.gsub(name, "off", "on"), param2 = fdir})
|
|
|
|
mesecon.receptor_on(pos, pipeworks.mesecons_rules)
|
|
|
|
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
|
|
|
|
end},
|
2015-01-31 16:10:25 +01:00
|
|
|
groups = {mesecon = 2},
|
|
|
|
mesecons = {receptor = {state = "off", rules = pipeworks.mesecons_rules }},
|
|
|
|
},
|
2015-01-29 22:24:14 +01:00
|
|
|
})
|
2015-01-29 22:47:33 +01:00
|
|
|
|
|
|
|
minetest.register_craft( {
|
2016-04-18 05:05:38 +02:00
|
|
|
output = "pipeworks:detector_tube_off_1 2",
|
2015-01-29 22:47:33 +01:00
|
|
|
recipe = {
|
2018-10-31 01:45:48 +01:00
|
|
|
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
2016-04-18 05:05:38 +02:00
|
|
|
{ "mesecons:mesecon", "mesecons_materials:silicon", "mesecons:mesecon" },
|
2018-10-31 01:45:48 +01:00
|
|
|
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
|
2015-01-29 22:47:33 +01:00
|
|
|
},
|
|
|
|
})
|
2015-01-29 22:24:14 +01:00
|
|
|
end
|
|
|
|
|
2017-09-26 05:19:35 +02:00
|
|
|
local digiline_enabled = minetest.get_modpath("digilines") ~= nil
|
|
|
|
if digiline_enabled and pipeworks.enable_digiline_detector_tube then
|
2016-06-12 02:14:38 +02:00
|
|
|
pipeworks.register_tube("pipeworks:digiline_detector_tube", {
|
2020-02-18 18:34:52 +01:00
|
|
|
description = S("Digiline Detecting Pneumatic Tube Segment"),
|
2016-06-12 02:14:38 +02:00
|
|
|
inventory_image = "pipeworks_digiline_detector_tube_inv.png",
|
|
|
|
plain = { "pipeworks_digiline_detector_tube_plain.png" },
|
|
|
|
node_def = {
|
|
|
|
tube = {can_go = function(pos, node, velocity, stack)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
|
|
|
|
local setchan = meta:get_string("channel")
|
|
|
|
|
2020-04-28 05:08:31 +02:00
|
|
|
digiline:receptor_send(pos, digiline.rules.default, setchan, stack:to_table())
|
2016-06-12 02:14:38 +02:00
|
|
|
|
|
|
|
return pipeworks.notvel(pipeworks.meseadjlist, velocity)
|
|
|
|
end},
|
|
|
|
on_construct = function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_string("formspec",
|
|
|
|
"size[8.6,2.2]"..
|
2020-02-18 18:34:52 +01:00
|
|
|
"field[0.6,0.6;8,1;channel;"..S("Channel")..";${channel}]"..
|
2016-06-12 02:14:38 +02:00
|
|
|
"image[0.3,1.3;1,1;pipeworks_digiline_detector_tube_inv.png]"..
|
2020-02-18 18:34:52 +01:00
|
|
|
"label[1.6,1.2;"..S("Digiline Detecting Tube").."]"
|
2016-06-12 02:14:38 +02:00
|
|
|
)
|
|
|
|
end,
|
|
|
|
on_receive_fields = function(pos, formname, fields, sender)
|
|
|
|
if fields.channel then
|
|
|
|
minetest.get_meta(pos):set_string("channel", fields.channel)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
groups = {},
|
|
|
|
digiline = {
|
|
|
|
receptor = {},
|
|
|
|
effector = {
|
|
|
|
action = function(pos,node,channel,msg) end
|
2018-11-14 05:07:33 +01:00
|
|
|
},
|
|
|
|
wire = {
|
|
|
|
rules = pipeworks.digilines_rules
|
|
|
|
},
|
2016-06-12 02:14:38 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft( {
|
|
|
|
output = "pipeworks:digiline_detector_tube_1 2",
|
|
|
|
recipe = {
|
2018-10-31 01:45:48 +01:00
|
|
|
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
|
2016-06-12 02:14:38 +02:00
|
|
|
{ "digilines:wire_std_00000000", "mesecons_materials:silicon", "digilines:wire_std_00000000" },
|
2018-10-31 01:45:48 +01:00
|
|
|
{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
|
2016-06-12 02:14:38 +02:00
|
|
|
},
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2015-01-29 22:24:14 +01:00
|
|
|
if pipeworks.enable_conductor_tube then
|
2015-01-31 16:10:25 +01:00
|
|
|
pipeworks.register_tube("pipeworks:conductor_tube_off", {
|
2020-02-18 18:34:52 +01:00
|
|
|
description = S("Conducting Pneumatic Tube Segment"),
|
2015-01-31 16:10:25 +01:00
|
|
|
inventory_image = "pipeworks_conductor_tube_inv.png",
|
|
|
|
short = "pipeworks_conductor_tube_short.png",
|
|
|
|
plain = { "pipeworks_conductor_tube_plain.png" },
|
|
|
|
noctr = { "pipeworks_conductor_tube_noctr.png" },
|
|
|
|
ends = { "pipeworks_conductor_tube_end.png" },
|
|
|
|
node_def = {
|
|
|
|
groups = {mesecon = 2},
|
|
|
|
mesecons = {conductor = {state = "off",
|
2015-01-29 22:24:14 +01:00
|
|
|
rules = pipeworks.mesecons_rules,
|
|
|
|
onstate = "pipeworks:conductor_tube_on_#id"}}
|
2015-01-31 16:10:25 +01:00
|
|
|
},
|
2015-01-29 22:24:14 +01:00
|
|
|
})
|
2015-01-31 16:10:25 +01:00
|
|
|
pipeworks.register_tube("pipeworks:conductor_tube_on", {
|
2020-02-18 18:34:52 +01:00
|
|
|
description = S("Conducting Pneumatic Tube Segment on"),
|
2015-01-31 16:10:25 +01:00
|
|
|
inventory_image = "pipeworks_conductor_tube_inv.png",
|
|
|
|
short = "pipeworks_conductor_tube_short.png",
|
2015-02-08 11:00:07 +01:00
|
|
|
plain = { "pipeworks_conductor_tube_on_plain.png" },
|
2015-01-31 16:10:25 +01:00
|
|
|
noctr = { "pipeworks_conductor_tube_on_noctr.png" },
|
|
|
|
ends = { "pipeworks_conductor_tube_on_end.png" },
|
|
|
|
node_def = {
|
|
|
|
groups = {mesecon = 2, not_in_creative_inventory = 1},
|
|
|
|
drop = "pipeworks:conductor_tube_off_1",
|
|
|
|
mesecons = {conductor = {state = "on",
|
2015-01-29 22:24:14 +01:00
|
|
|
rules = pipeworks.mesecons_rules,
|
|
|
|
offstate = "pipeworks:conductor_tube_off_#id"}}
|
2015-01-31 16:10:25 +01:00
|
|
|
},
|
2015-01-29 22:24:14 +01:00
|
|
|
})
|
2015-01-29 22:47:33 +01:00
|
|
|
|
2017-09-26 05:19:35 +02:00
|
|
|
minetest.register_craft({
|
|
|
|
type = "shapeless",
|
|
|
|
output = "pipeworks:conductor_tube_off_1",
|
|
|
|
recipe = {"pipeworks:tube_1", "mesecons:mesecon"}
|
2015-01-29 22:47:33 +01:00
|
|
|
})
|
2015-01-29 22:24:14 +01:00
|
|
|
end
|
|
|
|
|
2017-09-26 05:19:35 +02:00
|
|
|
if digiline_enabled and pipeworks.enable_digiline_conductor_tube then
|
|
|
|
pipeworks.register_tube("pipeworks:digiline_conductor_tube", {
|
2020-02-18 18:34:52 +01:00
|
|
|
description = S("Digiline Conducting Pneumatic Tube Segment"),
|
2017-09-26 05:19:35 +02:00
|
|
|
inventory_image = "pipeworks_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
|
|
|
|
short = "pipeworks_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
|
|
|
|
plain = {"pipeworks_tube_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
|
|
|
|
noctr = {"pipeworks_tube_noctr.png^pipeworks_digiline_conductor_tube_noctr.png"},
|
|
|
|
ends = {"pipeworks_tube_end.png^pipeworks_digiline_conductor_tube_end.png"},
|
|
|
|
node_def = {digiline = {wire = {rules = pipeworks.digilines_rules}}},
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "shapeless",
|
|
|
|
output = "pipeworks:digiline_conductor_tube_1",
|
|
|
|
recipe = {"pipeworks:tube_1", "digilines:wire_std_00000000"}
|
|
|
|
})
|
|
|
|
end
|
2015-01-29 22:24:14 +01:00
|
|
|
|
2017-09-26 05:19:35 +02:00
|
|
|
if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
|
|
|
|
pipeworks.enable_conductor_tube then
|
|
|
|
pipeworks.register_tube("pipeworks:mesecon_and_digiline_conductor_tube_off", {
|
2020-02-18 18:34:52 +01:00
|
|
|
description = S("Mesecon and Digiline Conducting Pneumatic Tube Segment"),
|
2017-09-26 05:19:35 +02:00
|
|
|
inventory_image = "pipeworks_conductor_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
|
|
|
|
short = "pipeworks_conductor_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
|
|
|
|
plain = {"pipeworks_conductor_tube_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
|
|
|
|
noctr = {"pipeworks_conductor_tube_noctr.png^pipeworks_digiline_conductor_tube_noctr.png"},
|
|
|
|
ends = {"pipeworks_conductor_tube_end.png^pipeworks_digiline_conductor_tube_end.png"},
|
|
|
|
node_def = {
|
|
|
|
digiline = {wire = {rules = pipeworks.digilines_rules}},
|
|
|
|
groups = {mesecon = 2},
|
|
|
|
mesecons = {conductor = {
|
|
|
|
state = "off",
|
|
|
|
rules = pipeworks.mesecons_rules,
|
|
|
|
onstate = "pipeworks:mesecon_and_digiline_conductor_tube_on_#id"
|
|
|
|
}},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
pipeworks.register_tube("pipeworks:mesecon_and_digiline_conductor_tube_on", {
|
2020-02-18 18:34:52 +01:00
|
|
|
description = S("Mesecon and Digiline Conducting Pneumatic Tube Segment on"),
|
2017-09-26 05:19:35 +02:00
|
|
|
inventory_image = "pipeworks_conductor_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
|
|
|
|
short = "pipeworks_conductor_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
|
|
|
|
plain = {"pipeworks_conductor_tube_on_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
|
|
|
|
noctr = {"pipeworks_conductor_tube_on_noctr.png^pipeworks_digiline_conductor_tube_noctr.png"},
|
|
|
|
ends = {"pipeworks_conductor_tube_on_end.png^pipeworks_digiline_conductor_tube_end.png"},
|
|
|
|
node_def = {
|
|
|
|
digiline = {wire = {rules = pipeworks.digilines_rules}},
|
|
|
|
groups = {mesecon = 2, not_in_creative_inventory = 1},
|
|
|
|
drop = "pipeworks:mesecon_and_digiline_conductor_tube_off_1",
|
|
|
|
mesecons = {conductor = {
|
|
|
|
state = "on",
|
|
|
|
rules = pipeworks.mesecons_rules,
|
|
|
|
offstate = "pipeworks:mesecon_and_digiline_conductor_tube_off_#id"}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "shapeless",
|
|
|
|
output = "pipeworks:mesecon_and_digiline_conductor_tube_off_1",
|
|
|
|
recipe = {"pipeworks:tube_1", "mesecons:mesecon", "digilines:wire_std_00000000"}
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "shapeless",
|
|
|
|
output = "pipeworks:mesecon_and_digiline_conductor_tube_off_1",
|
|
|
|
recipe = {"pipeworks:conductor_tube_off_1", "digilines:wire_std_00000000"}
|
|
|
|
})
|
|
|
|
minetest.register_craft({
|
|
|
|
type = "shapeless",
|
|
|
|
output = "pipeworks:mesecon_and_digiline_conductor_tube_off_1",
|
|
|
|
recipe = {"pipeworks:digiline_conductor_tube_1", "mesecons:mesecon"}
|
|
|
|
})
|
|
|
|
end
|