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 meta = minetest.get_meta(pos)
27 local dir = get_offset(minetest.get_node(pos).param2)
28 local ppos = vector.add(dir,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)
79 --reload smoke and flame on load
80 minetest.register_abm({
81 label = "Torch Particle",
82 nodenames = {"group:torch"},
86 action = function(pos, node, active_object_count, active_object_count_wider)
87 local found_player = false
88 for _,object in ipairs(minetest.get_objects_inside_radius(pos, 3)) do
89 local pos2 = object:getpos()
90 if object:is_player() then
94 if found_player == true then
105 minetest.register_craftitem("torch:torch", {
106 description = "Torch",
107 inventory_image = "torches_torch.png",
108 wield_image = "torches_torch.png",
109 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
110 liquids_pointable = false,
111 on_place = function(itemstack, placer, pointed_thing)
112 if pointed_thing.type ~= "node" then
116 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
118 local fakestack = itemstack
122 elseif wdir == 1 then
123 retval = fakestack:set_name("torch:floor")
125 retval = fakestack:set_name("torch:wall")
130 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
131 itemstack:set_name("torch:torch")
134 minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
141 minetest.register_node("torch:floor", {
142 inventory_image = "default_torch.png",
143 wield_image = "torches_torch.png",
144 wield_scale = {x = 1, y = 1, z = 1 + 2/16},
146 mesh = "torch_floor.obj",
147 tiles = {"torches_torch.png"},
150 sunlight_propagates = true,
151 drop = "torch:torch",
154 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
155 legacy_wallmounted = true,
158 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
160 on_construct = function(pos)
163 on_destruct = function(pos)
166 sounds = main.woodSound(),
169 minetest.register_node("torch:wall", {
170 inventory_image = "default_torch.png",
171 wield_image = "torches_torch.png",
172 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
174 mesh = "torch_wall.obj",
175 tiles = {"torches_torch.png"},
177 paramtype2 = "wallmounted",
178 sunlight_propagates = true,
181 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
182 drop = "torch:torch",
184 type = "wallmounted",
185 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
186 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
187 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
189 on_construct = function(pos)
192 on_destruct = function(pos)
195 sounds = main.woodSound(),
198 minetest.register_craft({
199 output = "torch:torch 4",
205 minetest.register_craft({
206 output = "torch:torch 4",