Merge branch 'light_cycle' into 'master'

Fix firefly lights not properly refreshing sometimes when shown/hidden

See merge request Df458/fly_b_gone!1
This commit is contained in:
Hugues Ross 2019-11-24 02:06:27 +00:00
commit 71c099e9a4

View File

@ -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