コード例 #1
0
        public async Task ErrorTriggerTest()
        {
            var errorTestScript = @"
(0:0) when the script starts,
        (5:102) print {This is a test of the new error system} to the console.
        (5:105) raise an error.
        (5:102) print {This will NOT be displayed because an error was raised} to the console.
";

            Monkeyspeak.MonkeyspeakEngine engine = GetMonkeySpeakEngine();
            Monkeyspeak.Page page = engine.LoadFromString(errorTestScript);

            page.Error += DebugAllErrors;

            page.LoadSysLibrary();

            //Throws MonkeySpeak.Exception
            await Task.Run(() => page.ExecuteAsync(0));
        }
コード例 #2
0
        public void DemoTest()
        {
            Monkeyspeak.MonkeyspeakEngine engine = GetMonkeySpeakEngine();
            Monkeyspeak.Page page = engine.LoadFromString(testScript);

            page.Error += DebugAllErrors;

            List <Monkeyspeak.Trigger> triggers = new List <Monkeyspeak.Trigger>();

            page.LoadSysLibrary();
            Monkeyspeak.IVariable var = page.SetVariable("%testVariable", "Hello WOrld", true);

            page.SetTriggerHandler(Monkeyspeak.TriggerCategory.Cause, 0, HandleAllCauses);

            // Trigger count created by subscribing to TriggerAdded event
            // and putting triggers into a list.
            Console.WriteLine("Trigger Count: " + page.Size);

            page.ExecuteAsync(0);
        }
コード例 #3
0
        public async Task TextCondkitionBlockageAsync()
        {
            var timerLibTestScript = @"
(0:0) when the script starts,
    (5:102) print {Before False} to the console.
(1:6666) return false,
    (5:102) print {After False} to the console.

(0:300) when timer %timer goes off,
    (5:102) print {Timer %timer went off.} to the console.
";

            Monkeyspeak.MonkeyspeakEngine engine = GetMonkeySpeakEngine(true);
            Monkeyspeak.Page page = engine.LoadFromString(timerLibTestScript);

            page.Error += DebugAllErrors;

            page.LoadSysLibrary();
            page.LoadTimerLibrary();
            page.SetTriggerHandler(Monkeyspeak.TriggerCategory.Condition, 6666, AlwayFalse);
            page.SetTriggerHandler(Monkeyspeak.TriggerCategory.Cause, 0, HandleAllCauses);
            int[] ids = { 0 };
            await Task.Run(() => page.ExecuteAsync(ids));
        }