World of Hello
Static Public Member Functions | List of all members
script Class Reference

used to control specific scripts. More...

#include <script.h>

Static Public Member Functions

static script setReloadOnUpdate (string scriptName, bool reloadOnupdate=true)
 sets whether or not the script should reload on update. More...
 
static script remove (string scriptName)
 removes the given script, no longer running it. More...
 
static bool rename (string scriptName, string newName="")
 renames the script. If no name given, renames the current script. More...
 
static script clear (string scriptName)
 clears the script, removing all objects associated with it. More...
 
static multiReturn< var *... > triggerFunction (string funcName, string scriptName,...)
 calls a function in a script. More...
 
static string doString (string scriptStr, string scriptName)
 does a script string in a script. More...
 
static var * getValue (string variable, string scriptName)
 gets the value of a variable from another script. More...
 
static string thisName ()
 gets the name of the script where this function is called. More...
 
static function thisFunction ()
 gets the current function where this function is called. More...
 
static string thisFunctionName ()
 gets the name of the function where this function is called. More...
 

Detailed Description

used to control specific scripts.

Member Function Documentation

◆ clear()

static script script::clear ( string  scriptName)
static

clears the script, removing all objects associated with it.

Parameters
Thename of the script.
Returns
Returns itself.

◆ doString()

static string script::doString ( string  scriptStr,
string  scriptName 
)
static

does a script string in a script.

  Given a script, runs the given string in the script by name.
Parameters
Thestring to run in the script.
Thescript name where the string is ran.
Returns
Returns nil if the script ran successfully, otherwise returns an error message.

◆ getValue()

static var* script::getValue ( string  variable,
string  scriptName 
)
static

gets the value of a variable from another script.

   Gets the value of any variable from another script. The value is not limited to variable type.
Parameters
Thevariable name from another script.
Thescript name to get the variable from.
Returns
The variable from another script. If it doesn't exist, returns nil.

◆ remove()

static script script::remove ( string  scriptName)
static

removes the given script, no longer running it.

   Removes the script, destroying it from the application.\n
   WARNING: the script is removed the next time it is ran. This means the script does not stop running on the same loop that it is removed (this is to prevent exiting early from a script and adds additional security for cleaning up objects).
Parameters
Thename of the script.

◆ rename()

static bool script::rename ( string  scriptName,
string  newName = "" 
)
static

renames the script. If no name given, renames the current script.

   Renames the given script, or the current script if no given script.\n
   Since loaded scripts must be uniquely named, this is an option for loading multiple instances of a script.\n
   NOTE that this is different than renaming the file using server:renameFile().
   WARNING: Scripts updated on the server or locally are updated via name. By renaming the script, if a script with that name is downloaded or updated, this script will be replaced.
Parameters
Thename of the script to be renamed (or the new name of the current script if no newName given).
(optional)The new name of the script (if not given, scriptName becomes newName).
Returns
Whether or not the rename was successful (e.g. couldn't be renamed because a script with that name already exists).

◆ setReloadOnUpdate()

static script script::setReloadOnUpdate ( string  scriptName,
bool  reloadOnupdate = true 
)
static

sets whether or not the script should reload on update.

   True by default. If this is set to true, a script will call "onCreated()" each time that a script is modified.
   Otherwise, if this is false, a script will call "onCreated()" only at the time an app is loaded, and never again.
Parameters
Thename of the script.
(optional)Whether or not the script should reload on update.
Returns
Returns itself.

◆ thisFunction()

static function script::thisFunction ( )
static

gets the current function where this function is called.

Returns
The current function.

◆ thisFunctionName()

static string script::thisFunctionName ( )
static

gets the name of the function where this function is called.

Returns
The name of the function where this function is called.

◆ thisName()

static string script::thisName ( )
static

gets the name of the script where this function is called.

Returns
The name of the script where this function is called.

◆ triggerFunction()

static multiReturn<var* ...> script::triggerFunction ( string  funcName,
string  scriptName,
  ... 
)
static

calls a function in a script.

   Given a list of parameters, calls a function and uses them as arguments.\n
   Returns only a single variable for each triggered function. If the function doesn't return anything, the variable is nil for the triggered function.\n
   WARNING: a script that is being loaded from game:loadScript() will have the function triggered once the script loads. Scripts loaded from a directory, rather than directly loaded, will <b>not</b> be triggered.
Parameters
Thefunction to trigger in another script.
Thescript name where the function is called. You may use an asterisk (*) as a wildcard to trigger multiple scripts.
(optional)The arguments to trigger the function with.
Returns
Returns the first variable from each triggered function's return if any, otherwise nil for that function.