Verse Library verse

07 Removing Button Interaction When Puzzle Is Solved

Toggles light states, updates tracking data, triggers victory effects, enables rewards, and cancels buttons.

extracted-snippets/documentation/en-us/uefn/tagged-lights-5-detecting-when-the-puzzle-is-solved-in-verse/07-removing-button-interaction-when-puzzle-is-solved.verse

# Source URL: https://dev.epicgames.com/documentation/en-us/uefn/tagged-lights-5-detecting-when-the-puzzle-is-solved-in-verse
# Local doc:  epic-docs/documentation/en-us/uefn/tagged-lights-5-detecting-when-the-puzzle-is-solved-in-verse.md
# Section:    Removing Button Interaction when Puzzle Is Solved
 ToggleLights(LightIndices : []int) : void =
     for:
         LightIndex : LightIndices
         IsLightOn := LightsState[LightIndex]
         Light := Lights[LightIndex]
     do:
         Logger.Print("Turning light at index {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}")
    
     if (IsPuzzleSolved[]):
         Logger.Print("Puzzle solved!")
         ItemSpawner.Enable()
    
         for (ButtonSubscription : ButtonSubscriptions):
             ButtonSubscription.Cancel()
Copy full snippet

Comments

    Sign in to vote, comment, or suggest an edit. Sign in