From 3c2633ee2c534682134b0e63bff649cd4a9dc874 Mon Sep 17 00:00:00 2001 From: cora Date: Wed, 6 Jul 2022 04:17:39 +0200 Subject: [PATCH] Simplify my own mess... remove code dupe i'll fix this in cauldrons too, promise --- mods/ITEMS/mcl_campfires/init.lua | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/mcl_campfires/init.lua b/mods/ITEMS/mcl_campfires/init.lua index b4ff7d5599..e51ec9f54f 100644 --- a/mods/ITEMS/mcl_campfires/init.lua +++ b/mods/ITEMS/mcl_campfires/init.lua @@ -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 minetest.register_globalstep(function(dtime) etime = dtime + etime if etime < 0.5 then return end etime = 0 for _,pl in pairs(minetest.get_connected_players()) do - local n = minetest.find_node_near(pl:get_pos(),0.4,{"group:lit_campfire"},true) - if n then - mcl_burning.set_on_fire(pl, 5) - end + burn_in_campfire(pl) end for _,ent in pairs(minetest.luaentities) do - if ent.object:get_pos() and ent.is_mob then - local n = minetest.find_node_near(ent.object:get_pos(),0.4,{"group:lit_campfire"},true) - if n then - mcl_burning.set_on_fire(ent.object, 5) - end + if ent.is_mob then + burn_in_campfire(ent.object) end end end)