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
79 minetest.register_lbm({
80 name = "redstone:torch",
81 nodenames = {"redstone:torch_floor","redstone:torch_wall"},
82 run_at_every_load = true,
83 action = function(pos, node)
89 minetest.register_craftitem("redstone:torch", {
90 description = "Redstone Torch",
91 inventory_image = "redstone_torch.png",
92 wield_image = "redstone_torch.png",
93 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
94 liquids_pointable = false,
96 on_place = function(itemstack, placer, pointed_thing)
97 if pointed_thing.type ~= "node" then
101 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
103 local fakestack = itemstack
107 elseif wdir == 1 then
108 retval = fakestack:set_name("redstone:torch_floor")
110 retval = fakestack:set_name("redstone:torch_wall")
115 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
116 itemstack:set_name("redstone:torch")
119 minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
126 minetest.register_node("redstone:torch_floor", {
127 inventory_image = "redstone_torch.png",
128 wield_image = "redstone_torch.png",
129 wield_scale = {x = 1, y = 1, z = 1 + 2/16},
131 mesh = "torch_floor.obj",
132 tiles = {"redstone_torch.png"},
136 sunlight_propagates = true,
137 drop = "redstone:torch",
140 groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,connect_to_raillike=1},
141 legacy_wallmounted = true,
144 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
146 on_construct = function(pos)
150 after_destruct = function(pos, oldnode)
151 redstone.update(pos,oldnode)
153 on_destruct = function(pos)
156 sounds = main.woodSound(),
159 minetest.register_node("redstone:torch_wall", {
160 inventory_image = "redstone_torch.png",
161 wield_image = "redstone_torch.png",
162 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
164 mesh = "torch_wall.obj",
165 tiles = {"redstone_torch.png"},
167 paramtype2 = "wallmounted",
168 sunlight_propagates = true,
172 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},
173 drop = "redstone:torch",
175 type = "wallmounted",
176 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
177 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
178 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
180 on_construct = function(pos)
184 after_destruct = function(pos, oldnode)
185 redstone.update(pos,oldnode)
187 on_destruct = function(pos)
190 sounds = main.woodSound(),
193 minetest.register_craft({
194 output = "redstone:torch 4",
213 minetest.register_craftitem("redstone:blink_torch", {
214 description = "Redstone Blink Torch",
215 inventory_image = "redstone_torch.png",
216 wield_image = "redstone_torch.png",
217 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
218 liquids_pointable = false,
220 on_place = function(itemstack, placer, pointed_thing)
221 if pointed_thing.type ~= "node" then
225 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
227 local fakestack = itemstack
231 elseif wdir == 1 then
232 retval = fakestack:set_name("redstone:blink_torch_floor_1")
234 retval = fakestack:set_name("redstone:blink_torch_wall_1")
239 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
240 itemstack:set_name("redstone:blink_torch")
243 minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
250 local coloring = 160*(1-i)
253 minetest.register_node("redstone:blink_torch_floor_"..i, {
254 inventory_image = "redstone_torch.png",
255 wield_image = "redstone_torch.png",
256 wield_scale = {x = 1, y = 1, z = 1 + 2/16},
258 mesh = "torch_floor.obj",
259 tiles = {"redstone_torch.png^[colorize:black:"..coloring},
263 sunlight_propagates = true,
264 drop = "redstone:torch",
267 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},
268 legacy_wallmounted = true,
271 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
273 on_construct = function(pos)
276 after_destruct = function(pos, oldnode)
277 redstone.update(pos,oldnode)
279 sounds = main.woodSound(),
282 minetest.register_node("redstone:blink_torch_wall_"..i, {
283 inventory_image = "redstone_torch.png",
284 wield_image = "redstone_torch.png",
285 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
287 mesh = "torch_wall.obj",
288 tiles = {"redstone_torch.png^[colorize:black:"..coloring},
290 paramtype2 = "wallmounted",
291 sunlight_propagates = true,
295 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},
296 drop = "redstone:torch",
298 type = "wallmounted",
299 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
300 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
301 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
303 on_construct = function(pos)
306 after_destruct = function(pos, oldnode)
307 redstone.update(pos,oldnode)
309 sounds = main.woodSound(),
315 minetest.register_abm{
316 label = "Torch Blink",
317 nodenames = {"group:blinker_torch"},
318 --neighbors = {"group:redstone"},
321 action = function(pos, node, active_object_count, active_object_count_wider)
322 --minetest.set_node(pos,{name=node.name:sub(1, -2)..0})
323 --redstone.update(pos)
325 local inversion = math.abs(tonumber(node.name:sub(#node.name, #node.name))-1) --never do this
326 minetest.set_node(pos,{name=node.name:sub(1, #node.name-1)..inversion})
330 minetest.register_craft({
331 output = "redstone:blink_torch 4",