예제 #1
0
    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();
        }
    }
예제 #2
0
파일: Bot.cs 프로젝트: norberto5/KindBot
        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);
        }
예제 #3
0
        public void Quit()
        {
            IsExecute = false;

            if (luaController != null)
            {
                luaController.QuitScript();

                luaController = null;
            }

            if (onQuit != null)
            {
                onQuit.OnNext(Unit.Default);
            }
        }
예제 #4
0
        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());
        }