Sharing variables between scripts
setShared(key, value) Description: Stores a variable in a public list accessible by all scripts. Parameters:
key (String): The unique identifier for the variable.
value (Any): The value to be stored. This can be a string, number, object, function, list, class instance, etc.
getShared(key) Description: Retrieves a variable from the public list. If the variable does not exist, the function will wait until it does or timeout after 500 milliseconds. Parameters:
key (String): The unique identifier for the variable to be retrieved.
Returns:
The value associated with the given key, or null if the variable does not exist within the timeout period.
here are quick examples:
To read a public variable from any script do the following:
It'll return the variable "Hello world!" You can share any type of variable! Here is an example with a function:
Last updated