Repository navigation
Lua Script API: Scripting & File Functions
Adds a Lua script into the game.
-
path- The location of the Lua script file to be added. -
ignoreAlreadyRunning- An optional parameter, It will execute while ignoring the Lua script that it's running from.
Removes a Lua script into the game, can be used for improving performaces for crappy computers.
-
path- The location of the Lua script file to be removed.
Checks if the Lua script is currently running; Returns a boolean.
-
luaFile- The location of the Lua script file to be used.
Sets the current global variable from another Lua script with a new value.
Note: The
globalparameter can only get global variables and not local variables.
-
luaFile- The location of the Lua script file to be used. -
global- The variable inside the Lua script to get. -
val- The new value to be set.
Gets the current global variable from another Lua script current value; Returns a variable value.
-
luaFile- The location of the Lua script file to be used. -
global- The variable inside the Lua script to get.
Checks if multiple Lua scripts are current running; Returns a table.
Imports haxe librarys into the interpreter. Basically an import statement in Haxe which imports specific packages into Haxe like sprites, text, tweens, etc.
-
libName- The library name. -
libPackage- An optional parameter, The library package.
Examples:
- Imports the sound library:
addHaxeLibrary('FlxSound', 'flixel.system') - Imports shader filters:
addHaxeLibrary('ShaderFilter', 'openfl.filters') - Imports CoolUtil:
addHaxeLibrary('CoolUtil')
In Haxe:
package; // they are directories that contain modules, i dunno how it works; but very important to use.
// import library_package.library_name | <-- Thats the syntax
import flixel.system.FlxSound; // Imports the sound package
import openfl.filters.ShaderFilter; // Imports the shader filter package
import CoolUtil; // Imports CoolUtil haxe file, i think
// Also the semi colon ';' character is very important when declaring functions, packages, variables, etc.Executes the haxe code.
-
codeToRun- The haxe code to be run, use double brackets[[]].
Example:
function onCreatePost()
addHaxeLibrary('FlxText', 'flixel.text')
addHaxeLibrary('FlxG', 'flixel')
runHaxeCode([[
var textContent = ['Among us', 'This is a Text', 'Haxe is kinda cool'];
var textDisplay = new FlxText(0, 0, 0, textContent[ FlxG.random.Int(0, 2) ], 35, false); // makeLuaSprite
textDisplay.cameras = [game.camHUD]; // setObjectCamera
textDisplay.screenCenter(); // screenCenter
game.add(textDisplay); // addLuaText
]])
endNote: These functions are only located inside the
runHaxeCodefunction. Meaning they are Haxe functions, strange right.
Sets the current Haxe global variable with a new value. Or initializes the creation of the Haxe global variable.
-
name- The name of the global variable to be used. -
value- The specific value to be used, Like anArray,String,Number, etc.
Example:
Here, the setVar() function will initializes the creation of an array, with the tag textStuff. With the getVar() function getting the value of the array of Yes string.
function onCreatePost()
addHaxeLibrary('FlxText', 'flixel.text')
runHaxeCode([[
setVar('textStuff', ['Yes', 'No', 'Maybe']);
var textDisplay = new FlxText(0, 0, 0, getVar('textStuff')[0], 35, false);
textDisplay.cameras = [game.camHUD];
textDisplay.screenCenter();
game.add(textDisplay);
]])
endGets the current Haxe global variable current value, it can be inside the runHaxeCode() function or another runHaxeCode() function.
-
name- The name of the global variable to be used.
Example:
Here, the getVar() function will get the textStuff global variable array from another runHaxeCode() function.
function onCreatePost()
addHaxeLibrary('FlxText', 'flixel.text')
runHaxeCode([[ setVar('textStuff', ['Yes', 'No', 'Maybe']); ]])
runHaxeCode([[
var textDisplay = new FlxText(0, 0, 0, getVar('textStuff')[1], 35, false);
textDisplay.cameras = [game.camHUD];
textDisplay.screenCenter();
game.add(textDisplay);
]])
endRemoves The Haxe global variable, if not used anymore.
-
name- The name of the global variable to be removed.
Example:
Here, the removeVar() function will remove the global variable textStuff from another runHaxeCode() function. This will return a null value in Haxe, if called. So the text wont appeared becuase of the null value.
function onCreatePost()
addHaxeLibrary('FlxText', 'flixel.text')
runHaxeCode([[
setVar('textStuff', ['Yes', 'No', 'Maybe']);
removeVar('textStuff');
]])
runHaxeCode([[
var textDisplay = new FlxText(0, 0, 0, getVar('textStuff')[2], 35, false);
textDisplay.cameras = [game.camHUD];
textDisplay.screenCenter();
game.add(textDisplay);
]])
endGets the text content from a txt file.
-
path- The location of thetxtfile to be used; Starts outside themodfolder by defualt.
Gets the contents of the folder; Returns a table.
-
folder- The location of the folder to be used; Starts outside themodfolder by defualt.
Changes the specific file contents and saves it.
-
path- The location of the file to be change -
content- The file contents to be changed or modified, use double brackets[[]]. -
absolute- An optional parameter, It will be ignore by the mod folder directory, causing it to be outside the mod folder.
Deletes the specific file.
-
path- The location of the file to be deleted.
Checks if the file exist or not.
-
filename- The location of the Lua script file to be used. -
absolute- An optional parameter, It will be ignore by the mod folder directory, causing it to be outside the mod folder.
Checks if the sprite object exist inside the stage or script; Returns a boolean.
-
tag- The sprite object tag name to be used.
Checks if the text object exist inside the stage or script; Returns a boolean.
-
tag- The text object tag name to be used.
Checks if the sound object exist inside the stage or script; Returns a boolean.
-
tag- The sound object tag name to be used.
Initializes/Creates the save data making it able to be called anywhere. This function is recommended to be place above the save data functions for obvious reasons.
-
name- The name of the save data to be used. -
folder- An optional parameter, The folder to be loaded or be created.
Deletes the save data, if not used anymore; Returns a nil value.
-
name- The name of the save data to be used.
Sets the current data field with a new value. Or creates a data field with a specify value of the data field.
-
name- The name of the save data to be used. -
field- The name of the data field to be used. -
value- The new value to be set or the specific value to be used, Like anArray,String,Number, etc.
Gets the current data field current value; Returns the data field value.
-
name- The name of the save data to be used. -
field- The name of the data field to be used.
Checks the specific starting section of the string; Returns a boolean.
-
str- The string to be used. -
start- The starting section to be called.
Checks the specific ending section of the string; Returns a boolean.
-
str- The string to be used. -
end- The starting section to be called.
Splits the string into multiple strings; Returns a table.
-
str- The string to be used.
Removes any whitspaces from the string. Or could just use this (string):gsub('% ', '') it functions just the same. So this function is now confirmed useless.
-
str- The string to be used.
Randomizes the Int number from min to max values.
-
min- The lowest/starting value. -
max- The highest/ending value.
Randomizes the Float number from min to max values.
-
min- The lowest/starting value. -
max- The highest/ending value.
Randomizes the chances of returning a true value.
-
chance- The percent of it beingtrue; Goes from0to100.
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