Repository navigation
Lua Script API: Scripting & File Functions
Adds a Lua script into the game.
-
luaFile- The location of the Lua script to add; Starts inside the mod folder directory. -
ignoreAlreadyRunning- An optional parameter; will execute while ignoring the Lua script that it's running from; Default value:false.
Adds a Haxe script into the game.
-
haxeFile- The location of the Haxe script to add; Starts inside the mod folder directory. -
ignoreAlreadyRunning- An optional parameter; will execute while ignoring the Haxe script that it's running from; Default value:false.
Removes a Lua script into the game.
-
luaFile- The location of the Lua script to remove; Starts inside the mod folder directory. -
ignoreAlreadyRunning- An optional parameter; will execute while ignoring the Lua script that it's running from; Default value:false.
Sets the current global variable with a new value. This will only work if the Lua script that is in, is currently executed; Same works with getGlobalFromScript() function.
-
luaFile- The location for the Lua script to get the given variable. -
global- The global variable given name to set. -
val- The specified value to set in.
Gets the current global variable current value from another Lua script.
-
luaFile- The location for the Lua script to get the given variable. -
global- The global variable given name to get.
Checks if the specific Lua script is currently running, returning true is it's running.
-
luaFile- The location for the Lua script to check.
Returns every currently running scripts.
Sets a Lua variable into global and inserts it to any currently executing Lua script(s).
-
varName- The variable's name to be given. -
arg- The variable's value to be given. -
ignoreSelf- An optional parameter; This will ignore itself within the script that it's in; Defualt value:false. -
exclusions- An optional parameter; The exclusions of Lua scripts, for the function to not insert in.
Example:
function onCreatePost()
setOnLuas('stupidVar1', 'string')
setOnLuas('stupidVar2', 23, true)
debugPrint(stupidVar2) -- will print > nil
endfunction onCreatePost()
debugPrint(stupidVar1) -- will print > 'string'
debugPrint(stupidVar2) -- will print > 23
endsetOnHScript(varName:String, arg:Dynamic, ?ignoreSelf:Bool = false, ?exclusions:Array<String> = null)
Sets a Haxe variable into global and inserts it to any currently executing Haxe script(s).
-
varName- The variable's name to be given. -
arg- The variable's value to be given. -
ignoreSelf- An optional parameter; This will ignore itself within the script that it's in; Default value:false. -
exclusions- An optional parameter; The exclusions of Haxe scripts, for the function to not insert in.
setOnScripts(varName:String, arg:Dynamic, ?ignoreSelf:Bool = false, ?exclusions:Array<String> = null)
Sets a Lua/Haxe variable into global and inserts it to any currently executing Lua/Haxe script(s).
-
varName- The variable's name to be given. -
arg- The variable's value to be given. -
ignoreSelf- An optional parameter; This will ignore itself within the script that it's in; Default value:false. -
exclusions- An optional parameter; The exclusions of Lua/Haxe scripts, for the function to not insert in.
callOnLuas(funcName:String, ?args:Array<Dynamic> = null, ?ignoreStops=false, ?ignoreSelf:Bool = true, ?excludeScripts:Array<String> = null, ?excludeValues:Array<Dynamic> = null)
Calls a Lua function from another currently executing Lua script.
-
funcName- The function's name to be called. -
args- An optional parameter; The arguments of the function to be passed on. -
ignoreStops- An optional parameter; Whether it will ignore returns fromFunction_StopLuaorFunction_StopAll; Default value:false. -
ignoreSelf- An optional parameter; This will ignore itself within the script that it's in; Default value:true. -
excludeScripts- An optional parameter; The exclusions of Lua scripts, for the function to not insert in. -
excludeValues- An optional parameter; The exclusions of the arguments, for the function to not passed on.
Example:
function round(num, dp) -- i stole this
local mult = 10^(dp or 0);
return math.floor(num * mult + 0.5)/mult;
end
function onCreatePost()
callOnLuas('round', {23.532, 2}, false) -- will print > 23.53
endfunction onCreatePost()
callOnLuas('round', {632.1224, 2}) -- will print > 632.12
callOnLuas('round', {381.1213, 3}) -- will print > 381.121
endcallOnHScript(funcName:String, ?args:Array<Dynamic> = null, ?ignoreStops=false, ?ignoreSelf:Bool = true, ?excludeScripts:Array<String> = null, ?excludeValues:Array<Dynamic> = null)
Calls a Haxe function from another currently executing Haxe script.
-
funcName- The function's name to be called. -
args- An optional parameter; The arguments of the function to be passed on. -
ignoreStops- An optional parameter; Whether it will ignore returns fromFunction_StopHScriptorFunction_StopAll; Default value:false. -
ignoreSelf- An optional parameter; This will ignore itself within the script that it's in; Default value:true. -
excludeScripts- An optional parameter; The exclusions of Haxe scripts, for the function to not insert in. -
excludeValues- An optional parameter; The exclusions of the arguments, for the function to not passed on.
callOnScripts(funcName:String, ?args:Array<Dynamic> = null, ?ignoreStops = false, ?ignoreSelf:Bool = true, ?excludeScripts:Array<String> = null, ?excludeValues:Array<Dynamic> = null)
Calls a Lua/Haxe function from another currently executing Lua/Haxe script.
-
funcName- The function's name to be called. -
args- An optional parameter; The arguments of the function to be passed on. -
ignoreStops- An optional parameter; Whether it will ignore returns fromFunction_StopLuaorFunction_StopHScriptorFunction_StopAll; Default value:false. -
ignoreSelf- An optional parameter; This will ignore itself within the script that it's in; Default value:true. -
excludeScripts- An optional parameter; The exclusions of Lua/Haxe scripts, for the function to not insert in. -
excludeValues- An optional parameter; The exclusions of the arguments, for the function to not passed on.
Calls a function from a specific Lua script that is currently executing.
-
luaFile- The location of the Lua script file to get the function; Starts inside the mod folder directory. -
funcName- The function's name to be called. -
args- An optional parameter; The arguments of the function to be passed on.
Returns every folder and files inside the given folder.
-
folder- The location of the folder to locate.
Gets the text content from another file.
-
path- The location of the file to target; Starts inside the mod folder directory. -
ignoreMods- An optional parameter; it will start outside of the mod folder directory if set totrue; Default value:false.
Checks if the file exists inside the game assets, returns true if it exists.
-
filename- The filename given to check if it exists or not. -
absolute- An optional parameter; it will start outside of the mod folder directory if set totrue; Default value:false.
Creates a file, if it doesn't exist or applies all the changes to the file and update its contents.
-
path- The location for the file to create or to save; Starts inside the mod folder directory. -
content- The new contents of the file to be updated, use multi-line strings for this. -
absolute- An optional parameter; it will start outside of the mod folder directory if set totrue; Default value:false.
Deletes a file, literally; nothing else to say here.
-
path- The location for the file to delete; Starts inside the mod folder directory. -
ignoreModFolders- An optional parameter; it will start outside of the mod folder directory if set totrue; Default value:false.
Checks if the sprite object exists inside the game, returns true if it exists.
-
tag- The sprite object tag name to be used.
Checks if the text object exists inside the game, returns true if it exists.
-
tag- The text object tag name to be used.
Checks if the sound exists inside the game, returns true if it exists.
-
tag- The sound tag name to be used.
Initializes the creation of the save data or loads the saved data if it exists. You must use this function first before using other saving data functions. Why? it doesn't exists yet, stupid.
-
name- The save data name to be given. -
folder- An optional parameter; The folder to create or load the save file in; Default value:psychenginemods.
Sets the current save data variable with a new value. If the field save data doesn't exist it will initializes the creation of a save data variable field.
-
name- The save data name to be used. -
field- The save data variable name to be given. -
value- The specified value to set in.
Gets the current save data variable current value.
-
name- The save data name to be used. -
field- The save data variable name to get.
Applies all the changes to the saved file and updates it with new values.
-
name- The save data name to be used.
Checks if the string begins with the specified pattern, returning true if detected.
-
str- The string to be used. -
start- The starting pattern for the string to find.
Checks if the string ends with the specified pattern, returning true if detected.
-
str- The string to be used. -
end- The ending pattern for the string to find.
Splits the string that is determined by the pattern into an array of substrings.
-
str- The string to be split. -
split- The delimeter, the pattern separator for the string to split.
Removes any whitespace it could find from the string. Or you could just use (string):gsub('%s*')
.
-
str- The string to be trimmed.
Randomizes and integer number, determined by the min and max parameters.
-
min- The specified minimum value. -
max- The specified maximum value; Default value:0x7FFFFFFF. -
exclude- An optional parameter; the integer numbers to exclude—each separated by a comma , character.
Randomizes and floating-point number, determined by the min and max parameters.
-
min- The specified minimum value. -
max- The specified maximum value; Default value:1. -
exclude- An optional parameter; the folating-point numbers to exclude—each separated by a comma , character.
Randomizes the chances of returning to true.
-
chance- The numbers of chances to returntrue; Default value:50; Goes from0to100.
Initializes the creation of a playstate variable, if it doesn't exist or sets the current playstate variable with a new value. This will only work if the Lua script that is in, is currently executed; Same works with getVar() function.
-
varName- The playstate variable's name to be given. -
value- The specified value to set in.
Gets the current playstate variable current value.
-
varName- The playstate variable's name to get.
Is the page in some way inaccurate? an error, a typo, or outdated data? To report it, use the "Issue Tab". Or do you wish to include a new function or add new information? use the "Pull Request Tab". Help is always appreciated!
- Event Callbacks
- Custom Sprite
- Custom Text
- Object Functions
- General Functions
- Scripting & File Functions
- Game Input Control Functions
- Language Translation
- HScript Functions
- Custom Substates
- Custom Shaders
- Deprecated & Removed Functions
- Sound & Music Functions
- Tweens & Timers Functions
- Reflection Functions
- Variables