コード例 #1
0
 // Token: 0x0600F741 RID: 63297 RVA: 0x00552958 File Offset: 0x00550B58
 public void EBIJMBJCPIG()
 {
     if (this.ICOMJMLACPH.Count > 0)
     {
         try
         {
             MoonSharp.Interpreter.Coroutine coroutine = this.ICOMJMLACPH.Peek();
             DynValue dynValue = coroutine.Resume();
             if (coroutine.State == CoroutineState.Suspended)
             {
                 this.ICOMJMLACPH.Pop();
                 this.OEGKPMHIJGF = true;
             }
             if (dynValue.Type == DataType.Number)
             {
                 this.ICOMJMLACPH.Push(this.LOKOJMIKEEL.CreateCoroutine(dynValue).Coroutine);
             }
         }
         catch (ScriptRuntimeException ex)
         {
             Debug.LogError(ex.DecoratedMessage);
             this.OEGKPMHIJGF = false;
             this.ICOMJMLACPH.Clear();
         }
     }
     else
     {
         this.OEGKPMHIJGF = true;
     }
 }
コード例 #2
0
 private IEnumerator ScriptRoutine(DynValue function)
 {
     Assert.IsNull(activeScript);
     activeScript = GlobalContext.CreateCoroutine(function).Coroutine;
     activeScript.Resume();
     while (activeScript.State != CoroutineState.Dead)
     {
         yield return(null);
     }
 }
コード例 #3
0
ファイル: LuaScriptHost.cs プロジェクト: hafewa/MAJIKA
        public IEnumerator Co(MoonSharp.Interpreter.Coroutine co)
        {
            while (co.State != CoroutineState.Dead)
            {
                var val = co.Resume();

                /*if (!val.IsNil())
                 *  Debug.Log(val.ToObject());*/
                yield return(val.ToObject());
            }
        }
コード例 #4
0
 // executes asynchronously, for cutscenes
 public void RunScript(DynValue function, Action callback = null)
 {
     Global.Instance().Maps.Avatar.PauseInput();
     StartCoroutine(CoUtils.RunWithCallback(ScriptRoutine(function), this, () => {
         Global.Instance().Maps.Avatar.UnpauseInput();
         activeScript = null;
         if (callback != null)
         {
             callback();
         }
     }));
 }
コード例 #5
0
        public void QuitScript()
        {
            if (luaCoroutine != null)
            {
                luaCoroutine = null;
            }

            if (LuaScript != null)
            {
                LuaScript = null;
            }
        }
コード例 #6
0
        private IEnumerator ExecuteScriptInternal(string script)
        {
            var luaFunc = DynValue.Nil;

            try
            {
                luaFunc = LuaScript.DoString(script);
            }
            catch (InterpreterException ex)
            {
                Debug.LogErrorFormat("Lua Execute error:\n{0}", ex.DecoratedMessage);
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }

            if (luaFunc.IsNil())
            {
                yield break;
            }

            luaCoroutine = null;

            var dynValue = LuaScript.CreateCoroutine(luaFunc);

            if (dynValue.IsNil())
            {
                yield break;
            }

            luaCoroutine = dynValue.Coroutine;

            luaCoroutine.AutoYieldCounter = 1000;

            luaCoroutine.Resume();

            while (true)
            {
                if (luaCoroutine == null)
                {
                    break;
                }

                if (luaCoroutine.State == CoroutineState.Dead)
                {
                    break;
                }

                yield return(null);
            }
        }
コード例 #7
0
    public void AdvanceScript()
    {
        // Check if the Coroutine stack is empty
        if (coroutineStack.Count > 0)
        {
            try
            {
                MoonSharp.Interpreter.Coroutine activeCoroutine = coroutineStack.Peek();

                // Save the active coroutine's return value
                DynValue returnValue = activeCoroutine.Resume();

                // If the active coroutine is dead, pop it off the stack
                if (activeCoroutine.State == CoroutineState.Dead)
                {
                    coroutineStack.Pop();
                    Debug.Log("Dialogue complete");
                }

                // If the return value is a function, add it to the top of the coroutine stack
                if (returnValue.Type == DataType.Function)
                {
                    coroutineStack.Push(environment.CreateCoroutine(returnValue).Coroutine);
                }
            }
            catch (ScriptRuntimeException e)
            {
                Debug.LogError(e.DecoratedMessage);
                coroutineStack.Clear();
            }
        }
        else
        {
            Debug.Log("No active dialogue");
        }
    }
コード例 #8
0
ファイル: LuaScriptHost.cs プロジェクト: hafewa/MAJIKA
 public UnityEngine.Coroutine StartCoroutine(MoonSharp.Interpreter.Coroutine coroutine)
 => Host.StartCoroutine(coroutine.AsUnityCoroutine());