예제 #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
        }
예제 #2
0
 private void bDispose_Click(object sender, EventArgs e)
 {
     testScriptRunner     = null;
     bExecute.Enabled     = false;
     bDispose.Enabled     = false;
     bAbort.Enabled       = false;
     bStart.Enabled       = true;
     bSetStashkey.Enabled = false;
     bCallHook.Enabled    = false;
 }
예제 #3
0
 private void bStart_Click(object sender, EventArgs e)
 {
     testScriptRunner = new HookedScriptRunner(new ScriptBindings(this))
     {
         AutoRefreshInterval = 1
     };
     bExecute.Enabled     = true;
     bDispose.Enabled     = true;
     bAbort.Enabled       = true;
     bSetStashkey.Enabled = true;
     bStart.Enabled       = false;
     bCallHook.Enabled    = true;
 }