|  | overview |  | wiki |  | api reference |  | download

- Main Page
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

enum gameplay::Script::Scope

Defines the scope of a script environment.

Enumerator:

  GLOBAL

  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

  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:
    ScriptTarget

## Member Function Documentation

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

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

Parameters:

  name | Name of the function.

Returns:
  True if the function exists, false otherwise.

const char* gameplay::Script::getPath | ( |  | ) | const

Returns the path from which this Script was loaded.

Returns:
  The script's path.

Scope gameplay::Script::getScope | ( |  | ) | const

Returns the scope of this script.

Returns:
  The scope of this script.

bool gameplay::Script::reload | ( |  | ) |

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.

Returns:
  True if the script is successfully reloaded, false otherwise.

All Classes Functions Variables Typedefs Enumerations Enumerator