3 local rotate_torch_rules
= function (rules
, param2
)
6 elseif param2
== 5 then
7 return mesecon
.rotate_rules_right(rules
)
8 elseif param2
== 2 then
9 return mesecon
.rotate_rules_right(mesecon
.rotate_rules_right(rules
)) --180 degrees
10 elseif param2
== 4 then
11 return mesecon
.rotate_rules_left(rules
)
12 elseif param2
== 0 then
19 local torch_get_output_rules
= function(node
)
20 if node
.param2
== 1 then
22 { x
= -1, y
= 0, z
= 0 },
23 { x
= 1, y
= 0, z
= 0 },
24 { x
= 0, y
= 1, z
= 0, spread
= true },
25 { x
= 0, y
= 0, z
= -1 },
26 { x
= 0, y
= 0, z
= 1 },
29 return rotate_torch_rules({
30 { x
= 1, y
= 0, z
= 0 },
31 { x
= 0, y
= -1, z
= 0 },
32 { x
= 0, y
= 1, z
= 0, spread
= true },
33 { x
= 0, y
= 1, z
= 0 },
34 { x
= 0, y
= 0, z
= -1 },
35 { x
= 0, y
= 0, z
= 1 },
40 local torch_get_input_rules
= function(node
)
41 if node
.param2
== 1 then
42 return {{x
= 0, y
= -1, z
= 0 }}
44 return rotate_torch_rules({{ x
= -1, y
= 0, z
= 0 }}, node
.param2
)
48 local torch_inversion
= function(pos
, node
)
49 if node
.name
== "mesecons_torch:mesecon_torch_on" then
50 minetest
.set_node(pos
, {name
="mesecons_torch:mesecon_torch_off", param2
=node
.param2
})
51 mesecon
.receptor_off(pos
, torch_get_output_rules(node
))
52 elseif node
.name
== "mesecons_torch:mesecon_torch_on_wall" then
53 minetest
.set_node(pos
, {name
="mesecons_torch:mesecon_torch_off_wall", param2
=node
.param2
})
54 mesecon
.receptor_off(pos
, torch_get_output_rules(node
))
55 elseif node
.name
== "mesecons_torch:mesecon_torch_off" then
56 minetest
.set_node(pos
, {name
="mesecons_torch:mesecon_torch_on", param2
=node
.param2
})
57 mesecon
.receptor_on(pos
, torch_get_output_rules(node
))
58 elseif node
.name
== "mesecons_torch:mesecon_torch_off_wall" then
59 minetest
.set_node(pos
, {name
="mesecons_torch:mesecon_torch_on_wall", param2
=node
.param2
})
60 mesecon
.receptor_on(pos
, torch_get_output_rules(node
))
64 minetest
.register_craft({
65 output
= 'mesecons_torch:mesecon_torch_on',
67 {"mesecons:redstone"},
71 mcl_torches
.register_torch("mesecon_torch_off", "Redstone Torch (off)",
74 "jeija_torches_off.png",
75 "mcl_torches_torch_floor.obj", "mcl_torches_torch_wall.obj",
76 {"jeija_torches_off.png"},
78 {dig_immediate
=3, dig_by_water
=1, not_in_creative_inventory
=1},
79 mcl_sounds
.node_sound_wood_defaults(),
83 state
= mesecon
.state
.off
,
84 rules
= torch_get_output_rules
,
87 state
= mesecon
.state
.on
,
88 rules
= torch_get_input_rules
,
89 action_off
= torch_inversion
,
92 drop
= "mesecons_torch:mesecon_torch_on",
93 _doc_items_create_entry
= false,
97 mcl_torches
.register_torch("mesecon_torch_on", "Redstone Torch",
98 "Redstone torches are redstone components which invert the signal of surrounding redstone components. An active component will become inactive, and an inactive component will become active. Redstone torches can be used as a quick and easy way to send a redstone to a redstone trail.",
99 [[Redstone torches can generally be placed at the side and on the top of full solid opaque blocks. The following exceptions apply:
100 • Glass, fence, wall, hopper: Can only be placed on top
101 • Upside-down slab/stair: Can only be placed on top
102 • Soul sand, mob spawner: Placement possible
103 • Glowstone and pistons: No placement possible]],
104 "jeija_torches_on.png",
105 "mcl_torches_torch_floor.obj", "mcl_torches_torch_wall.obj",
106 {"jeija_torches_on.png"},
108 {dig_immediate
=3, dig_by_water
=1,},
109 mcl_sounds
.node_sound_wood_defaults(),
113 state
= mesecon
.state
.on
,
114 rules
= torch_get_output_rules
117 state
= mesecon
.state
.off
,
118 rules
= torch_get_input_rules
,
119 action_on
= torch_inversion
,
125 minetest
.register_node("mesecons_torch:redstoneblock", {
126 description
= "Block of Redstone",
127 _doc_items_longdesc
= "A block of redstone permanently supplies redstone power to its surrounding blocks.",
128 tiles
= {"redstone_redstone_block.png"},
130 groups
= {pickaxey
=1},
131 sounds
= mcl_sounds
.node_sound_stone_defaults(),
132 is_ground_content
= false,
133 mesecons
= {receptor
= {
134 state
= mesecon
.state
.on
,
135 rules
= mesecon
.rules
.alldirs
,
137 _mcl_blast_resistance
= 30,
141 minetest
.register_craft({
142 output
= "mesecons_torch:redstoneblock",
144 {'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'},
145 {'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'},
146 {'mesecons:wire_00000000_off','mesecons:wire_00000000_off','mesecons:wire_00000000_off'},
150 minetest
.register_craft({
151 output
= 'mesecons:wire_00000000_off 9',
153 {'mesecons_torch:redstoneblock'},
157 if minetest
.get_modpath("doc") then
158 doc
.add_entry_alias("nodes", "mesecons_torch:mesecon_torch_on", "nodes", "mesecons_torch:mesecon_torch_off")
159 doc
.add_entry_alias("nodes", "mesecons_torch:mesecon_torch_on", "nodes", "mesecons_torch:mesecon_torch_off_wall")