void registerMessageFunctions(LuaState* state) { LuaObject globals = state->GetGlobals(); globals.Register("message_post", &message_post); globals.Register("message_reader_show", &message_reader_show); globals.Register("message_reader_select_new", &message_reader_select_new); }
void registerGameFunctions(LuaState* state) { LuaObject globals = state->GetGlobals(); globals.Register("game_mission_selector", &game_mission_selector); globals.Register("game_load", &game_load); globals.Register("game_save", &game_save); globals.Register("game_quit", &game_quit); }
void registerConfigFunctions(LuaState* state) { LuaObject globals = state->GetGlobals(); globals.Register("config_distribution_standard", &config_distribution_standard); globals.Register("config_distribution_complete", &config_distribution_complete); }
LuaManager::LuaManager() : consumer(NULL) { luaState = LuaState::Create(); LuaObject globals = luaState->GetGlobals(); #ifndef SELF_TEST globals.Register("Module", &Parser::parseModule); globals.Register("SoundEffect", &Parser::parseSoundEffect); globals.Register("Ambient", &Parser::parseAmbient); globals.Register("Track", &Parser::parseTrack); globals.Register("Mission", &Parser::parseMission); globals.Register("Trigger", &Parser::parseTrigger); globals.Register("Message", &Parser::parseMessage); globals.Register("Campaign", &Parser::parseCampaign); registerGameFunctions(luaState); registerDRMFunctions(luaState); #endif scriptPatterns.push_back("*.lua"); if(ResourceGroupManager::getSingletonPtr() != NULL) ResourceGroupManager::getSingletonPtr()->_registerScriptLoader(this); }
void registerMissionFunctions(LuaState* state) { LuaObject globals = state->GetGlobals(); globals.Register("mission_get_credits", &mission_get_credits); globals.Register("mission_set_credits", &mission_set_credits); globals.Register("mission_credit_transaction", &mission_credit_transaction); globals.Register("mission_is_solvent", &mission_is_solvent); globals.Register("mission_enable_module", &mission_enable_module); globals.Register("mission_disable_module", &mission_disable_module); globals.Register("mission_is_module_enabled", &mission_is_module_enabled); globals.Register("mission_enable_all_modules", &mission_enable_all_modules); globals.Register("mission_set_time", &mission_set_time); globals.Register("mission_complete", &mission_complete); }
CRemoteLuaDebuggerDoc::CRemoteLuaDebuggerDoc() { m_state = LuaState::Create(); LuaObject globalsObj = m_state->GetGlobals(); globalsObj.Register("DebugSendFile", Script_DebugSendFile); globalsObj.Register("DebugSetLocation", Script_DebugSetLocation); globalsObj.Register("DebugUpdateLocals", Script_DebugUpdateLocals); globalsObj.Register("DebugUpdateWatch", LS_DebugUpdateWatch ); globalsObj.Register("DebugUpdateCallStack", Script_DebugUpdateCallStack); globalsObj.Register("DebugOutput", Script_DebugOutput); globalsObj.Register("LuaServerConnect", Script_LuaServerConnect); globalsObj.Register("LuaDebuggerConnect", Script_LuaDebuggerConnect); const DWORD LUA_DEBUGGER_PORT = 3536; theApp.GetNetworkClient().Open("LuaDebugger", CStringA(theApp.m_pszRegistryKey), m_state->GetCState(), NULL, LUA_DEBUGGER_PORT); }
extern "C" LUAMODULE_API int luaopen_bit(lua_State* L) { LuaState* state = LuaState::CastState(L); LuaObject obj = state->GetGlobals().CreateTable( "bit" ); obj.Register("bnot", int_bnot); obj.Register("band", int_band); obj.Register("bor", int_bor); obj.Register("bxor", int_bxor); obj.Register("lshift", int_lshift); obj.Register("rshift", int_rshift); obj.Register("arshift", int_arshift); obj.Register("mod", int_mod); obj.Register("help", LS_help); return 0; }
void ScriptFunctionsRegister(struct lua_State* L) { LuaState* state = lua_State_To_LuaState(L); LuaObject globalsObj = state->GetGlobals(); globalsObj.Register("GetTickCount", LS_GetTickCount); #if defined(_MSC_VER) && defined(WIN32) && !defined(_XBOX) && !defined(_XBOX_VER) && !defined(PLATFORM_PS3) #elif defined(__APPLE__) char modulePath[MAXPATHLEN + 1]; unsigned int path_len = MAXPATHLEN; _NSGetExecutablePath(modulePath, &path_len); char* slashPtr = strrchr(modulePath, '/'); slashPtr++; *slashPtr = 0; #endif // _MSC_VER state->GetGlobals().Register("LuaDumpGlobals", LS_LuaDumpGlobals); state->GetGlobals().Register("LuaDumpObject", LS_LuaDumpObject); state->GetGlobals().Register("LuaDumpFile", LS_LuaDumpFile); }
void registerStationFunctions(LuaState* state) { LuaObject globals = state->GetGlobals(); globals.Register("station_get_name", &station_get_name); globals.Register("station_set_name", &station_set_name); globals.Register("station_add_module", &station_add_module); globals.Register("station_count_modules", &station_count_modules); globals.Register("station_get_modules", &station_get_modules); globals.Register("station_save_as_group", &station_save_as_group); globals.Register("station_save_group", &station_save_group); globals.Register("station_load_group", &station_load_group); }
extern "C" LUAMODULE_API int luaopen_dotnet(lua_State* L) { LuaState* state = LuaState::CastState(L); LuaObject obj = state->GetGlobals()["dotnet"]; if (obj.IsTable()) return 0; obj = state->GetGlobals().CreateTable( "dotnet" ); char path[ _MAX_PATH ]; #ifdef _DEBUG const char* dllName = "ldotnet.dlld"; #else !_DEBUG const char* dllName = "ldotnet.dll"; #endif _DEBUG GetModuleFileName(GetModuleHandle(dllName), path, _MAX_PATH); char* slashPtr = strrchr( path, '\\' ); slashPtr++; *slashPtr = 0; #ifdef _DEBUG strcat(path, "Debug\\"); #endif _DEBUG strcat(path, "dotnetinterface.dll"); Assembly* assembly = Assembly::LoadFrom(path); Type* type = assembly->GetType("LuaInterface.Lua"); Object* parms[] = new Object*[1]; parms[0] = __box((IntPtr)state->GetCState()); Object* lua = Activator::CreateInstance(type, parms); LuaObject metaTableObj; metaTableObj.AssignNewTable(state); metaTableObj.Register("__gc", GCHandle_gc); LuaObject dotNetObj = state->NewUserDataBox((void*)(GCHandle::op_Explicit(GCHandle::Alloc(lua))).ToInt32()); dotNetObj.SetMetaTable(metaTableObj); obj.SetObject("__dotNetUserData", dotNetObj); return 0; }
void ScriptFunctionsRegister( LuaState* state ) { LuaObject globalsObj = state->GetGlobals(); globalsObj.Register("GetTickCount", LS_GetTickCount); #if defined(_MSC_VER) && defined(WIN32) && !defined(_XBOX) #ifdef _DEBUG const char* luaplusdllName = "LuaPlusD_1100.dll"; #else // _DEBUG const char* luaplusdllName = "LuaPlus_1100.dll"; #endif // _DEBUG char modulePath[MAX_PATH]; GetModuleFileName(GetModuleHandle(luaplusdllName), modulePath, _MAX_PATH); char* slashPtr = strrchr( modulePath, '\\' ); slashPtr++; *slashPtr = 0; #else char modulePath[300]; strcpy(modulePath, ""); #endif // _MSC_VER const char* luaPath = getpath(state->GetCState()); (void)luaPath; state->PushString("LUA_SOPATH="); state->PushString(modulePath); state->PushString("modules/"); state->Concat(3); LuaObject modulePathObj(state, -1); #if !defined(_XBOX) && !defined(_XBOX_VER) && !defined(PLATFORM_PS3) #if defined(_MSC_VER) _putenv(modulePathObj.GetString()); #else putenv((char*)modulePathObj.GetString()); #endif // _MSC_VER #endif // _XBOX state->Pop(); state->PushString("LUA_CPATH="); state->PushString(modulePath); state->PushString("modules/"); #ifdef _DEBUG state->PushString("?.dlld"); #else state->PushString("?.dll"); #endif state->Concat(4); LuaObject modulePath2Obj(state, -1); #if !defined(_XBOX) && !defined(_XBOX_VER) && !defined(PLATFORM_PS3) #if defined(_MSC_VER) _putenv(modulePath2Obj.GetString()); #else putenv((char*)modulePath2Obj.GetString()); #endif // _MSC_VER #endif // _XBOX state->Pop(); LuaObject packageObj = state->GetGlobal("package"); LuaObject pathObj = packageObj["path"]; state->PushString(pathObj.GetString()); state->PushString(LUA_PATH_SEP); state->PushString(modulePath); state->PushString("modules/?.lua"); state->Concat(4); LuaObject newPathObj(state, -1); packageObj.SetString("path", newPathObj.GetString()); state->Pop(); }
extern "C" LUAMODULE_API int luaopen_vdrive(lua_State* L) { LuaState* state = LuaState::CastState(L); LuaObject metaTableObj = state->GetRegistry().CreateTable("VDriveFileHandleMetaTable"); metaTableObj.Register("__gc", VirtualFileHandle_gc); metaTableObj = state->GetRegistry().CreateTable("VDriveMetaTable"); metaTableObj.Register("Create", LS_VirtualDrive_Create); metaTableObj.Register("Open", LS_VirtualDrive_Open); metaTableObj.Register("Close", LS_VirtualDrive_Close); metaTableObj.Register("Flush", LS_VirtualDrive_Flush); metaTableObj.Register("FileCreate", LS_VirtualDrive_FileCreate); metaTableObj.Register("FileOpen", LS_VirtualDrive_FileOpen); metaTableObj.Register("FileClose", LS_VirtualDrive_FileClose); metaTableObj.Register("FileCloseAll", LS_VirtualDrive_FileCloseAll); metaTableObj.Register("FileGetFileName", LS_VirtualDrive_FileGetFileName); metaTableObj.Register("FileGetPosition", LS_VirtualDrive_FileGetPosition); metaTableObj.Register("FileSetLength", LS_VirtualDrive_FileSetLength); metaTableObj.Register("FileGetLength", LS_VirtualDrive_FileGetLength); metaTableObj.Register("FileRead", LS_VirtualDrive_FileRead); metaTableObj.Register("FileWrite", LS_VirtualDrive_FileWrite); metaTableObj.Register("FileErase", LS_VirtualDrive_FileErase); metaTableObj.Register("FileRename", LS_VirtualDrive_FileRename); metaTableObj.Register("FileInsert", LS_VirtualDrive_FileInsert); metaTableObj.Register("FileExtract", LS_VirtualDrive_FileExtract); metaTableObj.Register("Pack", LS_VirtualDrive_Pack); metaTableObj.Register("ProcessFileList", LS_VirtualDrive_ProcessFileList); metaTableObj.Register("GetFileName", LS_VirtualDrive_GetFileName); metaTableObj.Register("GetFileEntryCount", LS_VirtualDrive_GetFileEntryCount); metaTableObj.Register("GetFileEntry", LS_VirtualDrive_GetFileEntry); metaTableObj.Register("FindFileEntry", LS_VirtualDrive_FindFileEntry); metaTableObj.Register("GetFileEntryIndex", LS_VirtualDrive_GetFileEntryIndex); metaTableObj.Register("__gc", VirtualDrive_gc); metaTableObj.SetObject("__index", metaTableObj); LuaObject obj = state->GetGlobals().CreateTable( "vdrive" ); obj.Register("VirtualDrive", LS_VirtualDrive); obj.Register("AdjustTime_t", LS_AdjustTime_t); obj.Register("help", LS_Help); obj.Register("crc32", LS_crc32); return 0; }
extern "C" LUAMODULE_API int luaopen_iox(lua_State* L) { LuaState* state = LuaState::CastState(L); LuaObject ioxObj = state->GetGlobals().CreateTable("iox"); ioxObj.RegisterDirect("PathCreate", PathCreate); ioxObj.RegisterDirect("PathDestroy", PathDestroy); ioxObj.RegisterDirect("CreateDirectory", PathCreate); ioxObj.RegisterDirect("RemoveDirectory", PathDestroy); ioxObj.Register("GetCurrentDirectory", LS_GetCurrentDirectory); ioxObj.Register("SetCurrentDirectory", LS_SetCurrentDirectory); ioxObj.Register("PathAddBackslash", LS_PathAddBackslash); ioxObj.Register("PathAddExtension", LS_PathAddExtension); ioxObj.Register("PathAppend", LS_PathAppend); ioxObj.Register("PathCanonicalize", LS_PathCanonicalize); ioxObj.Register("PathCombine", LS_PathCombine); ioxObj.Register("PathCommonPrefix", LS_PathCommonPrefix); ioxObj.Register("PathFileExists", LS_PathFileExists); ioxObj.Register("PathFindExtension", LS_PathFindExtension); ioxObj.Register("PathFindFileName", LS_PathFindFileName); ioxObj.Register("PathFindNextComponent", LS_PathFindNextComponent); ioxObj.Register("PathFindOnPath", LS_PathFindOnPath); ioxObj.Register("PathGetArgs", LS_PathGetArgs); ioxObj.Register("PathIsDirectory", LS_PathIsDirectory); ioxObj.Register("PathIsDirectoryEmpty", LS_PathIsDirectoryEmpty); ioxObj.Register("PathIsFileSpec", LS_PathIsFileSpec); ioxObj.Register("PathIsHTMLFile", LS_PathIsHTMLFile); ioxObj.Register("PathIsLFNFileSpec", LS_PathIsLFNFileSpec); ioxObj.Register("PathIsNetworkPath", LS_PathIsNetworkPath); ioxObj.Register("PathIsPrefix", LS_PathIsPrefix); ioxObj.Register("PathIsRelative", LS_PathIsRelative); ioxObj.Register("PathIsRoot", LS_PathIsRoot); ioxObj.Register("PathIsSameRoot", LS_PathIsSameRoot); ioxObj.Register("PathIsSystemFolder", LS_PathIsSystemFolder); ioxObj.Register("PathIsUNC", LS_PathIsUNC); ioxObj.Register("PathIsUNCServer", LS_PathIsUNCServer); ioxObj.Register("PathIsUNCServerShare", LS_PathIsUNCServerShare); ioxObj.Register("PathIsURL", LS_PathIsURL); ioxObj.Register("PathMakePretty", LS_PathMakePretty); ioxObj.Register("PathMakeSystemFolder", LS_PathMakeSystemFolder); ioxObj.Register("PathMatchSpec", LS_PathMatchSpec); ioxObj.Register("PathQuoteSpaces", LS_PathQuoteSpaces); ioxObj.Register("PathRelativePathTo", LS_PathRelativePathTo); ioxObj.Register("PathRemoveArgs", LS_PathRemoveArgs); ioxObj.Register("PathRemoveBackslash", LS_PathRemoveBackslash); ioxObj.Register("PathRemoveBlanks", LS_PathRemoveBlanks); ioxObj.Register("PathRemoveExtension", LS_PathRemoveExtension); ioxObj.Register("PathRemoveFileSpec", LS_PathRemoveFileSpec); ioxObj.Register("PathRenameExtension", LS_PathRenameExtension); ioxObj.Register("PathSearchAndQualify", LS_PathSearchAndQualify); ioxObj.Register("PathSkipRoot", LS_PathSkipRoot); ioxObj.Register("PathStripPath", LS_PathStripPath); ioxObj.Register("PathStripToRoot", LS_PathStripToRoot); ioxObj.Register("PathUndecorate", LS_PathUndecorate); ioxObj.Register("PathUnExpandEnvStrings", LS_PathUnExpandEnvStrings); ioxObj.Register("PathUnmakeSystemFolder", LS_PathUnmakeSystemFolder); ioxObj.Register("PathUnquoteSpaces", LS_PathUnquoteSpaces); ioxObj.Register("PathMakeAbsolute", LS_PathMakeAbsolute); ioxObj.Register("PathMakeBackSlash", LS_PathMakeBackSlash); ioxObj.Register("PathMakeForwardSlash", LS_PathMakeForwardSlash); ioxObj.Register("FindFirstFile", LS_FindFirstFile); ioxObj.Register("FindNextFile", LS_FindNextFile); ioxObj.Register("FindClose", LS_FindClose); ioxObj.Register("FindGetFileName", LS_FindGetFileName); ioxObj.Register("FindIsDirectory", LS_FindIsDirectory); ioxObj.Register("FindGetLastWriteTime", LS_FindGetLastWriteTime); ioxObj.Register("GetFileSize", LS_GetFileSize); ioxObj.Register("access", LS_access); ioxObj.Register("CopyFile", LS_CopyFile); ioxObj.Register("DeleteFile", LS_DeleteFile); ioxObj.Register("GetWriteTime", LS_GetFileWriteTime); ioxObj.Register("SetWriteTime", LS_SetFileWriteTime); ioxObj.Register("MakeWritable", LS_MakeWritable); ioxObj.Register("Sleep", LS_Sleep); ioxObj.Register("FileTimeToTime_t", LS_FileTimeToTime_t); ioxObj.Register("LoadLibrary", LS_LoadLibrary); ioxObj.Register("FreeLibrary", LS_FreeLibrary); return 0; }
void ScriptFunctionsRegister( LuaState* state ) { LuaObject globalsObj = state->GetGlobals(); globalsObj.Register("import", LS_import); globalsObj.Register("LuaDumpBinary", LS_dump); }
void registerAspectsFunctions(LuaState* state) { LuaObject globals = state->GetGlobals(); globals.Register("aspects_enable_credits", &aspects_enable_credits); globals.Register("aspects_disable_credits", &aspects_disable_credits); globals.Register("aspects_is_credits", &aspects_is_credits); globals.Register("aspects_enable_income", &aspects_enable_income); globals.Register("aspects_disable_income", &aspects_disable_income); globals.Register("aspects_is_income", &aspects_is_income); globals.Register("aspects_enable_expenses", &aspects_enable_expenses); globals.Register("aspects_disable_expenses", &aspects_disable_expenses); globals.Register("aspects_is_expenses", &aspects_is_expenses); globals.Register("aspects_enable_energy", &aspects_enable_energy); globals.Register("aspects_disable_energy", &aspects_disable_energy); globals.Register("aspects_is_energy", &aspects_is_energy); globals.Register("aspects_enable_thermal", &aspects_enable_thermal); globals.Register("aspects_disable_thermal", &aspects_disable_thermal); globals.Register("aspects_is_thermal", &aspects_is_thermal); globals.Register("aspects_enable_shop", &aspects_enable_shop); globals.Register("aspects_disable_shop", &aspects_disable_shop); globals.Register("aspects_is_shop", &aspects_is_shop); }