//----------------------------------------------------------------// void AKUSetArgv ( char **argv ) { int i; int argc = 0; lua_State* L = AKUGetLuaState (); // count argv while ( argv[argc] ) argc++; lua_createtable ( L, argc, 0 ); int newTable = lua_gettop ( L ); // arg[-1] => host binary (lua, luajit, moai-untz, ...) // arg[0] => first arg (script name as passed to host binary) // arg[1] => next arg/option/script // arg[2] => next arg/option/script // ... for ( i=0; i < argc; i++ ) { lua_pushstring ( L, argv[i] ); lua_rawseti ( L, newTable, i - 1 ); } // same as lua global 'arg' lua_setglobal ( L, "arg" ); }
//----------------------------------------------------------------// void AKUHarnessContextInitialize () { REGISTER_LUA_CLASS ( MOAIHarness ) // Hook lua debug callbacks here lua_State* L = AKUGetLuaState (); MOAIHarness::Get().HookLua ( L, "127.0.0.1", 7018 ); }
//----------------------------------------------------------------// void AKUDebugHarnessInit () { REGISTER_LUA_CLASS ( MOAIHarness ) lua_State* L = AKUGetLuaState (); // Hook lua debug callbacks here MOAIHarness::Get().HookLua(L, "127.0.0.1", 7018); // disable buffering on stdout so that piped output gets flushed immediately setvbuf(stdout, NULL, _IONBF, 0); }
//----------------------------------------------------------------// void AKUSetParticlePreset ( const char* presetTable, const char* presetName, AKUParticleInitFunc initFunc, AKUParticleRenderFunc renderFunc, int size ) { lua_State* L = AKUGetLuaState (); lua_getglobal ( L, presetTable ); if ( lua_isnil ( L, -1 )) { lua_newtable ( L ); lua_setglobal ( L, presetTable ); } lua_getglobal ( L, presetTable ); assert ( lua_isnil ( L, -1 ) == false ); AKUNewParticlePlugin ( L, initFunc, renderFunc, size ); lua_setfield ( L, -2, presetName ); lua_pop ( L, 1 ); }
//----------------------------------------------------------------// void AKUHarnessUpdate () { lua_State* L = AKUGetLuaState (); MOAIHarness::Get ().Update ( L ); }