If you want to use this language, then start your program with a #!lua
line.
#!lua
-- global variables
acounter = 123
anumber = 3.1415
anaddress = 0x0048C
astring = "something"
anarray = {}
-- Things to do on startup
function setup()
-- local variables
iamlocal = 234
end
-- Things to run for every frame, at 60 FPS
function loop()
-- Lua style print
print("I", "am", "running")
-- Get MEG-4 style outputs
printf("a counter %d, left shift %d\n", acounter, getkey(KEY_LSHIFT))
end
Unlike the other languages, this isn't integral part of MEG-4, rather provided by a thrid party library. Due to that it does not (and cannot) have perfect integration (no debugger and no translated error messages for example). Its runner is bloated and much slower compared to the other languages, but it works, and you can use it.
The embedded version is Lua 5.4.7, with modifications. For security reasons it lacks concurrency, as well as module loading,
file access, pipes, command execution. The coroutine
, io
and os
modules and their functions aren't available (but the
language features and all the other parts of the baselib are still there). Instead of these missing tables, it has the MEG-4 API,
which can be used as in any other language (with some slight, minor differences for better integration).
If you're interested in this language then you can find more information in the Programming in Lua documentation.
MEM_USER
(0x30000) and just simply use the data in the returned Lua table.numnpc
and npc
) one single Lua table (with each element being another table) can be used.