Beispiel #1
0
static void iuplua_openlibs(lua_State *L) 
{
  lua_pushliteral(L, LUA_COPYRIGHT);
  lua_setglobal(L, "_COPYRIGHT");  /* set global _COPYRIGHT */

  /* iuplua initialization */
  iuplua_open(L);

#ifdef USE_STATIC
  /* disable require */
  iuplua_dostring(L, "function require() end ", "static_require");

#ifdef IUPLUA_IMGLIB
  luaopen_iupluaimglib(L);
#endif
#ifdef IUPLUA_TUIO
  iuptuiolua_open(L);
#endif
#ifdef IUPLUA_WEB
  iupweblua_open(L);
#endif
#ifdef IUPLUA_SCINTILLA
  iup_scintillalua_open(L);
#endif

/* luaopen_lfs(L); */

#ifndef IUPLUA_NO_GL
  iupgllua_open(L);
  iupglcontrolslua_open(L);
#ifdef USE_LUAGL
  luaopen_luagl(L);
#endif
#endif
#ifndef IUPLUA_NO_CD
  iupcontrolslua_open(L);
  iupmatrixexlua_open(L);
  iup_plotlua_open(L);
  cdlua_open(L);
  cdluaiup_open(L);
  cdInitContextPlus();
#endif
#ifndef IUPLUA_NO_IM
  iupimlua_open(L);
  imlua_open(L);
  imlua_open_process(L);
#endif
#ifndef IUPLUA_NO_IM
#ifndef IUPLUA_NO_CD
  cdluaim_open(L);
#endif
#endif
#endif
}
Beispiel #2
0
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;
}
Beispiel #3
0
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;
}