1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
|
if pipeworks.enable_detector_tube then
local detector_tube_step = 5 * tonumber(minetest.settings:get("dedicated_server_step"))
pipeworks.register_tube("pipeworks:detector_tube_on", {
description = "Detecting Pneumatic Tube Segment on (you hacker you)",
inventory_image = "pipeworks_detector_tube_inv.png",
plain = { "pipeworks_detector_tube_plain.png" },
node_def = {
tube = {can_go = function(pos, node, velocity, stack)
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)
minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
return pipeworks.notvel(pipeworks.meseadjlist,velocity)
end},
groups = {mesecon = 2, not_in_creative_inventory = 1},
drop = "pipeworks:detector_tube_off_1",
mesecons = {receptor = {state = "on", rules = pipeworks.mesecons_rules}},
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)
minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos)
end,
},
})
pipeworks.register_tube("pipeworks:detector_tube_off", {
description = "Detecting Pneumatic Tube Segment",
inventory_image = "pipeworks_detector_tube_inv.png",
plain = { "pipeworks_detector_tube_plain.png" },
node_def = {
tube = {can_go = function(pos, node, velocity, stack)
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},
groups = {mesecon = 2},
mesecons = {receptor = {state = "off", rules = pipeworks.mesecons_rules }},
},
})
minetest.register_craft( {
output = "pipeworks:detector_tube_off_1 2",
recipe = {
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
{ "mesecons:mesecon", "mesecons_materials:silicon", "mesecons:mesecon" },
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
},
})
end
local digiline_enabled = minetest.get_modpath("digilines") ~= nil
if digiline_enabled and pipeworks.enable_digiline_detector_tube then
pipeworks.register_tube("pipeworks:digiline_detector_tube", {
description = "Digiline Detecting Pneumatic Tube Segment",
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")
digiline:receptor_send(pos, digiline.rules.default, setchan, stack:to_string())
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]"..
"field[0.6,0.6;8,1;channel;Channel:;${channel}]"..
"image[0.3,1.3;1,1;pipeworks_digiline_detector_tube_inv.png]"..
"label[1.6,1.2;Digiline Detecting Tube]"
)
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
}
},
},
})
minetest.register_craft( {
output = "pipeworks:digiline_detector_tube_1 2",
recipe = {
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
{ "digilines:wire_std_00000000", "mesecons_materials:silicon", "digilines:wire_std_00000000" },
{ "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
},
})
end
if pipeworks.enable_conductor_tube then
pipeworks.register_tube("pipeworks:conductor_tube_off", {
description = "Conducting Pneumatic Tube Segment",
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",
rules = pipeworks.mesecons_rules,
onstate = "pipeworks:conductor_tube_on_#id"}}
},
})
pipeworks.register_tube("pipeworks:conductor_tube_on", {
description = "Conducting Pneumatic Tube Segment on (you hacker you)",
inventory_image = "pipeworks_conductor_tube_inv.png",
short = "pipeworks_conductor_tube_short.png",
plain = { "pipeworks_conductor_tube_on_plain.png" },
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",
rules = pipeworks.mesecons_rules,
offstate = "pipeworks:conductor_tube_off_#id"}}
},
})
minetest.register_craft({
type = "shapeless",
output = "pipeworks:conductor_tube_off_1",
recipe = {"pipeworks:tube_1", "mesecons:mesecon"}
})
end
if digiline_enabled and pipeworks.enable_digiline_conductor_tube then
pipeworks.register_tube("pipeworks:digiline_conductor_tube", {
description = "Digiline Conducting Pneumatic Tube Segment",
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
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", {
description = "Mesecon and Digiline Conducting Pneumatic Tube Segment",
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", {
description = "Mesecon and Digiline Conducting Pneumatic Tube Segment on (you hacker you)",
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
|