#include <stdio.h> #ifdef __cplusplus extern "C" { #endif #include <lua.h> #include <lualib.h> #include <lauxlib.h> #ifdef __cplusplus } #endif int main( int argc, char** argv ) { lua_State* L = lua_open(); luaL_openlibs(L); int error = luaL_dofile(L, "script.lua"); if(error) { fprintf(stderr, "%s", lua_tostring(L, -1)); lua_pop(L, 1); } else { lua_getglobal(L, "main"); lua_pushstring(L, argv[1]); lua_call(L, 1, 0); } lua_close(L); return 0; }