overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Public Types | Public Member Functions
gameplay::Script Class Reference

#include <Script.h>

Inheritance diagram for gameplay::Script:

List of all members.

Public Types

enum  Scope { GLOBAL, PROTECTED }

Public Member Functions

const char * getPath () const
Scope getScope () const
bool functionExists (const char *name) const
bool reload ()

Detailed Description

Represents a script that has been loaded by the scripting system.

Member Enumeration Documentation

Defines the scope of a script environment.


Global scripts execute in a single shared environment that is accessible to all other scripts in the system. Global scripts can use code from other global scripts and other scripts can use code from a global script.

Scripts that execute in the global environment must be careful to not override other variables or functions that already exist in the global environment (unless this is intended). Because of this, script naming conventions and the use of unique namespaces is important to prevent naming collisions with other global code.


Protected scripts execute in a more limited sandbox environment that by default does not allow other scripts to see their variables or functions. Variables and functions in a protected script can be named the same as those in other scripts without collision issues.

Although global code cannot access protected scripts, protected scripts can acceess global code. Similarly, protected scripts can expose variables and functions to the global environment using explicit notation, although the same precautions noted for the GLOBAL scope should be used when doing this, to prevent naming collisions.

Protected scripts are best used when associated with a single game object, since these scripts are not cached the same way global scripts are. Each time a protected script is loaded, a new instance of the script is loaded. This allows protected scripts to store per-instance state, since it will not be shared by multiple instances.

See also:

Member Function Documentation

bool gameplay::Script::functionExists ( const char *  name) const

Determines if a function with the given name exists in the script.

nameName of the function.
True if the function exists, false otherwise.
const char* gameplay::Script::getPath ( ) const

Returns the path from which this Script was loaded.

The script's path.

Returns the scope of this script.

The scope of this script.

Reloads this script.

The code in the script will be reloaded and any functions and variables will be overwritten into the script's envrionment.

If the script is GLOBAL in scope, it will simply be re-run, replacing any existing global variables and functions. If the script has changed, any previous variables or functions that do not exist in the updated script will remain in the global environment.

True if the script is successfully reloaded, false otherwise.
 All Classes Functions Variables Typedefs Enumerations Enumerator