Psych Engine - Script Functions
Psych Engine Logo
Psych Engine - Lua Script API

Script Functions

Functions that allow you to "communicate" between scripts and HScript.


getRunningScripts

Usage: getRunningScripts()

Returns a table with the path of all Lua Scripts running.


callScript

callScript(luaFile:String, funcName:String, ?args:Array<Dynamic> = null):Dynamic

Calls a function only in a specific Lua Script.
Returns the value returned by the function called (Could be literally anything depending on context).

Examples:


addLuaScript

addLuaScript(luaFile:String, ?ignoreAlreadyRunning:Bool = false):Void

Initializes a specific Lua Script found at the path.

Examples:


addHScript

addHScript(scriptFile:String, ?ignoreAlreadyRunning:Bool = false):Void

Initializes a specific HScript found at the path.

Examples:


removeLuaScript

removeLuaScript(luaFile:String):Bool

Stops a specific Lua Script running.
Returns true if the Script was found and was running.

Examples:


removeHScript

removeHScript(scriptFile:String):Bool

Stops a specific HScript running.
Returns true if the Script was found and was running.

Examples:


isRunning

isRunning(scriptFile:String):Bool

Checks if a specific Lua Script/HScript is running.

Examples:


setVar

setVar(varName:String, value:Dynamic):Dynamic

Stores a variable, allowing all Lua Scripts and HScript to access it through "getVar".
Returns the value that was inserted.

Examples:


getVar

getVar(varName:String):Dynamic

Returns the named stored variable.

Examples:


setOnScripts

setOnScripts(varName:String, value:Dynamic, ?ignoreSelf:Bool = false, ?exclusions:Array<String> = null):Void

Saves/Overwrites a global variable to all Lua Script/HScript running currently.
This differs from "setVar" because you won't need a function like "getVar" to get the variable and it will not have its value shared between scripts.

Examples:


setOnLuas

setOnLuas(varName:String, value:Dynamic, ?ignoreSelf:Bool = false, ?exclusions:Array<String> = null):Void

Structurally identical to "setOnScripts", but it does not insert the variable into HScripts running.


setOnHScript

setOnHScript(varName:String, value:Dynamic, ?ignoreSelf:Bool = false, ?exclusions:Array<String> = null):Void

Structurally identical to "setOnScripts", but it does not insert the variable into Lua Scripts running.


callOnScripts

callOnScripts(funcName:String, ?args:Array<Dynamic> = null, ?ignoreStops:Bool = false, ?ignoreSelf:Bool = true, ?excludeScripts:Array<String> = null, ?excludeValues:Array<Dynamic> = null):Dynamic

Calls a function in all Lua Scripts and HScript running.
Returns the value returned in the function, unless you add this value to "excludeValues".

Examples:


callOnLuas

callOnLuas(funcName:String, ?args:Array<Dynamic> = null, ?ignoreStops:Bool = false, ?ignoreSelf:Bool = true, ?excludeScripts:Array<String> = null, ?excludeValues:Array<Dynamic> = null):Dynamic

Structurally identical to "callOnScripts", but it does not call the function in HScripts.


callOnHScript

callOnHScript(funcName:String, ?args:Array<Dynamic> = null, ?ignoreStops:Bool = false, ?ignoreSelf:Bool = true, ?excludeScripts:Array<String> = null, ?excludeValues:Array<Dynamic> = null):Dynamic

Structurally identical to "callOnScripts", but it does not call the function in Lua Scripts.


runHaxeCode

runHaxeCode(codeToRun:String, ?varsToBring:Any = null, ?funcToRun:String = null, ?funcArgs:Array<Dynamic> = null):Void

Runs HScript code inside a Lua Script by initializing a HScript Interpreter for the Lua Script.

Examples:

Note: Do not use "runHaxeCode" every frame! Instead, put your code in functions and call them with "runHaxeFunction" after running runHaxeCode atleast once.


runHaxeFunction

runHaxeFunction(funcToRun:String = null, ?funcArgs:Array<Dynamic> = null):Void

Calls a function inside a code ran previously with "runHaxeCode".

Examples: