Fix mixer allowing infinite laser loops

This commit is contained in:
Wuzzy 2024-09-23 18:35:23 +02:00
parent d51edea23e
commit 09cd9eeeda
2 changed files with 10 additions and 3 deletions

View File

@ -678,7 +678,7 @@ lzr_laser.register_element("lzr_laser:mixer", {
__light_source_on = lzr_globals.LASER_GLOW,
groups = { laser_block = 1 },
sounds = lzr_sounds.node_sound_wood_defaults(),
}, { allow_take = true, allow_rotate = true, register_color = false, group = "mixer" })
}, { allow_take = true, allow_rotate = true, group = "mixer" })
-- List of emitters
local emitters = {

View File

@ -337,8 +337,15 @@ function lzr_laser.add_laser(pos, dir, colorcode, varea, vdata, vdata_p2)
local active = def._lzr_active
if active then
-- Set new node state
vdata[vi] = minetest.get_content_id(active)
-- Activate node and mix output color of node
local old_colorcode = minetest.get_item_group(nodename, "laser_block_color")
local new_colorcode = bit.bor(colorcode, old_colorcode)
-- Stop laser propagation if we already output this laser color
-- to break potential infinite loops.
if old_colorcode == new_colorcode then
return false
end
vdata[vi] = minetest.get_content_id(active.."_"..new_colorcode)
end
--[[ NOTE: The mixer does NOT actually mix the laser color,