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 buildable = minetest.get_nodedef(minetest.get_node(pointed_thing.under).name, "buildable_to")
106 wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.under))
108 wdir = minetest.dir_to_wallmounted(vector.subtract(pointed_thing.under,pointed_thing.above))
111 local fakestack = itemstack
114 if buildable and wdir == 4 then
115 retval = fakestack:set_name("torch:floor")
118 elseif wdir == 1 then
119 retval = fakestack:set_name("torch:floor")
121 retval = fakestack:set_name("torch:wall")
127 itemstack, retval = minetest.item_place(fakestack, placer, pointed_thing, wdir)
128 itemstack:set_name("torch:torch")
131 minetest.sound_play("wood", {pos=pointed_thing.above, gain = 1.0})
138 minetest.register_node("torch:floor", {
139 inventory_image = "torches_torch.png",
140 wield_image = "torches_torch.png",
141 wield_scale = {x = 1, y = 1, z = 1 + 2/16},
143 mesh = "torch_floor.obj",
144 tiles = {"torches_torch.png"},
147 sunlight_propagates = true,
148 drop = "torch:torch",
151 on_flood = function(pos, oldnode, newnode)
152 minetest.throw_item(pos, "torch:torch")
155 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
156 legacy_wallmounted = true,
159 fixed = {-1/16, -0.5, -1/16, 1/16, 2/16, 1/16},
161 sounds = main.woodSound(),
164 minetest.register_node("torch:wall", {
165 inventory_image = "torches_torch.png",
166 wield_image = "torches_torch.png",
167 wield_scale = {x = 1, y = 1, z = 1 + 1/16},
169 mesh = "torch_wall.obj",
170 tiles = {"torches_torch.png"},
172 paramtype2 = "wallmounted",
174 on_flood = function(pos, oldnode, newnode)
175 minetest.throw_item(pos, "torch:torch")
177 sunlight_propagates = true,
180 groups = {choppy=2, dig_immediate=3, flammable=1, not_in_creative_inventory=1, attached_node=1, torch=1},
181 drop = "torch:torch",
183 type = "wallmounted",
184 wall_top = {-0.1, -0.1, -0.1, 0.1, 0.5, 0.1},
185 wall_bottom = {-0.1, -0.5, -0.1, 0.1, 0.1, 0.1},
186 wall_side = {-0.5, -0.3, -0.1, -0.2, 0.3, 0.1},
188 sounds = main.woodSound(),
191 minetest.register_craft({
192 output = "torch:torch 4",