Simplify my own mess... remove code dupe

i'll fix this in cauldrons too, promise
This commit is contained in:
cora 2022-07-06 04:17:39 +02:00
parent f0241bbf6a
commit 3c2633ee2c
1 changed files with 13 additions and 9 deletions

View File

@ -119,23 +119,27 @@ minetest.register_craft({
} }
}) })
local function burn_in_campfire(obj)
local p = obj:get_pos()
if p then
local n = minetest.find_node_near(p,0.4,{"group:lit_campfire"},true)
if n then
mcl_burning.set_on_fire(obj, 5)
end
end
end
local etime = 0 local etime = 0
minetest.register_globalstep(function(dtime) minetest.register_globalstep(function(dtime)
etime = dtime + etime etime = dtime + etime
if etime < 0.5 then return end if etime < 0.5 then return end
etime = 0 etime = 0
for _,pl in pairs(minetest.get_connected_players()) do for _,pl in pairs(minetest.get_connected_players()) do
local n = minetest.find_node_near(pl:get_pos(),0.4,{"group:lit_campfire"},true) burn_in_campfire(pl)
if n then
mcl_burning.set_on_fire(pl, 5)
end
end end
for _,ent in pairs(minetest.luaentities) do for _,ent in pairs(minetest.luaentities) do
if ent.object:get_pos() and ent.is_mob then if ent.is_mob then
local n = minetest.find_node_near(ent.object:get_pos(),0.4,{"group:lit_campfire"},true) burn_in_campfire(ent.object)
if n then
mcl_burning.set_on_fire(ent.object, 5)
end
end end
end end
end) end)