Verse Library verse

02 Standalone

Holds a reference to another script and calls its public methods safely, enabling cross-script communication.

verse-library/specifiers/02-standalone.verse

# This script is attached to a Button.

# We need a reference to the Light Script.
# Think of this as holding the remote control.
light_remote := struct {
    # This variable will hold the other script.
    controller: Script
}

# This event happens when you click the button.
OnClicked := function() {
    # We check if the remote has a script.
    if (light_remote.controller != None) {
        # We call the PUBLIC function from the other script.
        # This works because we used 'public' in the other script!
        light_remote.controller.TurnOn()
    }
}

Comments

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