1 local PISTON_MAXIMUM_PUSH
= 12
3 -- Get mesecon rules of pistons
5 {{x
=0, y
=0, z
=1}, --everything apart from z- (pusher side)
11 local piston_up_rules
=
12 {{x
=0, y
=0, z
=-1}, --everything apart from y+ (pusher side)
18 local piston_down_rules
=
19 {{x
=0, y
=0, z
=-1}, --everything apart from y- (pusher side)
25 local piston_get_rules
= function (node
)
26 local rules
= piston_rules
27 for i
= 1, node
.param2
do
28 rules
= mesecon
.rotate_rules_left(rules
)
33 local piston_facedir_direction
= function (node
)
34 local rules
= {{x
= 0, y
= 0, z
= -1}}
35 for i
= 1, node
.param2
do
36 rules
= mesecon
.rotate_rules_left(rules
)
41 local piston_get_direction
= function (dir
, node
)
42 if type(dir
) == "function" then
49 -- Remove pusher of piston.
50 -- To be used when piston was destroyed or dug.
51 local piston_remove_pusher
= function (pos
, oldnode
)
52 local pistonspec
= minetest
.registered_nodes
[oldnode
.name
].mesecons_piston
54 local dir
= piston_get_direction(pistonspec
.dir
, oldnode
)
55 local pusherpos
= vector
.add(pos
, dir
)
56 local pushername
= minetest
.get_node(pusherpos
).name
58 if pushername
== pistonspec
.pusher
then -- make sure there actually is a pusher
59 minetest
.remove_node(pusherpos
)
60 core
.check_for_falling(pusherpos
)
61 minetest
.sound_play("piston_retract", {
63 max_hear_distance
= 31,
69 -- Remove base node of piston.
70 -- To be used when pusher was destroyed.
71 local piston_remove_base
= function (pos
, oldnode
)
72 local basenodename
= minetest
.registered_nodes
[oldnode
.name
].corresponding_piston
73 local pistonspec
= minetest
.registered_nodes
[basenodename
].mesecons_piston
75 local dir
= piston_get_direction(pistonspec
.dir
, oldnode
)
76 local basepos
= vector
.subtract(pos
, dir
)
77 local basename
= minetest
.get_node(basepos
).name
79 if basename
== pistonspec
.onname
then -- make sure there actually is a base node
80 minetest
.remove_node(basepos
)
81 core
.check_for_falling(basepos
)
82 minetest
.sound_play("piston_retract", {
84 max_hear_distance
= 31,
90 local piston_on
= function (pos
, node
)
91 local pistonspec
= minetest
.registered_nodes
[node
.name
].mesecons_piston
93 local dir
= piston_get_direction(pistonspec
.dir
, node
)
94 local np
= vector
.add(pos
, dir
)
95 local success
, stack
, oldstack
= mesecon
.mvps_push(np
, dir
, PISTON_MAXIMUM_PUSH
)
97 minetest
.add_node(pos
, {param2
= node
.param2
, name
= pistonspec
.onname
})
98 minetest
.add_node(np
, {param2
= node
.param2
, name
= pistonspec
.pusher
})
99 local below
= minetest
.get_node({x
=np
.x
,y
=np
.y
-1,z
=np
.z
})
100 if below
.name
== "mcl_farming:soil" or below
.name
== "mcl_farming:soil_wet" then
101 minetest
.set_node({x
=np
.x
,y
=np
.y
-1,z
=np
.z
}, {name
= "mcl_core:dirt"})
103 mesecon
.mvps_process_stack(stack
)
104 mesecon
.mvps_move_objects(np
, dir
, oldstack
)
105 minetest
.sound_play("piston_extend", {
107 max_hear_distance
= 31,
113 local piston_off
= function (pos
, node
)
114 local pistonspec
= minetest
.registered_nodes
[node
.name
].mesecons_piston
115 minetest
.add_node(pos
, {param2
= node
.param2
, name
= pistonspec
.offname
})
116 piston_remove_pusher (pos
, node
)
118 if pistonspec
.sticky
then
119 local dir
= piston_get_direction(pistonspec
.dir
, node
)
120 local pullpos
= vector
.add(pos
, vector
.multiply(dir
, 2))
121 local stack
= mesecon
.mvps_pull_single(pullpos
, vector
.multiply(dir
, -1), PISTON_MAXIMUM_PUSH
)
122 mesecon
.mvps_process_stack(pos
, dir
, stack
)
126 local piston_orientate
= function (pos
, placer
)
127 -- not placed by player
128 if not placer
then return end
130 -- placer pitch in degrees
131 local pitch
= placer
:get_look_vertical() * (180 / math
.pi
)
133 local node
= minetest
.get_node(pos
)
134 local pistonspec
= minetest
.registered_nodes
[node
.name
].mesecons_piston
136 minetest
.add_node(pos
, {name
=pistonspec
.piston_up
})
137 elseif pitch
< -55 then
138 minetest
.add_node(pos
, {name
=pistonspec
.piston_down
})
143 -- Horizontal pistons
145 local pt
= 4/16 -- pusher thickness
147 local piston_pusher_box
= {
150 {-2/16, -2/16, -.5 + pt
, 2/16, 2/16, .5 + pt
},
151 {-.5 , -.5 , -.5 , .5 , .5 , -.5 + pt
},
155 local piston_on_box
= {
158 {-.5, -.5, -.5 + pt
, .5, .5, .5}
163 -- Normal (non-sticky) ones:
165 local pistonspec_normal
= {
166 offname
= "mesecons_pistons:piston_normal_off",
167 onname
= "mesecons_pistons:piston_normal_on",
168 dir
= piston_facedir_direction
,
169 pusher
= "mesecons_pistons:piston_pusher_normal",
170 piston_down
= "mesecons_pistons:piston_down_normal_off",
171 piston_up
= "mesecons_pistons:piston_up_normal_off",
174 local usagehelp_piston
= "This block can have one of 6 possible orientations. On placement, the pusher will face you."
177 if minetest
.get_modpath("screwdriver") then
178 on_rotate
= screwdriver
.disallow
182 minetest
.register_node("mesecons_pistons:piston_normal_off", {
183 description
= "Piston",
184 _doc_items_longdesc
= "A piston is a redstone component with a pusher which pushes the block or blocks in front of it when it is supplied with redstone power. Not all blocks can be pushed, however.",
185 _doc_items_usagehelp
= usagehelp_piston
,
187 "mesecons_piston_bottom.png^[transformR180",
188 "mesecons_piston_bottom.png",
189 "mesecons_piston_bottom.png^[transformR90",
190 "mesecons_piston_bottom.png^[transformR270",
191 "mesecons_piston_back.png",
192 "mesecons_piston_pusher_front.png"
194 groups
= {handy
= 1},
196 paramtype2
= "facedir",
197 is_ground_content
= false,
198 after_place_node
= piston_orientate
,
199 mesecons_piston
= pistonspec_normal
,
200 sounds
= mcl_sounds
.node_sound_stone_defaults(),
201 mesecons
= {effector
={
202 action_on
= piston_on
,
203 rules
= piston_get_rules
205 _mcl_blast_resistance
= 2.5,
207 on_rotate
= on_rotate
,
211 minetest
.register_node("mesecons_pistons:piston_normal_on", {
212 drawtype
= "nodebox",
214 "mesecons_piston_bottom.png^[transformR180",
215 "mesecons_piston_bottom.png",
216 "mesecons_piston_bottom.png^[transformR90",
217 "mesecons_piston_bottom.png^[transformR270",
218 "mesecons_piston_back.png",
219 "mesecons_piston_on_front.png"
221 groups
= {handy
=1, not_in_creative_inventory
= 1},
223 paramtype2
= "facedir",
224 is_ground_content
= false,
225 drop
= "mesecons_pistons:piston_normal_off",
226 after_destruct
= piston_remove_pusher
,
227 node_box
= piston_on_box
,
228 selection_box
= piston_on_box
,
229 mesecons_piston
= pistonspec_normal
,
230 sounds
= mcl_sounds
.node_sound_stone_defaults(),
231 mesecons
= {effector
={
232 action_off
= piston_off
,
233 rules
= piston_get_rules
235 _mcl_blast_resistance
= 2.5,
237 on_rotate
= on_rotate
,
241 minetest
.register_node("mesecons_pistons:piston_pusher_normal", {
242 drawtype
= "nodebox",
244 "mesecons_piston_pusher_top.png",
245 "mesecons_piston_pusher_bottom.png",
246 "mesecons_piston_pusher_left.png",
247 "mesecons_piston_pusher_right.png",
248 "mesecons_piston_pusher_back.png",
249 "mesecons_piston_pusher_front.png"
252 paramtype2
= "facedir",
253 is_ground_content
= false,
254 after_destruct
= piston_remove_base
,
256 corresponding_piston
= "mesecons_pistons:piston_normal_on",
257 selection_box
= piston_pusher_box
,
258 node_box
= piston_pusher_box
,
259 sounds
= mcl_sounds
.node_sound_wood_defaults(),
260 _mcl_blast_resistance
= 2.5,
261 on_rotate
= on_rotate
,
266 local pistonspec_sticky
= {
267 offname
= "mesecons_pistons:piston_sticky_off",
268 onname
= "mesecons_pistons:piston_sticky_on",
269 dir
= piston_facedir_direction
,
270 pusher
= "mesecons_pistons:piston_pusher_sticky",
272 piston_down
= "mesecons_pistons:piston_down_sticky_off",
273 piston_up
= "mesecons_pistons:piston_up_sticky_off",
277 minetest
.register_node("mesecons_pistons:piston_sticky_off", {
278 description
= "Sticky Piston",
279 _doc_items_longdesc
= "A sticky piston is a redstone component with a sticky pusher which can be extended and retracted. It extends when it is supplied with redstone power. When the pusher extends, it pushes the block or blocks in front of it. When it retracts, it pulls back the single block in front of it. Note that not all blocks can be pushed or pulled.",
280 _doc_items_usagehelp
= usagehelp_piston
,
283 "mesecons_piston_bottom.png^[transformR180",
284 "mesecons_piston_bottom.png",
285 "mesecons_piston_bottom.png^[transformR90",
286 "mesecons_piston_bottom.png^[transformR270",
287 "mesecons_piston_back.png",
288 "mesecons_piston_pusher_front_sticky.png"
292 paramtype2
= "facedir",
293 is_ground_content
= false,
294 after_place_node
= piston_orientate
,
295 mesecons_piston
= pistonspec_sticky
,
296 sounds
= mcl_sounds
.node_sound_stone_defaults(),
297 mesecons
= {effector
={
298 action_on
= piston_on
,
299 rules
= piston_get_rules
301 _mcl_blast_resistance
= 2.5,
303 on_rotate
= on_rotate
,
307 minetest
.register_node("mesecons_pistons:piston_sticky_on", {
308 drawtype
= "nodebox",
310 "mesecons_piston_bottom.png^[transformR180",
311 "mesecons_piston_bottom.png",
312 "mesecons_piston_bottom.png^[transformR90",
313 "mesecons_piston_bottom.png^[transformR270",
314 "mesecons_piston_back.png",
315 "mesecons_piston_on_front.png"
317 groups
= {handy
=1, not_in_creative_inventory
= 1},
319 paramtype2
= "facedir",
320 is_ground_content
= false,
321 drop
= "mesecons_pistons:piston_sticky_off",
322 after_destruct
= piston_remove_pusher
,
323 node_box
= piston_on_box
,
324 selection_box
= piston_on_box
,
325 mesecons_piston
= pistonspec_sticky
,
326 sounds
= mcl_sounds
.node_sound_stone_defaults(),
327 mesecons
= {effector
={
328 action_off
= piston_off
,
329 rules
= piston_get_rules
331 _mcl_blast_resistance
= 2.5,
333 on_rotate
= on_rotate
,
337 minetest
.register_node("mesecons_pistons:piston_pusher_sticky", {
338 drawtype
= "nodebox",
340 "mesecons_piston_pusher_top.png",
341 "mesecons_piston_pusher_bottom.png",
342 "mesecons_piston_pusher_left.png",
343 "mesecons_piston_pusher_right.png",
344 "mesecons_piston_pusher_back.png",
345 "mesecons_piston_pusher_front_sticky.png"
348 paramtype2
= "facedir",
349 is_ground_content
= false,
350 after_destruct
= piston_remove_base
,
352 corresponding_piston
= "mesecons_pistons:piston_sticky_on",
353 selection_box
= piston_pusher_box
,
354 node_box
= piston_pusher_box
,
355 sounds
= mcl_sounds
.node_sound_wood_defaults(),
356 _mcl_blast_resistance
= 2.5,
357 on_rotate
= on_rotate
,
366 local piston_up_pusher_box
= {
369 {-2/16, -.5 - pt
, -2/16, 2/16, .5 - pt
, 2/16},
370 {-.5 , .5 - pt
, -.5 , .5 , .5 , .5},
374 local piston_up_on_box
= {
377 {-.5, -.5, -.5 , .5, .5-pt
, .5}
383 local pistonspec_normal_up
= {
384 offname
= "mesecons_pistons:piston_up_normal_off",
385 onname
= "mesecons_pistons:piston_up_normal_on",
386 dir
= {x
= 0, y
= 1, z
= 0},
387 pusher
= "mesecons_pistons:piston_up_pusher_normal"
391 minetest
.register_node("mesecons_pistons:piston_up_normal_off", {
393 "mesecons_piston_pusher_front.png",
394 "mesecons_piston_back.png",
395 "mesecons_piston_bottom.png",
396 "mesecons_piston_bottom.png",
397 "mesecons_piston_bottom.png",
398 "mesecons_piston_bottom.png",
400 groups
= {handy
=1, not_in_creative_inventory
= 1},
402 paramtype2
= "facedir",
403 is_ground_content
= false,
404 drop
= "mesecons_pistons:piston_normal_off",
405 mesecons_piston
= pistonspec_normal_up
,
406 mesecons
= {effector
={
407 action_on
= piston_on
,
408 rules
= piston_up_rules
,
410 sounds
= mcl_sounds
.node_sound_stone_defaults({
411 footstep
= mcl_sounds
.node_sound_wood_defaults().footstep
413 _mcl_blast_resistance
= 2.5,
415 on_rotate
= on_rotate
,
419 minetest
.register_node("mesecons_pistons:piston_up_normal_on", {
420 drawtype
= "nodebox",
422 "mesecons_piston_on_front.png",
423 "mesecons_piston_back.png",
424 "mesecons_piston_bottom.png",
425 "mesecons_piston_bottom.png",
426 "mesecons_piston_bottom.png",
427 "mesecons_piston_bottom.png",
429 groups
= {hanry
=1, not_in_creative_inventory
= 1},
431 paramtype2
= "facedir",
432 is_ground_content
= false,
433 drop
= "mesecons_pistons:piston_normal_off",
434 after_destruct
= piston_remove_pusher
,
435 node_box
= piston_up_on_box
,
436 selection_box
= piston_up_on_box
,
437 mesecons_piston
= pistonspec_normal_up
,
438 sounds
= mcl_sounds
.node_sound_stone_defaults(),
439 mesecons
= {effector
={
440 action_off
= piston_off
,
441 rules
= piston_up_rules
,
443 _mcl_blast_resistance
= 2.5,
445 on_rotate
= on_rotate
,
449 minetest
.register_node("mesecons_pistons:piston_up_pusher_normal", {
450 drawtype
= "nodebox",
452 "mesecons_piston_pusher_front.png",
453 "mesecons_piston_pusher_back.png",
454 "mesecons_piston_pusher_left.png^[transformR270",
455 "mesecons_piston_pusher_right.png^[transformR90",
456 "mesecons_piston_pusher_bottom.png",
457 "mesecons_piston_pusher_top.png^[transformR180",
460 paramtype2
= "facedir",
461 is_ground_content
= false,
462 after_destruct
= piston_remove_base
,
464 corresponding_piston
= "mesecons_pistons:piston_up_normal_on",
465 selection_box
= piston_up_pusher_box
,
466 node_box
= piston_up_pusher_box
,
467 sounds
= mcl_sounds
.node_sound_wood_defaults(),
468 _mcl_blast_resistance
= 2.5,
469 on_rotate
= on_rotate
,
477 local pistonspec_sticky_up
= {
478 offname
= "mesecons_pistons:piston_up_sticky_off",
479 onname
= "mesecons_pistons:piston_up_sticky_on",
480 dir
= {x
= 0, y
= 1, z
= 0},
481 pusher
= "mesecons_pistons:piston_up_pusher_sticky",
486 minetest
.register_node("mesecons_pistons:piston_up_sticky_off", {
488 "mesecons_piston_pusher_front_sticky.png",
489 "mesecons_piston_back.png",
490 "mesecons_piston_bottom.png",
491 "mesecons_piston_bottom.png",
492 "mesecons_piston_bottom.png",
493 "mesecons_piston_bottom.png",
495 groups
= {handy
=1, not_in_creative_inventory
= 1},
497 paramtype2
= "facedir",
498 is_ground_content
= false,
499 drop
= "mesecons_pistons:piston_sticky_off",
500 mesecons_piston
= pistonspec_sticky_up
,
501 sounds
= mcl_sounds
.node_sound_stone_defaults({
502 footstep
= mcl_sounds
.node_sound_wood_defaults().footstep
504 mesecons
= {effector
={
505 action_on
= piston_on
,
506 rules
= piston_up_rules
,
508 _mcl_blast_resistance
= 2.5,
510 on_rotate
= on_rotate
,
514 minetest
.register_node("mesecons_pistons:piston_up_sticky_on", {
515 drawtype
= "nodebox",
517 "mesecons_piston_on_front.png",
518 "mesecons_piston_back.png",
519 "mesecons_piston_bottom.png",
520 "mesecons_piston_bottom.png",
521 "mesecons_piston_bottom.png",
522 "mesecons_piston_bottom.png",
524 groups
= {handy
=1, not_in_creative_inventory
= 1},
526 paramtype2
= "facedir",
527 is_ground_content
= false,
528 drop
= "mesecons_pistons:piston_sticky_off",
529 after_destruct
= piston_remove_pusher
,
530 node_box
= piston_up_on_box
,
531 selection_box
= piston_up_on_box
,
532 mesecons_piston
= pistonspec_sticky_up
,
533 sounds
= mcl_sounds
.node_sound_stone_defaults(),
534 mesecons
= {effector
={
535 action_off
= piston_off
,
536 rules
= piston_up_rules
,
538 _mcl_blast_resistance
= 2.5,
540 on_rotate
= on_rotate
,
544 minetest
.register_node("mesecons_pistons:piston_up_pusher_sticky", {
545 drawtype
= "nodebox",
547 "mesecons_piston_pusher_front_sticky.png",
548 "mesecons_piston_pusher_back.png",
549 "mesecons_piston_pusher_left.png^[transformR270",
550 "mesecons_piston_pusher_right.png^[transformR90",
551 "mesecons_piston_pusher_bottom.png",
552 "mesecons_piston_pusher_top.png^[transformR180",
555 paramtype2
= "facedir",
556 is_ground_content
= false,
557 after_destruct
= piston_remove_base
,
559 corresponding_piston
= "mesecons_pistons:piston_up_sticky_on",
560 selection_box
= piston_up_pusher_box
,
561 node_box
= piston_up_pusher_box
,
562 sounds
= mcl_sounds
.node_sound_wood_defaults(),
563 _mcl_blast_resistance
= 2.5,
564 on_rotate
= on_rotate
,
573 local piston_down_pusher_box
= {
576 {-2/16, -.5 + pt
, -2/16, 2/16, .5 + pt
, 2/16},
577 {-.5 , -.5 , -.5 , .5 , -.5 + pt
, .5},
581 local piston_down_on_box
= {
584 {-.5, -.5+pt
, -.5 , .5, .5, .5}
592 local pistonspec_normal_down
= {
593 offname
= "mesecons_pistons:piston_down_normal_off",
594 onname
= "mesecons_pistons:piston_down_normal_on",
595 dir
= {x
= 0, y
= -1, z
= 0},
596 pusher
= "mesecons_pistons:piston_down_pusher_normal",
600 minetest
.register_node("mesecons_pistons:piston_down_normal_off", {
602 "mesecons_piston_back.png",
603 "mesecons_piston_pusher_front.png",
604 "mesecons_piston_bottom.png^[transformR180",
605 "mesecons_piston_bottom.png^[transformR180",
606 "mesecons_piston_bottom.png^[transformR180",
607 "mesecons_piston_bottom.png^[transformR180",
609 groups
= {handy
=1, not_in_creative_inventory
= 1},
611 paramtype2
= "facedir",
612 is_ground_content
= false,
613 drop
= "mesecons_pistons:piston_normal_off",
614 mesecons_piston
= pistonspec_normal_down
,
615 sounds
= mcl_sounds
.node_sound_stone_defaults(),
616 mesecons
= {effector
={
617 action_on
= piston_on
,
618 rules
= piston_down_rules
,
620 _mcl_blast_resistance
= 2.5,
622 on_rotate
= on_rotate
,
626 minetest
.register_node("mesecons_pistons:piston_down_normal_on", {
627 drawtype
= "nodebox",
629 "mesecons_piston_back.png",
630 "mesecons_piston_on_front.png",
631 "mesecons_piston_bottom.png^[transformR180",
632 "mesecons_piston_bottom.png^[transformR180",
633 "mesecons_piston_bottom.png^[transformR180",
634 "mesecons_piston_bottom.png^[transformR180",
636 groups
= {handy
=1, not_in_creative_inventory
= 1},
638 paramtype2
= "facedir",
639 is_ground_content
= false,
640 drop
= "mesecons_pistons:piston_normal_off",
641 after_destruct
= piston_remove_pusher
,
642 node_box
= piston_down_on_box
,
643 selection_box
= piston_down_on_box
,
644 mesecons_piston
= pistonspec_normal_down
,
645 sounds
= mcl_sounds
.node_sound_stone_defaults(),
646 mesecons
= {effector
={
647 action_off
= piston_off
,
648 rules
= piston_down_rules
,
650 _mcl_blast_resistance
= 2.5,
652 on_rotate
= on_rotate
,
656 minetest
.register_node("mesecons_pistons:piston_down_pusher_normal", {
657 drawtype
= "nodebox",
659 "mesecons_piston_pusher_back.png",
660 "mesecons_piston_pusher_front.png",
661 "mesecons_piston_pusher_left.png^[transformR90",
662 "mesecons_piston_pusher_right.png^[transformR270",
663 "mesecons_piston_pusher_bottom.png^[transformR180",
664 "mesecons_piston_pusher_top.png",
667 paramtype2
= "facedir",
668 is_ground_content
= false,
669 after_destruct
= piston_remove_base
,
671 corresponding_piston
= "mesecons_pistons:piston_down_normal_on",
672 selection_box
= piston_down_pusher_box
,
673 node_box
= piston_down_pusher_box
,
674 sounds
= mcl_sounds
.node_sound_wood_defaults(),
675 _mcl_blast_resistance
= 2.5,
676 on_rotate
= on_rotate
,
681 local pistonspec_sticky_down
= {
682 onname
= "mesecons_pistons:piston_down_sticky_on",
683 offname
= "mesecons_pistons:piston_down_sticky_off",
684 dir
= {x
= 0, y
= -1, z
= 0},
685 pusher
= "mesecons_pistons:piston_down_pusher_sticky",
690 minetest
.register_node("mesecons_pistons:piston_down_sticky_off", {
692 "mesecons_piston_back.png",
693 "mesecons_piston_pusher_front_sticky.png",
694 "mesecons_piston_bottom.png^[transformR180",
695 "mesecons_piston_bottom.png^[transformR180",
696 "mesecons_piston_bottom.png^[transformR180",
697 "mesecons_piston_bottom.png^[transformR180",
699 groups
= {handy
=1, not_in_creative_inventory
= 1},
701 paramtype2
= "facedir",
702 is_ground_content
= false,
703 drop
= "mesecons_pistons:piston_sticky_off",
704 mesecons_piston
= pistonspec_sticky_down
,
705 sounds
= mcl_sounds
.node_sound_stone_defaults(),
706 mesecons
= {effector
={
707 action_on
= piston_on
,
708 rules
= piston_down_rules
,
710 _mcl_blast_resistance
= 2.5,
712 on_rotate
= on_rotate
,
716 minetest
.register_node("mesecons_pistons:piston_down_sticky_on", {
717 drawtype
= "nodebox",
719 "mesecons_piston_back.png",
720 "mesecons_piston_on_front.png",
721 "mesecons_piston_bottom.png^[transformR180",
722 "mesecons_piston_bottom.png^[transformR180",
723 "mesecons_piston_bottom.png^[transformR180",
724 "mesecons_piston_bottom.png^[transformR180",
726 groups
= {handy
=1, not_in_creative_inventory
= 1},
728 paramtype2
= "facedir",
729 is_ground_content
= false,
730 drop
= "mesecons_pistons:piston_sticky_off",
731 after_destruct
= piston_remove_pusher
,
732 node_box
= piston_down_on_box
,
733 selection_box
= piston_down_on_box
,
734 mesecons_piston
= pistonspec_sticky_down
,
735 sounds
= mcl_sounds
.node_sound_stone_defaults(),
736 mesecons
= {effector
={
737 action_off
= piston_off
,
738 rules
= piston_down_rules
,
740 _mcl_blast_resistance
= 2.5,
742 on_rotate
= on_rotate
,
746 minetest
.register_node("mesecons_pistons:piston_down_pusher_sticky", {
747 drawtype
= "nodebox",
749 "mesecons_piston_pusher_back.png",
750 "mesecons_piston_pusher_front_sticky.png",
751 "mesecons_piston_pusher_left.png^[transformR90",
752 "mesecons_piston_pusher_right.png^[transformR270",
753 "mesecons_piston_pusher_bottom.png^[transformR180",
754 "mesecons_piston_pusher_top.png",
757 paramtype2
= "facedir",
758 is_ground_content
= false,
759 after_destruct
= piston_remove_base
,
761 corresponding_piston
= "mesecons_pistons:piston_down_sticky_on",
762 selection_box
= piston_down_pusher_box
,
763 node_box
= piston_down_pusher_box
,
764 sounds
= mcl_sounds
.node_sound_wood_defaults(),
765 _mcl_blast_resistance
= 2.5,
766 on_rotate
= on_rotate
,
770 -- Register pushers as stoppers if they would be seperated from the piston
771 local piston_pusher_get_stopper
= function (node
, dir
, stack
, stackid
)
772 if (stack
[stackid
+ 1]
773 and stack
[stackid
+ 1].node
.name
== minetest
.registered_nodes
[node
.name
].corresponding_piston
774 and stack
[stackid
+ 1].node
.param2
== node
.param2
)
775 or (stack
[stackid
- 1]
776 and stack
[stackid
- 1].node
.name
== minetest
.registered_nodes
[node
.name
].corresponding_piston
777 and stack
[stackid
- 1].node
.param2
== node
.param2
) then
783 local piston_pusher_up_down_get_stopper
= function (node
, dir
, stack
, stackid
)
784 if (stack
[stackid
+ 1]
785 and stack
[stackid
+ 1].node
.name
== minetest
.registered_nodes
[node
.name
].corresponding_piston
)
786 or (stack
[stackid
- 1]
787 and stack
[stackid
- 1].node
.name
== minetest
.registered_nodes
[node
.name
].corresponding_piston
) then
793 mesecon
.register_mvps_stopper("mesecons_pistons:piston_pusher_normal", piston_pusher_get_stopper
)
794 mesecon
.register_mvps_stopper("mesecons_pistons:piston_pusher_sticky", piston_pusher_get_stopper
)
796 mesecon
.register_mvps_stopper("mesecons_pistons:piston_up_pusher_normal", piston_pusher_up_down_get_stopper
)
797 mesecon
.register_mvps_stopper("mesecons_pistons:piston_up_pusher_sticky", piston_pusher_up_down_get_stopper
)
799 mesecon
.register_mvps_stopper("mesecons_pistons:piston_down_pusher_normal", piston_pusher_up_down_get_stopper
)
800 mesecon
.register_mvps_stopper("mesecons_pistons:piston_down_pusher_sticky", piston_pusher_up_down_get_stopper
)
803 -- Register pistons as stoppers if they would be seperated from the stopper
804 local piston_up_down_get_stopper
= function (node
, dir
, stack
, stackid
)
805 if (stack
[stackid
+ 1]
806 and stack
[stackid
+ 1].node
.name
== minetest
.registered_nodes
[node
.name
].mesecons_piston
.pusher
)
807 or (stack
[stackid
- 1]
808 and stack
[stackid
- 1].node
.name
== minetest
.registered_nodes
[node
.name
].mesecons_piston
.pusher
) then
814 local piston_get_stopper
= function (node
, dir
, stack
, stackid
)
815 local pistonspec
= minetest
.registered_nodes
[node
.name
].mesecons_piston
816 dir
= piston_get_direction(pistonspec
.dir
, node
)
817 local pusherpos
= vector
.add(stack
[stackid
].pos
, dir
)
818 local pushernode
= minetest
.get_node(pusherpos
)
820 if minetest
.registered_nodes
[node
.name
].mesecons_piston
.pusher
== pushernode
.name
then
821 for _
, s
in ipairs(stack
) do
822 if vector
.equals(s
.pos
, pusherpos
) -- pusher is also to be pushed
823 and s
.node
.param2
== node
.param2
then
831 mesecon
.register_mvps_stopper("mesecons_pistons:piston_normal_on", piston_get_stopper
)
832 mesecon
.register_mvps_stopper("mesecons_pistons:piston_sticky_on", piston_get_stopper
)
834 mesecon
.register_mvps_stopper("mesecons_pistons:piston_up_normal_on", piston_up_down_get_stopper
)
835 mesecon
.register_mvps_stopper("mesecons_pistons:piston_up_sticky_on", piston_up_down_get_stopper
)
837 mesecon
.register_mvps_stopper("mesecons_pistons:piston_down_normal_on", piston_up_down_get_stopper
)
838 mesecon
.register_mvps_stopper("mesecons_pistons:piston_down_sticky_on", piston_up_down_get_stopper
)
841 minetest
.register_craft({
842 output
= 'mesecons_pistons:piston_normal_off',
844 {"group:wood", "group:wood", "group:wood"},
845 {"mcl_core:cobble", "mcl_core:iron_ingot", "mcl_core:cobble"},
846 {"mcl_core:cobble", "mesecons:redstone", "mcl_core:cobble"},
850 minetest
.register_craft({
851 output
= "mesecons_pistons:piston_sticky_off",
853 {"mcl_mobitems:slimeball"},
854 {"mesecons_pistons:piston_normal_off"},
858 -- Add entry aliases for the Help
859 if minetest
.get_modpath("doc") then
860 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_normal_off", "nodes", "mesecons_pistons:piston_normal_on")
861 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_normal_off", "nodes", "mesecons_pistons:piston_up_normal_off")
862 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_normal_off", "nodes", "mesecons_pistons:piston_up_normal_on")
863 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_normal_off", "nodes", "mesecons_pistons:piston_down_normal_off")
864 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_normal_off", "nodes", "mesecons_pistons:piston_down_normal_on")
865 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_normal_off", "nodes", "mesecons_pistons:piston_pusher_normal")
866 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_normal_off", "nodes", "mesecons_pistons:piston_up_pusher_normal")
867 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_normal_off", "nodes", "mesecons_pistons:piston_down_pusher_normal")
869 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_sticky_off", "nodes", "mesecons_pistons:piston_sticky_on")
870 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_sticky_off", "nodes", "mesecons_pistons:piston_up_sticky_off")
871 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_sticky_off", "nodes", "mesecons_pistons:piston_up_sticky_on")
872 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_sticky_off", "nodes", "mesecons_pistons:piston_down_sticky_off")
873 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_sticky_off", "nodes", "mesecons_pistons:piston_down_sticky_on")
874 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_sticky_off", "nodes", "mesecons_pistons:piston_pusher_sticky")
875 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_sticky_off", "nodes", "mesecons_pistons:piston_up_pusher_sticky")
876 doc
.add_entry_alias("nodes", "mesecons_pistons:piston_sticky_off", "nodes", "mesecons_pistons:piston_down_pusher_sticky")