Lua blart

This commit is contained in:
Fierelier 2023-05-15 11:08:45 +02:00
parent 58e0ad8c8b
commit 7e49c6f3d1
4 changed files with 9 additions and 5 deletions

View File

@ -64,7 +64,7 @@ for func in functions:
ofile.write('\n}\n\n') ofile.write('\n}\n\n')
ofile.write('''\ ofile.write('''\
void engine_luaInit() { void engine_lua_init() {
engine_lua_state = luaL_newstate(); engine_lua_state = luaL_newstate();
luaL_openlibs(engine_lua_state); luaL_openlibs(engine_lua_state);
@ -77,7 +77,7 @@ for func in functions:
ofile.write('\tlua_setglobal (engine_lua_state,"' +func+ '");\n') ofile.write('\tlua_setglobal (engine_lua_state,"' +func+ '");\n')
ofile.write('''\ ofile.write('''\
engine_lua_init_manual();
luaL_loadfile(engine_lua_state,"assets/scripts/main.lua"); luaL_loadfile(engine_lua_state,"assets/scripts/main.lua");
lua_call(engine_lua_state,0,0); lua_call(engine_lua_state,0,0);
}''') }''')

2
main.c
View File

@ -10,5 +10,5 @@ int main(int argc, char **argv) {
printf("argv[%d]: %s\n", i, argv[i]); printf("argv[%d]: %s\n", i, argv[i]);
} }
engine_luaInit(); engine_lua_init();
} }

View File

@ -1,6 +1,7 @@
#include <lua5.3/lua.h> #include <lua5.3/lua.h>
#include <lua5.3/lualib.h> #include <lua5.3/lualib.h>
#include <lua5.3/lauxlib.h> #include <lua5.3/lauxlib.h>
#include "lua_manual.c"
lua_State * engine_lua_state; lua_State * engine_lua_state;
int engine_luaf_free(lua_State *L) { int engine_luaf_free(lua_State *L) {
@ -102,7 +103,7 @@ int engine_luaf_texture_from_file(lua_State *L) {
return 0; return 0;
} }
void engine_luaInit() { void engine_lua_init() {
engine_lua_state = luaL_newstate(); engine_lua_state = luaL_newstate();
luaL_openlibs(engine_lua_state); luaL_openlibs(engine_lua_state);
@ -134,7 +135,7 @@ void engine_luaInit() {
lua_setglobal (engine_lua_state,"engine_texture_render_2d"); lua_setglobal (engine_lua_state,"engine_texture_render_2d");
lua_pushcfunction(engine_lua_state,engine_luaf_texture_from_file); lua_pushcfunction(engine_lua_state,engine_luaf_texture_from_file);
lua_setglobal (engine_lua_state,"engine_texture_from_file"); lua_setglobal (engine_lua_state,"engine_texture_from_file");
engine_lua_init_manual();
luaL_loadfile(engine_lua_state,"assets/scripts/main.lua"); luaL_loadfile(engine_lua_state,"assets/scripts/main.lua");
lua_call(engine_lua_state,0,0); lua_call(engine_lua_state,0,0);
} }

View File

@ -0,0 +1,3 @@
void engine_lua_init_manual() {
}