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 = "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({
81 nodenames = {"torch:floor","torch:wall"},
82 run_at_every_load = true,
83 action = function(pos, node)
89 minetest.register_craftitem("torch:torch", {
90 description = "Torch",
91 inventory_image = "torches_torch.png",
92 wield_image = "torches_torch.png",
93 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
94 liquids_pointable = false,
95 on_place = function(itemstack, placer, pointed_thing)
96 if pointed_thing.type ~= "node" then
100 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
102 local fakestack = itemstack
106 elseif wdir == 1 then
107 retval = fakestack:set_name("torch:floor")
109 retval = fakestack:set_name("torch:wall")
114 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
115 itemstack:set_name("torch:torch")
117 minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
123 minetest.register_node("torch:floor", {
124 inventory_image = "default_torch.png",
125 wield_image = "torches_torch.png",
126 wield_scale = {x = 1, y = 1, z = 1 + 2/16},
128 mesh = "torch_floor.obj",
129 tiles = {"torches_torch.png"},
132 sunlight_propagates = true,
133 drop = "torch:torch",
136 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
137 legacy_wallmounted = true,
140 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
142 on_construct = function(pos)
145 on_destruct = function(pos)
148 sounds = main.woodSound(),
151 minetest.register_node("torch:wall", {
152 inventory_image = "default_torch.png",
153 wield_image = "torches_torch.png",
154 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
156 mesh = "torch_wall.obj",
157 tiles = {"torches_torch.png"},
159 paramtype2 = "wallmounted",
160 sunlight_propagates = true,
163 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
164 drop = "torch:torch",
166 type = "wallmounted",
167 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
168 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
169 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
171 on_construct = function(pos)
174 on_destruct = function(pos)
177 sounds = main.woodSound(),
180 minetest.register_craft({
181 output = "torch:torch 4",
187 minetest.register_craft({
188 output = "torch:torch 4",