Пример #1
0
        private void bTest0_Click(object sender, EventArgs e)
        {
            string s = "function A() Test.MyTables.PrintPlusA('one', 'two') end " +
                       "function B() " +
                       "print(1)" +
                       "coroutine.yield()" +
                       "print(2)" +
                       "coroutine.yield()" +
                       "print(3)" +
                       "end " +
                       "RegisterCoroutine(A, 'A', true) " +
                       //"RegisterCoroutine(b, 'B', true) " +
                       "";

            bool         isCoroutine        = true;
            bool         autoResetCoroutine = true;
            HookStandard standard           = new HookStandard(
                new FuncStandard("A", FuncType.AutoCoroutine | FuncType.AllowAny),
                new FuncStandard("B", FuncType.AutoCoroutine | FuncType.AllowAnyCoroutine)
                );

            HookedScriptRunner hsr = new HookedScriptRunner(standard);


            ScriptBindings b = new ScriptBindings(this);

            b.HookDelegate("Test.YieldPls", (Func <int, string, WaitUntil>)AutoCoroutineTest, "", "");
            hsr.AddBindings(b);
            hsr["text"] = "test";
            hsr.LoadScript(s);
            hsr.LoadScript(s);
            hsr.LoadScript(s);
            hsr.LoadScript(s);
            hsr.LoadScript(s);
            hsr.LoadScript(s);
            hsr.RefreshLua();

            hsr.Execute("A");

            for (int j = 0; j < 30; j++)
            {
                Console.WriteLine($"==========C# {j + 1}");
                hsr.Execute("B");
            }



            //Script s = new Script();
            //s.Globals["PrintPlusA"]
            //var a = CallbackFunction.FromDelegate(s, (Action<string>)PrintPlusA);

            //a.
            //var b = CallbackFunction.FromDelegate(s, (Action<string, string>)PrintPlusA);
            //s.DoString(@"PrintPlusA(")

            //DynValue.NewCallbackFu(CallbackFunction)
            //DynValue.NewYieldReq()
            //Closure c = new Closure();
            //DynValue.FromObject(s.Globals["test"]).Function.GetUpvalue
        }