1 --get point where particle spawner is added
2 local function get_offset(wdir)
14 return {x = x, y = 0.27, z = z}
17 --remove smoke and fire
18 local function delete_ps(pos)
19 local meta = minetest.get_meta(pos)
20 minetest.delete_particlespawner(meta:get_int("psf"))
21 minetest.delete_particlespawner(meta:get_int("pss"))
24 --add in smoke and fire
25 local function create_ps(pos)
26 local dir = get_offset(minetest.get_node(pos).param2)
27 local ppos = vector.add(dir,pos)
28 local meta = minetest.get_meta(pos)
29 local psf = minetest.add_particlespawner({
34 minvel = vector.new(0,0,0),
35 maxvel = vector.new(0,0,0),
36 minacc = {x=0, y=0, z=0},
37 maxacc = {x=0, y=0, z=0},
42 collisiondetection = false,
44 texture = "redstone_torch_animated.png",
45 animation = {type = "vertical_frames",
48 -- Width of a frame in pixels
51 -- Height of a frame in pixels
57 local pss = minetest.add_particlespawner({
62 minvel = vector.new(-0.1,0.1,-0.1),
63 maxvel = vector.new(0.1,0.3,0.1),
64 minacc = vector.new(0,0,0),
65 maxacc = vector.new(0,0,0),
70 collisiondetection = false,
72 texture = "smoke.png",
74 meta:set_int("psf", psf)
75 meta:set_int("pss", pss)
78 --reload smoke and flame on load
80 minetest.register_lbm({
81 name = "redstone:torch",
82 nodenames = {"redstone:torch_floor","redstone:torch_wall"},
83 run_at_every_load = true,
84 action = function(pos, node)
90 minetest.register_craftitem("redstone:torch", {
91 description = "Redstone Torch",
92 inventory_image = "redstone_torch.png",
93 wield_image = "redstone_torch.png",
94 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
95 liquids_pointable = false,
97 on_place = function(itemstack, placer, pointed_thing)
98 if pointed_thing.type ~= "node" then
102 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
104 local fakestack = itemstack
108 elseif wdir == 1 then
109 retval = fakestack:set_name("redstone:torch_floor")
111 retval = fakestack:set_name("redstone:torch_wall")
116 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
117 itemstack:set_name("redstone:torch")
120 minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
127 minetest.register_node("redstone:torch_floor", {
128 inventory_image = "redstone_torch.png",
129 wield_image = "redstone_torch.png",
130 wield_scale = {x = 1, y = 1, z = 1 + 2/16},
132 mesh = "torch_floor.obj",
133 tiles = {"redstone_torch.png"},
137 sunlight_propagates = true,
138 drop = "redstone:torch",
141 groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,connect_to_raillike=1},
142 legacy_wallmounted = true,
145 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
148 on_construct = function(pos)
149 redstone.collect_info(pos)
151 after_destruct = function(pos, oldnode)
152 redstone.collect_info(pos)
154 sounds = main.woodSound(),
157 minetest.register_node("redstone:torch_wall", {
158 inventory_image = "redstone_torch.png",
159 wield_image = "redstone_torch.png",
160 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
162 mesh = "torch_wall.obj",
163 tiles = {"redstone_torch.png"},
165 paramtype2 = "wallmounted",
166 sunlight_propagates = true,
170 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,connect_to_raillike=1},
171 drop = "redstone:torch",
173 type = "wallmounted",
174 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
175 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
176 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
178 on_construct = function(pos)
179 redstone.collect_info(pos)
181 after_destruct = function(pos, oldnode)
182 redstone.collect_info(pos)
184 sounds = main.woodSound(),
188 minetest.register_craftitem("redstone:blink_torch", {
189 description = "Redstone Blink Torch",
190 inventory_image = "redstone_torch.png",
191 wield_image = "redstone_torch.png",
192 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
193 liquids_pointable = false,
195 on_place = function(itemstack, placer, pointed_thing)
196 if pointed_thing.type ~= "node" then
200 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
202 local fakestack = itemstack
206 elseif wdir == 1 then
207 retval = fakestack:set_name("redstone:blink_torch_floor_1")
209 retval = fakestack:set_name("redstone:blink_torch_wall_1")
214 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
215 itemstack:set_name("redstone:blink_torch")
218 minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
225 local coloring = 160*(1-i)
228 minetest.register_node("redstone:blink_torch_floor_"..i, {
229 inventory_image = "redstone_torch.png",
230 wield_image = "redstone_torch.png",
231 wield_scale = {x = 1, y = 1, z = 1 + 2/16},
233 mesh = "torch_floor.obj",
234 tiles = {"redstone_torch.png^[colorize:black:"..coloring},
238 sunlight_propagates = true,
239 drop = "redstone:torch",
242 groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,connect_to_raillike=1,blinker_torch = 1},
243 legacy_wallmounted = true,
246 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
248 --there is no way for a player to get blink torch off
249 --so shortcut is to add this to both states
250 on_construct = function(pos)
251 redstone.add(pos,true)
253 after_destruct = function(pos, oldnode)
254 redstone.remove(pos,9,true)
256 sounds = main.woodSound(),
259 minetest.register_node("redstone:blink_torch_wall_"..i, {
260 inventory_image = "redstone_torch.png",
261 wield_image = "redstone_torch.png",
262 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
264 mesh = "torch_wall.obj",
265 tiles = {"redstone_torch.png^[colorize:black:"..coloring},
267 paramtype2 = "wallmounted",
268 sunlight_propagates = true,
272 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,connect_to_raillike=1,blinker_torch = 1},
273 drop = "redstone:torch",
275 type = "wallmounted",
276 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
277 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
278 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
280 on_construct = function(pos)
281 redstone.add(pos,true)
283 after_destruct = function(pos, oldnode)
284 redstone.remove(pos,9,true)
286 sounds = main.woodSound(),
292 minetest.register_abm{
293 label = "Torch Blink",
294 nodenames = {"group:blinker_torch"},
295 --neighbors = {"group:redstone"},
298 action = function(pos, node, active_object_count, active_object_count_wider)
299 --minetest.set_node(pos,{name=node.name:sub(1, -2)..0})
300 --redstone.update(pos)
301 local inversion = math.abs(tonumber(node.name:sub(#node.name, #node.name))-1) --never do this
302 minetest.set_node(pos,{name=node.name:sub(1, #node.name-1)..inversion})
303 if inversion == 1 then
304 redstone.add(pos,true)
305 elseif inversion == 0 then
306 redstone.remove(pos,9,true)
311 minetest.register_craft({
312 output = "redstone:blink_torch 4",
320 minetest.register_craft({
321 output = "redstone:torch 4",
340 minetest.register_craftitem("redstone:blink_torch", {
341 description = "Redstone Blink Torch",
342 inventory_image = "redstone_torch.png",
343 wield_image = "redstone_torch.png",
344 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
345 liquids_pointable = false,
347 on_place = function(itemstack, placer, pointed_thing)
348 if pointed_thing.type ~= "node" then
352 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
354 local fakestack = itemstack
358 elseif wdir == 1 then
359 retval = fakestack:set_name("redstone:blink_torch_floor_1")
361 retval = fakestack:set_name("redstone:blink_torch_wall_1")
366 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
367 itemstack:set_name("redstone:blink_torch")
370 minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
377 local coloring = 160*(1-i)
380 minetest.register_node("redstone:blink_torch_floor_"..i, {
381 inventory_image = "redstone_torch.png",
382 wield_image = "redstone_torch.png",
383 wield_scale = {x = 1, y = 1, z = 1 + 2/16},
385 mesh = "torch_floor.obj",
386 tiles = {"redstone_torch.png^[colorize:black:"..coloring},
390 sunlight_propagates = true,
391 drop = "redstone:torch",
394 groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,connect_to_raillike=1,blinker_torch = 1},
395 legacy_wallmounted = true,
398 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
400 on_construct = function(pos)
403 after_destruct = function(pos, oldnode)
404 redstone.update(pos,oldnode)
406 sounds = main.woodSound(),
409 minetest.register_node("redstone:blink_torch_wall_"..i, {
410 inventory_image = "redstone_torch.png",
411 wield_image = "redstone_torch.png",
412 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
414 mesh = "torch_wall.obj",
415 tiles = {"redstone_torch.png^[colorize:black:"..coloring},
417 paramtype2 = "wallmounted",
418 sunlight_propagates = true,
422 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,connect_to_raillike=1,blinker_torch = 1},
423 drop = "redstone:torch",
425 type = "wallmounted",
426 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
427 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
428 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
430 on_construct = function(pos)
433 after_destruct = function(pos, oldnode)
434 redstone.update(pos,oldnode)
436 sounds = main.woodSound(),
442 minetest.register_abm{
443 label = "Torch Blink",
444 nodenames = {"group:blinker_torch"},
445 --neighbors = {"group:redstone"},
448 action = function(pos, node, active_object_count, active_object_count_wider)
449 --minetest.set_node(pos,{name=node.name:sub(1, -2)..0})
450 --redstone.update(pos)
452 local inversion = math.abs(tonumber(node.name:sub(#node.name, #node.name))-1) --never do this
453 minetest.set_node(pos,{name=node.name:sub(1, #node.name-1)..inversion})
457 minetest.register_craft({
458 output = "redstone:blink_torch 4",