lua_State *L = luaL_newstate();
luaL_openlibs(L);
int test(lua_State *L) {
printf("Hello from C via Lua\n");
return 0;
}
(String ist der Funktionsname in Lua)
lua_register(L, "test", test);
const char lua_script[] = "test()";
int load_stat = luaL_loadbuffer(L, lua_script, strlen(lua_script), lua_script);
lua_pcall(L, 0, 0, 0);
// cleanup
lua_close(L);
return 0;