int main(int argc, char *argv[]) { QApplication a(argc, argv); qApp->setApplicationName( QObject::tr("X Toolbox")); QTranslator * translator = new QTranslator(); translator->load(":chs.qm"); if(QLocale::system().language() == QLocale::Chinese) QApplication::instance()->installTranslator(translator); int ret = 0; lua_State* L = lua_open(); luaL_openlibs(L); luaopen_luagl(L); luaopen_luaglu(L); register_classes(L); MainWindow w; w.show(); //run_script_init(0); ret = a.exec(); //lua_close(L); return ret; }
int ex_lua_init () { // if the core already initialized, don't init it second times. if ( __initialized ) { ex_warning ( "the lua-interpreter already initialized." ); return 1; } ex_assert_return( __L == NULL, 1, "the lua status already opened." ); __L = lua_open(); luaL_openlibs(__L); // open default libs // OPTME { // clear the package.path and package.cpath ex_lua_dostring ( __L, "package.path = \"\"" ); ex_lua_dostring ( __L, "package.cpath = \"\"" ); // NOTE: we don't need any search path. // in exsdk, require("module") is deprecated all script load as module. // clear the package.path and package.cpath ex_lua_dostring ( __L, "package.path = \"./?.lua\"" ); ex_lua_dostring ( __L, "package.cpath = \"./?.so;./?.dll\"" ); { char **mounts = ex_fsys_mounts(); char **i; for ( i = mounts; *i != NULL; ++i ) { ex_lua_add_path( __L, *i ); ex_lua_add_cpath( __L, *i ); } ex_fsys_free_list(mounts); } // } OPTME end // init graphics wraps #if ( EX_PLATFORM != EX_IOS ) lua_settop ( __L, 0 ); // clear the stack luaopen_luagl (__L); luaopen_luaglu (__L); #endif // we create global ex table if it not exists. ex_lua_global_module ( __L, "ex" ); // init ex lua luaopen_ex (__L); // ======================================================== // init core wraps // ======================================================== luaopen_angf (__L); luaopen_vec2f (__L); luaopen_mat33f (__L); luaopen_color3f (__L); luaopen_color4f (__L); // ======================================================== // init engine wraps // ======================================================== luaopen_yield (__L); luaopen_time (__L); // ======================================================== // init engine objects // ======================================================== luaopen_object (__L); luaopen_texture (__L); luaopen_texture2d (__L); luaopen_world (__L); luaopen_entity (__L); luaopen_component (__L); luaopen_trans2d (__L); luaopen_behavior (__L); luaopen_lua_behavior (__L); lua_settop ( __L, 0 ); // clear the stack __initialized = true; return 0; }