From 376ce515c5afde6ecc3b0b314a3fca376d09b8c4 Mon Sep 17 00:00:00 2001 From: Hugues Ross Date: Sat, 23 Nov 2019 21:05:10 -0500 Subject: [PATCH] Fix firefly lights not properly refreshing sometimes when shown/hidden --- init.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/init.lua b/init.lua index 1d96322..fcec332 100644 --- a/init.lua +++ b/init.lua @@ -28,6 +28,9 @@ end if minetest.settings:get_bool("hide_fireflies", "Firefly") then disable_node("fireflies:firefly", "Firefly", "firefly"); + -- These nodes need to be 'cycled' to trigger a lighting update + local to_cycle = { "fireflies:firefly" }; + if minetest.settings:get_bool("keep_bottled_fireflies") == false then -- Make firefly_bottle look and behave like a regular glass bottle minetest.override_item("fireflies:firefly_bottle", { @@ -40,6 +43,9 @@ if minetest.settings:get_bool("hide_fireflies", "Firefly") then on_rightclick = nil, }); + -- Add firefly_bottle to the list of light nodes to cycle + to_cycle[#to_cycle + 1] = "fireflies:firefly_bottle"; + -- Fallback for re-using bottles, allow crafting firefly_bottle into glass_bottle minetest.register_craft({ output = "vessels:glass_bottle", @@ -47,4 +53,16 @@ if minetest.settings:get_bool("hide_fireflies", "Firefly") then recipe = { "fireflies:firefly_bottle" }, }); end + + -- Register an LBM that triggers a node update on light-creating firefly + -- nodes. This will force the lighting to refresh. + minetest.register_lbm({ + label = "Refresh firefly lights", + name = "fly_b_gone:cycle_fireflies", + nodenames = to_cycle, + run_at_every_load = false, + action = function(pos, node) + minetest.set_node(pos, { name = node.name }); + end + }) end