void Awake() { if (instance != null) { DestroyImmediate(gameObject); return; } instance = this; _luaEnv = new LuaEnv(); L.AddLoader(FileUtils.LuaLoader); L.DoString("require 'init'"); L.Global.Set <string, Action <string, Action <object> > >("RegisterEvent", EventManager.Instance.AddEventAction); var MainAction = L.Global.Get <System.Action>("main"); if (MainAction != null) { MainAction(); } }
private bool Initialize() { Reset(); if (!MakeConnection()) { return(false); } if (!InitializeBot()) { return(false); } modulesController.LoadModules(modules); TelnetConnector.Instance.Execute("servernotifyregister event=server"); TelnetConnector.Instance.Execute("servernotifyregister event=channel id=0"); TelnetConnector.Instance.Execute("servernotifyregister event=textprivate"); //TelnetConnector.Instance.Execute("servernotifyregister event=textserver"); if (luaController == null) { luaController = new LuaController(); queryEvents = new QueryEvents(luaController); luaController.InitializeLua(); } ConsoleEx.WriteLine("Ready to go..."); MakeSomeTest(); return(true); }
public void Quit() { IsExecute = false; if (luaController != null) { luaController.QuitScript(); luaController = null; } if (onQuit != null) { onQuit.OnNext(Unit.Default); } }
private void SetupLua() { luaController = new LuaController(); luaController.SetScriptLoader(scriptLoader); luaController.SetScriptCommands(commandControllerTypes); commandControllers = new Dictionary <Type, CommandController>(); foreach (var luaType in commandControllerTypes) { var commandController = luaController.GetLuaClass(luaType) as CommandController; commandControllers.Add(luaType, commandController); } commandDictionary = commandControllers.Values .SelectMany(x => x.GetAllCommands()) .ToDictionary(x => x.GetType()); }