Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --*********************************************************************
- -- Anton Scriptsov/ Xbow Software - Copyright (C) 2003
- -- Author: AntiPoD
- -- Date: 28.11.2002
- -- Time: 11:25
- -- Abstract: Основные функции для обеспечения работы скриптовой системы
- --*********************************************************************/
- -- Edited '24.07.2015::10:57' by Nocalora29: Added new root folder from where new Lua/script Files can be Executed.
- -- 30.09.2015: Optimized Logging Capabilities, by adding an Indexing Feature for the Addons.
- -- Reason: Mainly so it becomes easier to sort out Mod-Files from Game-Files
- -- 07.03.2017 - Nocalora: Updated the Addonloader to support an embedded Autorun
- --REGISTER YOUR ADDONS HERE !!!
- --WARNING: This embedded Autorun has a Higher load Priority than SW3 Expansion's GetFollowers() Init Hook, so if -
- -- - you use this Autorun, make sure it doesn't rely on SW3EXP Functions
- -- "Addon Name", "Content-Type", {Table of Functions to be Executed}
- __AddonsList = {
- --Addons
- {"MGVE", "Inactive"},
- {"MQLE", "Addon"},
- {"PPHooks", "Addon"},
- {"StarRover", "Addon"},
- {"SW3_Expansion", "Addon"},
- {"Motherships_Mod_0.27", "Addon"},
- {"Fleet_Mod", "Addon"},
- {"Plugins", "Addon"},
- --Core Scripts
- {"Data/Scripts/", "Core"}
- };
- -- Content Types:
- -- Inactive: Will not be Loaded
- -- Addon: Will be loaded as an Addon
- -- Core: Core game files/Scripts
- --REGISTER YOUR ADDONS HERE !!!
- --//////////// DEFINES //////////////////
- TRUE = 1;
- FALSE = 0;
- --//////////// DEFINES //////////////////
- -- Standart functions library
- -- относительный путь к скиптам
- _script_path = "DATA/Scripts/";
- -- имя файла скриптовых ошибок
- userfolder = GetUserFolder();
- userfolder = userfolder.."ScriptErrors.log";
- _script_error_filename = userfolder;
- -- хэндлер файла скриптовых ошибок
- _script_error_output = openfile(_script_error_filename, "w");
- --/////////// INDEXED ADDONS ///////////////
- ADDONS = 0;
- --/////////// INDEXED ADDONS ///////////////
- --/////////// LOAD PRIORITY ///////////////
- -- 0 = Game Scripts have Priority
- -- 1 = Addon Scripts have Priority
- LOADPRIORITY = 1;
- --/////////// LOAD PRIORITY ///////////////
- -- перехватчик для отображения в лог файле информации об ошибках произошедших в скрипте
- function _ALERT(error)
- write(_script_error_output, error);
- --flush(_script_error_output);
- --closefile(_script_error_output);
- --SLOG(" Error: look at ".._script_error_filename.." file");
- --LOG(" Error: look at ".._script_error_filename.." file");
- SLOG(error);
- LOG(error);
- end
- -- функция для вывода ошибки в лог файл(по умолчанию) или в SLOG - ErrorLog("Trouble", "SLOG")
- function ErrorLog(message, to)
- if (to == nil or to == 'LOG')
- then
- write(_script_error_output, message);
- write(_script_error_output,'\n');
- SLOG("Script error: "..message);
- LOG("Script error: "..message);
- return
- end
- SLOG(message);
- end;
- -- ======= DIALOG SECTION =======
- function ProcessDialog()
- if Dialog == nil
- then
- ErrorLog("Have not a Dialog file");
- return
- end
- local dialog = CreateDlg(Dialog.name, Dialog.dialogID);--, Dialog.dialogInitializingScript
- print(dialog.classname, dialog.id);
- for k, i in Dialog.DialogSheetEntres
- do
- --print("Dialog stuff:"..dialog.classname.." "..dialog.id);
- local sheet = CreateDlgSheet(dialog, i.sheetID, i.question);
- --print("sheet stuff:"..sheet.classname.." "..sheet.id);
- --print(Dialog.DialogSheetEntres[k].question);
- for _,j in Dialog.DialogSheetEntres[k].answers
- do
- AddAnswerToDlgSheet(dialog, sheet, j.answer, j.to, j.script);
- end;
- end;
- end;
- -- Обработчик данных содержащихся в файле
- function ProcessQuest()
- if Quest == nil
- then
- ErrorLog("Have not a Quest file");
- return
- end;
- local quest = CreateQuest(Quest.id, Quest.name, Quest.desc);
- for k, i in Quest.Objectives
- do
- quest:AddObjectiveToQuest(i.desc, OBJECTIVE_INPROCESS);
- end;
- --sentinel
- -- для невозможности считывания повторных данных без считывания файла
- ret = {id = Quest.id};
- Quest = nil;
- settag(ret, TAG_QUEST);
- SLOG("TAG_QUEST is "..TAG_QUEST);
- return ret;
- end;
- function ParseQuestFilesList(file)
- if file == nil
- then
- file = _script_path.."questFiles.lst";
- end;
- ExecuteScriptFile(file);
- SLOG("DO FILE DONE.....");
- for _, val in sys_questFiles
- do
- ExecuteScriptFile(_script_path..val);
- ProcessQuest();
- end;
- end;
- -- подключение файлов необходимых для скриптового движка
- function LoadLevel(path)
- if (path == nil)
- then
- ErrorLog("Can't load level! Path is undefined!");
- return FALSE;
- else
- file = path.."level.lst";
- end;
- ret = ExecuteScriptFile(file);
- if (ret == nil)
- then
- return FALSE;
- end;
- if sys_IncludeFileList == nil
- then
- ErrorLog("Can't parse IncludeFiles List. File is invalid");
- return
- end;
- for _, val in sys_IncludeFileList
- do
- --SLOG("1Open "..path..val);
- local ret = ExecuteScriptFile(path..val);
- if (ret == nil)
- then
- return FALSE;
- end;
- end;
- end;
- function ParseSystemScripts(path)
- if (path == nil)
- then
- file = "DATA/Scripts/system.lst";
- else
- file = path.."system.lst";
- end;
- --SLOG("Loading "..file);
- ret = ExecuteScriptFile(file);
- if (ret == nil)
- then
- return FALSE;
- end;
- if sys_IncludeFileList == nil
- then
- ErrorLog("Can't parse IncludeFiles List. File is invalid");
- return
- end;
- for _, val in sys_IncludeFileList
- do
- local ret = ExecuteScriptFile(path..val);
- if (ret == nil)
- then
- return FALSE;
- end;
- end;
- end;
- function ParseSystemScripts_Edited(path)
- if (path == nil)
- then
- -- Execute Plugins
- file = "DATA/Addons/@Plugins/system.lst";
- else
- file = path.."system.lst";
- end;
- --SLOG("Loading "..file);
- ret = ExecuteScriptFile(file);
- if (ret == nil)
- then
- return FALSE;
- end;
- if sys_IncludeFileList == nil
- then
- ErrorLog("Can't parse IncludeFiles List. File is invalid");
- return
- end;
- for _, val in sys_IncludeFileList
- do
- local ret = ExecuteScriptFile(path..val);
- if (ret == nil)
- then
- return FALSE;
- end;
- end;
- end;
- -- End of Standart functions library
- -- ////////// REGISTERED EVENTS /////////
- EVENT_MAP_INITIALIZING = 1;
- EVENT_SELECTED = 2;
- EVENT_DESELECTED = 3;
- EVENT_DIALOG_ACTIVATED = 4;
- EVENT_DIALOG_ITEM_SELECTED = 5;
- -- ////////// REGISTERED EVENTS /////////
- -- MAP INITIALIZING Script
- function MapInitializing()
- unit_0001 = 1;
- condition = TRUE;
- print("Map initializing.....completed");
- end;
- function MapInitializing_Condition()
- print("MapInitializing_Condition executed...");
- return TRUE;
- end;
- -- MAP INITIALIZING Script
- --SW3EXP Addons folder Prefix Function
- function ExecuteModScripts(ModFName)
- ADDONS = ADDONS + 1;
- LOG("SW3EXP::Addon-System-> Adding Mod INDEX["..ADDONS.."]: '"..ModFName.."'");
- ParseSystemScripts_Edited("DATA/Addons/"..ModFName.."/");
- LOG("SW3EXP::Addon-System-> Mod INDEX["..ADDONS.."]: '".. ModFName.."' Successfully Added.");
- end
- --ParseQuestFilesList();
- -- Include base library files
- --New Plugin Loader
- --AddonLoader
- function AddonLoader()
- LOG("SW3EXP::ADDONLOADER: Beginning Operation...");
- --Process all Objects inside Table.
- for Addon, CurAddon in __AddonsList do
- --Check Property
- if CurAddon[2] == "Addon" then
- ExecuteModScripts("@"..CurAddon[1]);
- --Auto Execute Functions
- if (CurAddon[3]) then
- LOG("SW3EXP::ADDONLOADER: Addon '"..CurAddon[1].."' Has an Active Autorun routine.");
- for AllFunctions, CurrentFunction in CurAddon[3] do
- LOG("SW3EXP::ADDONLOADER: Addon '"..CurAddon[1].."' AUTORUN-> Executes: "..tostring(CurrentFunction));
- getglobal(CurrentFunction)();
- end;
- end;
- end;
- if CurAddon[2] == "Core" then
- ParseSystemScripts(CurAddon[1]);
- end;
- if CurAddon[2] == "Inactive" then
- --Ignore
- LOG("SW3EXP::ADDONLOADER: Addon '"..CurAddon[1].."' is Inactive!");
- end;
- end;--for Objects, CurObject in ObjectsTable do
- LOG("SW3EXP::ADDONLOADER: Operation Complete.");
- end;
- AddonLoader();
Advertisement
Add Comment
Please, Sign In to add comment