-
Notifications
You must be signed in to change notification settings - Fork 1
Lua functions
Piotr Halama edited this page Aug 14, 2025
·
21 revisions
Table of libraries and their function All functions are called as library.fucntionName() from Lua, except the bace ones (error, next, etc.)
Standard Lua libraries: str is something like a const char*
base functions & libraries
- base functions - some functions were cut, e.g.
require()error()getmetatable()setmetatable()getfenv()setfenv()next()ipairs()pairs()print()toint()tostring()type()assert()unpack()rawequal()rawget()rawset()pcall()xpcall()collectgarbage()gcinfo()loadstring()- missing function -
require()
-
coroutine- loaded as a part ofbasecreate()wrap()resume()yield()status()
-
tableconcat()foreach()foreachi()getn()setn()sort()insert()remove()
-
stringlen()sub()lower()upper()char()rep()byte()format()dump()find()gfind()gsub()
-
debuggsub()getlocal()getinfo()gethook()getupvalue()sethook()setlocal()setupvalue()debug()traceback()
Non-standard libraries:
-
gl-
SelectOSDMode(str mode)- possible modes:
844,655,4444,4633
- possible modes:
BeginScene()EndScene()int CreateOverlayFromTexture(int i)FreeOverlay(int i)int LoadTexture(int i, str s)FreeTexture(int i)AddTextureToOverlay(int i, int j)RemoveTextureFromOverlay(int i, int j)SetTextureActiveFrame(int i, int j)SetClipInfo(int i, int j, int k, int l, int m)-
SetParameters(int i, int j, int k, int l, int m)- identical to the
SetClipInfo()
- identical to the
SetZorder(int i, int j)SetVisibility(int i, int j)SetPosition(int i, int j, int k)int GetZorder(int i)int GetVisibility(int i)int, int GetPosition(int i)int, int GetSize(int i)ClearOSD()Show(int i)int HasAnimations(int i)DeleteAllAnimations(int i)AddPositionAnimation(int i, int j, int k, int l, int m, int n, int o)AddVisibilityAnimation(int i, int j, int k)AddParabolaAnimation(int i, int j, int k, int l, int m, int n, int o, int p, int q, int r, int s, int t)AddBlinkingAnimation(int i, int j, int k, int l, int m)AddAlphaAnimation(int i, int j, int k, int l)-
CreateTextureAnimation(int i, int j, int [][]t)- TODO tables, I don't know if I read this correctly
- expects a table of 11 tables of 3 ints,
int [11][3]
int CreateEmptyTexture(int i, int j, str s)-
BlitOverlay(int i, int j, int k, int l)- with optional
int mandint n
- with optional
-
BlitOverlayWithCR(int i, int j, int k, int l)- with optional
int m,int n, mnopqrstuvw
- with optional
SetTextureAlphaLevel(int i, int j)
-
-
rm- Resource Manager-
int OpenResource(str path)- loads resource s and returns ID of the loaded resource.
- For directories the path has to begin and end with
/.
CloseResource(int i)lightUserData, int LoadFile(int i, str s)UnloadFile(int i, userData u)
-
-
timeint GetRealTime()Sleep(int ms)
-
log-
Log(int level, str message)- prints somewhere if level is lower or equal to currently set log level
-
SetLevel(int level)- sets logging level (default is ???)
- LOG_NONE - 0
- LOG_CRITICAL - 1
- LOG_IMPORTANT - 2
- LOG_NORMAL - 3
- LOG_VERBOSE - 4
- LOG_DEBUG - 5
SetModule(int i, int j)-
PrintRaw(str message)- prints somewhere if sebug state is enabled
-
PrintLine(str message)- prints somewhere
-
DebugSetState(int enabled)- sets debug state 0/1
-
PrintRawworks only ifenabledis non-zero
-
-
pointer-
lightUserData *CreateUserData(int size)- probably allocs
sizebytes of space
- probably allocs
-
DestroyUserData(userData u)- empty func???? str ToString(userData u)-
str ToStringRange(userData u, int min, int max)- returns
[min, max)bytes of data
- returns
lightUserData FromString(str s)int GetIndex(userData u, int i)int GetU32MSB(userData u, int i)SetU32MSB(userData u, int i, int j)int GetU32LSB(userData u, int i)SetU32LSB(userData u, int i, int j)str ByteToAscii(int i)int AsciiToByte(str s)
-
-
zmath- there is no standardmathlibrary includedint Mod(int i, int j)-
int Rand(int min, int max)- gets random int that
min <= n <= max- TODO check if this is correct
- gets random int that
-
RandSeed(int i)- initializes Rand, seed can be set to time.GetRealTime()
-
inputClearKeyQueue()int, int, int GetKey()int, int, int WaitForKey()int EnableRemotes()int DisableRemotes()-
SetMode(int mode)- known modes: 0 - 4, defaults to 0
int GetMode()SetQueueSize(int size)-
SetRandomKeysTable(int []t)- I have no idea if I read this function correctly, or how many elelkemts in a table is expected (4?)
-
iframeint Load(int resID, str filename)Unload(int id)Show(int i)-
ShowPredefined(int i)- i==0 might be different from the rest?
- only VeggieTales uses this function apparently -
ShowPredefined(2) - possible known files
- 0 -
game_wave.m2v? - GameWave logo screen - 1 -
insert_disc.m2v? - "Please insert disc...` screen - 2 -
launching.m2v-Launching game...orStarting game...screen, depending on the engine version
- 0 -
Clear()
-
engineZMM_SetLeakDebugMode(int enabled)ZMM_SetCheckPoint()ZMM_VerifyCheckPoint()int ZMM_GetTotalAllocMemory()int ZMM_GetTotalFreeMemory()int ZMM_GetMaxFreeMemory()DR_SetEnable(int i)DR_SetDebug(int i)DR_SetAbsoluteCapping(int i, int j, int k)DR_ClearPairCappings(int i, int j, int k)DR_AddPairCapping()OpenTray()CloseTray()-
EjectTray()- exactly the same as
OpenTray()
- exactly the same as
int GetTrayState()SoftwareReset()WaitForDisk()int GetNumOverlays()int GetNumTextures()-
str Version()- returns something like
1.01.3.xxxxxx
- returns something like
-
SetLineTraceMode(int enabled)- expects 0/1
int GetLineTraceMode()
-
textint RenderSimple(int i, str s)-
Render(str s, int i, int j, int k)- possible 10 optional args????
Remove(int i)int GetOverlayId(int i)
-
fontint Load(int loc, str filepath)Free(int i)-
int GetBuiltinFontID()- the builtin font is called
f_1955_s_22_m_4633_32_128.dat
- the builtin font is called
-
movie-
int Load(str path)- path is a full name,
moviedoesn't usermlibrary
- path is a full name,
SetLoop(int i)Play()Stop(int i)Resume()-
int GetState()- returns 0 if it's still playing, needs to be checked in a loop
-
-
audioint Load(int i, str s)Unload(int i)Play(int i , int j)
-
spiint Init()int Open()int Close()int Write(userData u, int i,int j)lightUserData Read(int i, int j)
-
uartstr RxD()int TxD(str s, int i)-
int Open()- returns 1, does nothing
-
int Close()- returns 1, does nothing
-
eeprombool SaveGameToNewSlot(int i, int j, str s, str s2, userData u)str, str, bool GetSaveNameByID(int i,)lightUserData, bool LoadSaveByID(int i)UnloadData(userData u)bool SaveGameToExistingSlot(int i, userData u)-
int, bool EnumerateGameSavesByID(int i)- returns
number_of_slots, 0
- returns
-
int, bool EnumerateGameSavesByName(str s)- returns
number_of_slots, 0
- returns
Format()CorruptFlash()int CheckFlashIntegrity()
-
zfile-
int OpenFile(str path)- doesn't use
rm - optional
int iandint locarguments, defaults to 0 -
iis checked against 0 and -1 (and else) -
locis only used when i is not 0 or -1,lochas to beloc >= 0, seedict.Load() - returns -1 on error
- doesn't use
-
lightUserData ReadBytes(int i, int j, int k)- can return
nil - returns buffer; to free memory use
pointer.DestroyUserData(buffer)after closing / after read
- can return
-
int, str ReadLine(int i)- returned int is set to
0if string is returned - returned int is set to
1ifnilis returned
- returned int is set to
int SetHeadPosition(int i, int j)int GetFileSize(int id)int CloseFile(int id)
-
-
dict-
lightUserData Load(int loc, str filename)-
locmight be place where to load files from (DVD, HDD etc.) - filename contains
.zdtextension
-
Unload(userdata i)bool Lookup(userdata i, str s)
-
-
exp_int- there are mentions of INT port whatever it isint Configure(bool i)int Close()int Test()
-
bit-
int bnot(int i)- not -
int band(int i, ...)- and -
int bor(int i, ...)- or -
int bxor(int i, ...)- xor int lshift(int i, int j)-
int rshift(int i, int j)- looks like unsigned right shift -
int arshift(int i, int j)- looks like signed right shift int mod(int i, int j)
-