# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/tagged-lights-4-toggling-lights-with-buttons-in-verse
# Local doc: epic-docs/documentation/en-us/uefn/tagged-lights-4-toggling-lights-with-buttons-in-verse.md
# Section: Toggling Lights
ToggleLights(LightIndices : []int) : void =
for:
LightIndex : LightIndices
IsLightOn := LightsState[LightIndex]
Light := Lights[LightIndex]
do:
Logger.Print("Turning light at {LightIndex} {if (IsLightOn?) then "Off" else "On"}")
NewLightState :=
if (IsLightOn?):
Light.TurnOff()
false
else:
Light.TurnOn()
true
if (set LightsState[LightIndex] = NewLightState):
Logger.Print("Updated the state for light at {LightIndex}")
Copy full snippet
Verse Library
verse
05 Toggling Lights
Toggles light objects and safely updates their boolean state tracking array.
extracted-snippets/documentation/en-us/uefn/tagged-lights-4-toggling-lights-with-buttons-in-verse/05-toggling-lights.verse