# This is a comment. Verse ignores lines starting with #. # We're making a simple Day/Night switch. # 1. Define our Script. In UEFN, Verse logic lives inside a creative_device class. using { /Fortnite.com/Devices } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # mood_sky_script is the container for our logic. # It inherits from creative_device so UEFN recognises it as a placeable script device. mood_sky_script := class(creative_device): # 2. Variables: These are our "state trackers." # CurrentMood is a boolean (true/false). # Think of it like a light switch: On or Off. # 'var' makes it mutable so we can toggle it later. var CurrentMood : logic = true # Reference to the skydome device placed on the island. # Wire this up in the UEFN Details panel after placing the script device. # skydome_device exposes EnableDayPhase / DisableDayPhase and # fog controls we call below. MoodSwitch : button_device = button_device{} SkyDome : sky_dome_device = sky_dome_device{} # OnBegin runs automatically when the game session starts. # We use it to subscribe to the button's InteractedWithEvent. OnBegin() : void = # Connect the button's event to our handler function. # Every time a player presses MoodSwitch, ChangeSkyMood fires. MoodSwitch.InteractedWithEvent.Subscribe(OnButtonPressed) # 3. Event handler: called by the Subscribe above. # Agent is the player who pressed the button (required by the event signature). OnButtonPressed(Agent : agent) : void = ChangeSkyMood() # 4. Function: This is our "Combo Move." # It reads CurrentMood and applies the matching sky preset, # then toggles the variable so the next press flips to the other state. ChangeSkyMood() : void = if (CurrentMood?): # --- DAYTIME preset --- # Re-enable the normal day phase on the skydome device. # note: sky_dome_device is the real UEFN device; tweak its # Day/Night settings in the Details panel for exact colours. SkyDome.EnableDayPhase() Print("Sky set to: DAY") else: # --- NIGHTTIME preset --- # Switch the skydome to its night phase. SkyDome.DisableDayPhase() Print("Sky set to: NIGHT") # 5. Toggle the variable for next time. # 'not' is the Verse boolean negation operator. # If it was true, make it false. If false, make it true. set CurrentMood = not CurrentMood