Script

Allows to compile code during execution time having a clean context. It adds some syntactic features and controls errors in a safe way.

Constructor

new L3D.Script()

Properties

static onError function = null

Used to globalally catch errors in scripts

static showErrorsInConsole bool = true

If true, script errors will be printed to the console.

Methods

static applyToConstructor(constructor, argArray, methods)

Given a constructor, it attaches several global arguments and methods

Parameters
constructor *
argArray *
methods *

static cleanCode(code)

Remove comments and trims empty lines

Parameters
code *

static computeLineFromError(error)

In case of error inside the scripts, tries to determine the error line (not as easy as it seems). Doesnt work in all cases.

Parameters
error *

static expandCode(code)

Adds some extra features to JS like:

  • the use of private or public in variables.
Parameters
code *

static showCodeInConsole(code, errorLine)

Dumps all the code to the console

Parameters
code *
errorLine *

callMethod(name, argv, expandParameters, parentObject)

Execute a method with the given name and arguments.

Parameters
name *
argv *

must be an array with parameters, unless skip_expand is true

expandParameters *
parentObject *

compile(argVars, saveContextVars)

Compiles the string, trys to keep the current state

Parameters
argVars Object
saveContextVars *

hasMethod(name) → bool

Does this script contains this method?

Parameters
name String

The name of the method.

Returns
bool

True if the script has the method.