Пример #1
0
        public (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf)
        {
            _currThread = lf.Thread;

            try
            {
                LuaLibraryBase.SetCurrentThread(lf);

                var execResult = _currThread.Resume(0);
                GuiAPI.ThisIsTheLuaAutounlockHack();

                _lua.RunScheduledDisposes();                 // TODO: I don't think this is needed anymore, we run this regularly anyway

                // not sure how this is going to work out, so do this too
                _currThread.RunScheduledDisposes();

                _currThread = null;
                var result = execResult == 0
                                        ? (WaitForFrame : false, Terminated : true)        // terminated
                             : (WaitForFrame : FrameAdvanceRequested, Terminated : false); // yielded

                FrameAdvanceRequested = false;
                return(result);
            }
            catch (Exception)
            {
                GuiAPI.ThisIsTheLuaAutounlockHack();
                throw;
            }
            finally
            {
                LuaLibraryBase.ClearCurrentThread();
            }
        }
Пример #2
0
 public void CallExitEvent(LuaFile lf)
 {
     foreach (var exitCallback in RegisteredFunctions
              .Where(l => l.Event == "OnExit" && (l.LuaFile.Path == lf.Path || l.LuaFile.Thread == lf.Thread)))
     {
         exitCallback.Call();
     }
     GuiAPI.ThisIsTheLuaAutounlockHack();
 }
Пример #3
0
 public void CallLoadStateEvent(string name)
 {
     try
     {
         foreach (var lf in RegisteredFunctions.Where(l => l.Event == "OnSavestateLoad"))
         {
             lf.Call(name);
         }
         GuiAPI.ThisIsTheLuaAutounlockHack();
     }
     catch (Exception e)
     {
         GuiAPI.ThisIsTheLuaAutounlockHack();
         LogToLuaConsole($"error running function attached by lua function event.onloadstate\nError message: {e.Message}");
     }
 }
Пример #4
0
 public void CallFrameAfterEvent()
 {
     if (IsUpdateSupressed)
     {
         return;
     }
     try
     {
         foreach (var lf in RegisteredFunctions.Where(l => l.Event == "OnFrameEnd"))
         {
             lf.Call();
         }
         GuiAPI.ThisIsTheLuaAutounlockHack();
     }
     catch (Exception e)
     {
         GuiAPI.ThisIsTheLuaAutounlockHack();
         LogToLuaConsole($"error running function attached by lua function event.onframeend\nError message: {e.Message}");
     }
 }