1 local minetest,vector = minetest,vector
2 --get point where particle spawner is added
3 local function get_offset(wdir)
15 return {x = x, y = 0.27, z = z}
18 --remove smoke and fire
19 local function delete_ps(pos)
20 local meta = minetest.get_meta(pos)
21 minetest.delete_particlespawner(meta:get_int("psf"))
22 minetest.delete_particlespawner(meta:get_int("pss"))
25 --add in smoke and fire
26 local function create_ps(pos)
27 local dir = get_offset(minetest.get_node(pos).param2)
28 local ppos = vector.add(dir,pos)
29 local meta = minetest.get_meta(pos)
30 local psf = minetest.add_particlespawner({
35 minvel = vector.new(0,0,0),
36 maxvel = vector.new(0,0,0),
37 minacc = {x=0, y=0, z=0},
38 maxacc = {x=0, y=0, z=0},
43 collisiondetection = false,
45 texture = "redstone_torch_animated.png",
46 animation = {type = "vertical_frames",
49 -- Width of a frame in pixels
52 -- Height of a frame in pixels
58 local pss = minetest.add_particlespawner({
63 minvel = vector.new(-0.1,0.1,-0.1),
64 maxvel = vector.new(0.1,0.3,0.1),
65 minacc = vector.new(0,0,0),
66 maxacc = vector.new(0,0,0),
71 collisiondetection = false,
73 texture = "smoke.png",
75 meta:set_int("psf", psf)
76 meta:set_int("pss", pss)
79 --reload smoke and flame on load
81 minetest.register_lbm({
82 name = "redstone:torch",
83 nodenames = {"redstone:torch_floor","redstone:torch_wall"},
84 run_at_every_load = true,
85 action = function(pos, node)
91 minetest.register_craftitem("redstone:torch", {
92 description = "Redstone Torch",
93 inventory_image = "redstone_torch.png",
94 wield_image = "redstone_torch.png",
95 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
96 liquids_pointable = false,
98 on_place = function(itemstack, placer, pointed_thing)
99 if pointed_thing.type ~= "node" then
103 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
105 local fakestack = itemstack
109 elseif wdir == 1 then
110 retval = fakestack:set_name("redstone:torch_floor")
112 retval = fakestack:set_name("redstone:torch_wall")
113 --local name = minetest.get_node(pointed_thing.under).name
114 --local def = minetest.registered_nodes[name]
115 --if def.drawtype == "normal" and string.match(name, "main:") then
116 -- minetest.set_node(pointed_thing.under,{name="redstone:"..string.gsub(name, "main:", "").."_deactivator"})
122 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
123 itemstack:set_name("redstone:torch")
126 minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
133 minetest.register_node("redstone:torch_floor", {
134 inventory_image = "redstone_torch.png",
135 wield_image = "redstone_torch.png",
136 wield_scale = {x = 1, y = 1, z = 1 + 2/16},
138 mesh = "torch_floor.obj",
139 tiles = {"redstone_torch.png"},
143 sunlight_propagates = true,
144 drop = "redstone:torch",
147 groups = {choppy=2, dig_immediate=3, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,redstone_power=9},
148 legacy_wallmounted = true,
151 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
154 on_construct = function(pos)
155 --redstone.torch_activate(pos)
156 redstone.collect_info(pos)
158 after_destruct = function(pos, oldnode)
159 redstone.collect_info(pos)
161 sounds = main.woodSound(),
164 minetest.register_node("redstone:torch_wall", {
165 inventory_image = "redstone_torch.png",
166 wield_image = "redstone_torch.png",
167 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
169 mesh = "torch_wall.obj",
170 tiles = {"redstone_torch.png"},
172 paramtype2 = "wallmounted",
173 sunlight_propagates = true,
177 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1,redstone=1,redstone_torch=1,redstone_power=9},
178 drop = "redstone:torch",
180 type = "wallmounted",
181 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
182 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
183 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
185 on_construct = function(pos)
186 --redstone.torch_activate(pos)
187 redstone.collect_info(pos)
189 after_destruct = function(pos, oldnode)
190 redstone.collect_info(pos)
192 sounds = main.woodSound(),