Class used for scripting.

Static variables

@:value(null)staticcurScript:Script = null

Currently executing script.

@:value(["hx", "hscript", "hsc"])staticscriptExtensions:Array<String> = ["hx", "hscript", "hsc"]

All available script extensions

Static methods

staticcreate(path:String):Script

Creates a script from the specified asset path. The language is automatically determined.

Parameters:

path

Path in assets

staticgetDefaultVariables():Map<String, Dynamic>

Constructor

new(path:String)

Creates a new instance of the script class.

Parameters:

null

path

Variables

fileName:String

Script name (with extension)

@:value(null)path:String = null

Path to the script.

Methods

call(func:String, ?parameters:Array<Dynamic>):Dynamic

Calls the function func defined in the script.

Parameters:

func

Name of the function

parameters

(Optional) Parameters of the function.

Returns:

Result (if void, then null)

error(text:String, ?additionalInfo:Dynamic):Void

Shows an error from this script.

Parameters:

text

Text of the error (ex: Null Object Reference).

additionalInfo

Additional information you could provide.

get(variable:String):Dynamic

Gets the variable variable from the script's variables.

Parameters:

variable

Name of the variable.

Returns:

Variable (or null if it doesn't exists)

load():Void

Loads the script

onCreate(path:String):Void

onDestroy():Void

onLoad():Void

set(variable:String, value:Dynamic):Void

Gets the variable variable from the script's variables.

Parameters:

variable

Name of the variable.

Returns:

Variable (or null if it doesn't exists)

setParent(variable:Dynamic):Void

Sets a script's parent object so that its properties can be accessed easily. Ex: Passing PlayState.instace will allow boyfriend to be typed instead of PlayState.instance.boyfriend.

Parameters:

variable

Parent variable.