Esempio n. 1
0
        /// <summary>
        /// Bot's logic loop
        /// </summary>
        public void update()
        {
            if (paused)
            {
                //Console.WriteLine("Not running");
                return;
            }

            if (script == null)
            {
                if (scriptName != null)
                {
                    script = loadScript(this.scriptName);
                }
                return;
            }

            if (!running)
            {
                Console.WriteLine("Not running, Click Run");
                return;
            }

            if (!initialized)
            {
                script.initializeInputs(bot);
                script.onStart();
                initialized = !initialized;
            }

            //Loaded script needs to be on its own thread...maybe not

            int sleep = 0;

            //Run background scripts
            foreach (Scriptable bgScript in bot.BACKGROUNDSCRIPTS)
            {
                try
                {
                    if (bgScript.Name.Equals("Autologer"))
                    {
                        if (!((Script.Scripts.AutoLoger)bgScript).HasCredentials)
                        {
                            ((Script.Scripts.AutoLoger)bgScript).userCredentials(bot.Accountmanager);
                        }
                    }

                    if (bgScript.Enabled)
                    {
                        bgScript.run();
                    }
                }

                catch (Exception e)
                {
                    Console.WriteLine("background script f****d up");
                    Console.WriteLine(e.ToString());
                }
            }
            try
            {
                if (script.enabled)
                {
                    script.initializeInputs(bot);
                    sleep = script.run();
                }
                else
                {
                    sleep = 600;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("user script f****d up");
                Console.WriteLine(e.ToString());
            }



            if (sleep < 1)
            {
                sleep = 300;
            }

            Thread.Sleep(sleep);

            Console.WriteLine("Bot pid = " + getPid());
        }