Files
While loading a plugin only executes a main.lua file, additional files can be loaded and it is generally very good idea to structure your code into multiple files.
fileExists function
Checks whether a file exists by relative path from the Lua file.
Syntax:
bool fileExists( string path )Example:
if(fileExists("other.lua"))then
print("It exists!")
endreadFile function
Read all content of a text file.
Syntax:
string readFile( string path )writeFile function
Write text into a file, replacing all previous content.
Syntax:
bool writeFile( string path, string content )appendFile function
Write text into a file, adding it after all existing content.
Syntax:
bool appendFile( string path, string content )getFilePath function
Returns path of the current file relative to the specific plugin's folder.
Syntax:
string getFilePath()Example:
print(getFilePath()) -- "main.lua"include function
Loads additional Lua file by relative path. Table can be returned from the other script to serve as a module. Inheritance will also work.
This can also be used inside a function for asynchronous load of code, which allows for custom hot loading of various parts of code.
Syntax:
mixed include( string path )Example:
local module = include("other.lua")