Class ScriptSystem

Class Documentation

class ScriptSystem

A JavaScript based scripting system that can be used to create advanced behaviours and interactions between entities in spaces.

Public Functions

void Initialise()

Starts up the JavaScript runtime context.

void Shutdown()

Shuts down and deletes the JavaScript runtime context.

bool RunScript(int64_t ContextId, const csp::common::String &ScriptText)

Attempts to execute a script in a given context.

Parameters
  • ContextId – : The context in which to run the script. If the provided context does not exist, the script run will fail.

  • ScriptText – : The script to execute.

Returns

a boolean representing success running the script.

bool RunScriptFile(int64_t ContextId, const csp::common::String &ScriptFilePath)

Attempts to execute a script from a given file path in the given context.

Parameters
  • ContextId – : The context in which to run the script. If the provided context does not exist, the script run will fail.

  • ScriptFilePath – : The file path of the script to execute.

Returns

a boolean representing success running the script.

bool CreateContext(int64_t ContextId)
bool DestroyContext(int64_t ContextId)
bool BindContext(int64_t ContextId)
bool ResetContext(int64_t ContextId)
bool ExistsInContext(int64_t ContextId, const csp::common::String &ObjectName)
void *GetContext(int64_t ContextId)
void *GetModule(int64_t ContextId, const csp::common::String &ModuleName)
void RegisterScriptBinding(IScriptBinding *ScriptBinding)
void UnregisterScriptBinding(IScriptBinding *ScriptBinding)
void SetModuleSource(csp::common::String ModuleUrl, csp::common::String Source)
void AddModuleUrlAlias(const csp::common::String &ModuleUrl, const csp::common::String &ModuleUrlAlias)
bool GetModuleUrlAlias(const csp::common::String &ModuleUrl, csp::common::String &OutModuleUrlAlias)
void ClearModuleSource(csp::common::String ModuleUrl)
csp::common::String GetModuleSource(csp::common::String ModuleUrl)
size_t GetNumImportedModules(int64_t ContextId) const
const char *GetImportedModule(int64_t ContextId, size_t Index) const