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)
22 local dir = get_offset(minetest.get_node(pos).param2)
23 local ppos = vector.add(dir,pos)
24 minetest.add_particle({
26 velocity = vector.new(0,0,0),
27 acceleration = vector.new(0,0,0),
28 expirationtime = particle_time*3,
30 collisiondetection = false,
32 texture = "torch_animated.png",
33 animation = {type = "vertical_frames",
36 -- Width of a frame in pixels
39 -- Height of a frame in pixels
46 minetest.add_particlespawner({
47 amount = particle_time*6,
48 time = particle_time*2,
51 minvel = vector.new(-0.1,0.1,-0.1),
52 maxvel = vector.new(0.1,0.3,0.1),
53 minacc = vector.new(0,0,0),
54 maxacc = vector.new(0,0,0),
59 collisiondetection = false,
61 texture = "smoke.png",
67 --reload smoke and flame on load
69 minetest.register_abm({
70 label = "Torch Particle",
71 nodenames = {"group:torch"},
73 interval = particle_time,
75 action = function(pos, node, active_object_count, active_object_count_wider)
76 local found_player = false
77 for _,object in ipairs(minetest.get_objects_inside_radius(pos, check_radius)) do
78 local pos2 = object:getpos()
79 if object:is_player() then
83 if found_player == true then
91 minetest.register_craftitem("torch:torch", {
92 description = "Torch",
93 inventory_image = "torches_torch.png",
94 wield_image = "torches_torch.png",
95 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
96 liquids_pointable = false,
97 on_place = function(itemstack, placer, pointed_thing)
98 if pointed_thing.type ~= "node" then
102 local wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
104 local fakestack = itemstack
108 elseif wdir == 1 then
109 retval = fakestack:set_name("torch:floor")
111 retval = fakestack:set_name("torch:wall")
116 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
117 itemstack:set_name("torch:torch")
120 minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
127 minetest.register_node("torch:floor", {
128 inventory_image = "default_torch.png",
129 wield_image = "torches_torch.png",
130 wield_scale = {x = 1, y = 1, z = 1 + 2/16},
132 mesh = "torch_floor.obj",
133 tiles = {"torches_torch.png"},
136 sunlight_propagates = true,
137 drop = "torch:torch",
140 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
141 legacy_wallmounted = true,
144 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
146 sounds = main.woodSound(),
149 minetest.register_node("torch:wall", {
150 inventory_image = "default_torch.png",
151 wield_image = "torches_torch.png",
152 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
154 mesh = "torch_wall.obj",
155 tiles = {"torches_torch.png"},
157 paramtype2 = "wallmounted",
158 sunlight_propagates = true,
161 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
162 drop = "torch:torch",
164 type = "wallmounted",
165 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
166 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
167 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
169 sounds = main.woodSound(),
172 minetest.register_craft({
173 output = "torch:torch 4",
179 minetest.register_craft({
180 output = "torch:torch 4",