1
1
-- vi: noexpandtab
2
2
3
+ -- local has_digilines = minetest.get_modpath("digilines") and true
4
+ local has_pipeworks = minetest .get_modpath (" pipeworks" ) and true
5
+
3
6
local cable_entry = " ^technic_cable_connection_overlay.png"
4
7
8
+ local groups_base = {
9
+ cracky = 3 ,
10
+ oddly_breakable_by_hand = 3 ,
11
+ technic_machine = 1 ,
12
+ technic_hv = 1
13
+ }
14
+
15
+ local groups_rail = table .copy (groups_base )
16
+ if has_pipeworks then
17
+ groups_rail .tubedevice = 1
18
+ groups_rail .tubedevice_receiver = 1
19
+ end
20
+
5
21
local register_spacecannon = function (def )
6
22
7
23
local entity_texture = " energycube_" .. def .color .. " .png"
@@ -112,11 +128,10 @@ local register_spacecannon = function(def)
112
128
textures = def .textures
113
129
end
114
130
115
- minetest . register_node ( " spacecannon:cannon_ " .. def . color , {
131
+ local def_cannon = {
116
132
description = def .name .. " (" .. def .desc .. " )" ,
117
133
tiles = textures ,
118
-
119
- groups = {cracky = 3 ,oddly_breakable_by_hand = 3 ,technic_machine = 1 , technic_hv = 1 },
134
+ groups = def .is_th and groups_base or groups_rail ,
120
135
drop = " spacecannon:cannon_" .. def .color ,
121
136
sounds = default .node_sound_glass_defaults (),
122
137
paramtype2 = " facedir" ,
@@ -147,6 +162,9 @@ local register_spacecannon = function(def)
147
162
after_place_node = function (pos , placer )
148
163
local meta = minetest .get_meta (pos )
149
164
meta :set_string (" owner" , placer :get_player_name () or " " )
165
+ if has_pipeworks then
166
+ pipeworks .after_place (pos )
167
+ end
150
168
end ,
151
169
152
170
on_construct = function (pos )
@@ -219,8 +237,35 @@ local register_spacecannon = function(def)
219
237
if meta .inventory and meta .inventory .src and meta .inventory .src [1 ] then
220
238
minetest .add_item (pos , ItemStack (meta .inventory .src [1 ]))
221
239
end
240
+ if has_pipeworks then
241
+ pipeworks .after_dig (pos )
242
+ end
222
243
end
223
- })
244
+ }
245
+
246
+ if has_pipeworks and not def .is_th then
247
+ def_cannon .tube = {
248
+ insert_object = function (pos , _ , stack )
249
+ local meta = minetest .get_meta (pos )
250
+ local inv = meta :get_inventory ()
251
+ return inv :add_item (" src" , stack )
252
+ end ,
253
+ can_insert = function (pos , _ , stack )
254
+ local meta = minetest .get_meta (pos )
255
+ local inv = meta :get_inventory ()
256
+ stack = stack :peek_item (1 )
257
+
258
+ return inv :room_for_item (" src" , stack )
259
+ end ,
260
+ input_inventory = " src" ,
261
+ connect_sides = {
262
+ left = 1 , back = 1 , top = 1 ,
263
+ right = 1 , front = 1 , bottom = nil
264
+ }
265
+ }
266
+ end
267
+
268
+ minetest .register_node (" spacecannon:cannon_" .. def .color , def_cannon )
224
269
225
270
technic .register_machine (" HV" , " spacecannon:cannon_" .. def .color , technic .receiver )
226
271
@@ -233,8 +278,6 @@ local register_spacecannon = function(def)
233
278
}
234
279
})
235
280
236
-
237
-
238
281
end
239
282
240
283
register_spacecannon ({
0 commit comments