Magical light scenes

I can’t say I understand how the code above works. The best I can offer is Design Pattern: Associated Items or A simple scene management: finally a good use of scripts. If it were Scripted Automation you could use .Design Pattern: Using Item Metadata as an Alternative to Several DPs.