Verse Library verse

01 Fragment

Toggles a boolean state when a player interacts with a device and responds to the new state.

verse-library/basic-options/01-fragment.verse

# We are defining a new "Device" called ChaosBox.
# Think of this as the blueprint for our interactive prop.
ChaosBox = device {
    # This is our "Light Switch."
    # It's an Option that starts as false (OFF).
    # In game terms, this is like a boolean flag: True = Chaos, False = Normal.
    IsChaosMode: bool = false

    # This is the "Trigger" that fires when a player interacts with the prop.
    # It's like the button on a door that says "Open."
    Interacted = event() {
        # STEP 1: Flip the switch.
        # We use the NOT operator (!) to flip the value.
        # If IsChaosMode is false, !false becomes true.
        # If IsChaosMode is true, !true becomes false.
        IsChaosMode = !IsChaosMode

        # STEP 2: Check the state and react.
        # We use an "if" statement. This is like a fork in the road.
        if (IsChaosMode == true) {
            # CHAOS MODE IS ON
            # We simulate changing the sky color by printing to the debug log.
            # In a real build, you'd use a Prop-Mover to change a sky sphere's color.
            print("CHOS MODE ACTIVATED! The sky is red!")

            # We also want to tell the player visually.
            # Let's make the box glow red (simulated by changing its name in log).
            print("The box is now GLOWING with evil energy.")
        } else {
            # CHAOS MODE IS OFF

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

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