1 local particle_time = 5 -- how many seconds torches will wait to check if player is near
2 local check_radius = 10
4 --get point where particle spawner is added
5 local function get_offset(wdir)
17 return {x = x, y = 0.27, z = z}
19 --add in smoke and fire
20 local function create_ps(pos)
21 local dir = get_offset(minetest.get_node(pos).param2)
22 local ppos = vector.add(dir,pos)
23 minetest.add_particle({
25 velocity = vector.new(0,0,0),
26 acceleration = vector.new(0,0,0),
27 expirationtime = particle_time*3,
29 collisiondetection = false,
31 texture = "torch_animated.png",
32 animation = {type = "vertical_frames",
35 -- Width of a frame in pixels
38 -- Height of a frame in pixels
45 minetest.add_particlespawner({
46 amount = particle_time*6,
47 time = particle_time*2,
50 minvel = vector.new(-0.1,0.1,-0.1),
51 maxvel = vector.new(0.1,0.3,0.1),
52 minacc = vector.new(0,0,0),
53 maxacc = vector.new(0,0,0),
58 collisiondetection = false,
60 texture = "smoke.png",
66 --reload smoke and flame on load
68 minetest.register_abm({
69 label = "Torch Particle",
70 nodenames = {"group:torch"},
72 interval = particle_time,
74 action = function(pos, node, active_object_count, active_object_count_wider)
75 local found_player = false
76 for _,object in ipairs(minetest.get_objects_inside_radius(pos, check_radius)) do
77 local pos2 = object:getpos()
78 if object:is_player() then
82 if found_player == true then
90 minetest.register_craftitem("torch:torch", {
91 description = "Torch",
92 inventory_image = "torches_torch.png",
93 wield_image = "torches_torch.png",
94 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
95 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("torch:floor")
110 retval = fakestack:set_name("torch:wall")
115 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
116 itemstack:set_name("torch:torch")
119 minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
126 minetest.register_node("torch:floor", {
127 inventory_image = "default_torch.png",
128 wield_image = "torches_torch.png",
129 wield_scale = {x = 1, y = 1, z = 1 + 2/16},
131 mesh = "torch_floor.obj",
132 tiles = {"torches_torch.png"},
135 sunlight_propagates = true,
136 drop = "torch:torch",
139 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
140 legacy_wallmounted = true,
143 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
145 sounds = main.woodSound(),
148 minetest.register_node("torch:wall", {
149 inventory_image = "default_torch.png",
150 wield_image = "torches_torch.png",
151 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
153 mesh = "torch_wall.obj",
154 tiles = {"torches_torch.png"},
156 paramtype2 = "wallmounted",
157 sunlight_propagates = true,
160 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
161 drop = "torch:torch",
163 type = "wallmounted",
164 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
165 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
166 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
168 sounds = main.woodSound(),
171 minetest.register_craft({
172 output = "torch:torch 4",
178 minetest.register_craft({
179 output = "torch:torch 4",