Fix mixer allowing infinite laser loops
This commit is contained in:
parent
d51edea23e
commit
09cd9eeeda
@ -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 = {
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user