Using Lua with Ziron
The latest release of Ziron 2.0.0.11 contains a lua include (experimental)
You will need to download the Lua DLL
Here is a quick example of loading a lua script:
program PE32_CUI 'test';
#include 'win_def.zir';
#include 'console.zir';
#include 'lua/lua.zir';
lua_state* L;
lua_loadlib('lua52-32.dll');
L = luaL_newstate();
luaL_openlibs(L);
eax = luaL_loadfile(L, 'script.lua', nil);
if (eax != 0) {
ecx = lua_tostring(L, -1);
print('Couldn\'t load file: ',[char*]ecx,'\n');
} else {
// Ask Lua to run our little script
eax = lua_pcall(L, 0, LUA_MULTRET, 0);
if (eax != 0) {
ecx = lua_tostring(L, -1);
print('Failed to run script: ',[char*]ecx,'\n');
} else {
lua_pop(L, 1); // Take script return value out of the stack
}
}
lua_close(L);
lua_freelib();
wait_key();
ExitProcess(0);
A very super simple script:
--
-- Sample lua script for Ziron
--
print("Hello World!");
n = 1
while n <= 20000 do
print("Hello, World "..n.."!");
n = n + 1
end;