Example #1
0
        private static void sheep_IncNounVerbCount(IntPtr vm)
        {
            string verb = SheepMachine.PopStringOffStack(vm);
            string noun = SheepMachine.PopStringOffStack(vm);

            Game.Nouns n = Game.NounUtils.ConvertStringToNoun(noun);
            Game.Verbs v = Game.VerbsUtils.ConvertStringToVerbs(verb);
            Game.GameManager.IncrementNounVerbCount(n, v);
        }
Example #2
0
        private static void sheep_GetChatCount(IntPtr vm)
        {
            string noun = SheepMachine.PopStringOffStack(vm);

            Game.Nouns n = Game.NounUtils.ConvertStringToNoun(noun);
            int        c = Game.GameManager.GetChatCount(n);

            SheepMachine.PushIntOntoStack(vm, c);
        }
Example #3
0
        private static void sheep_SetGameTimer(IntPtr vm)
        {
            int    milliseconds = SheepMachine.PopIntOffStack(vm);
            string verb         = SheepMachine.PopStringOffStack(vm);
            string noun         = SheepMachine.PopStringOffStack(vm);

            Game.Nouns n = Game.NounUtils.ConvertStringToNoun(noun);
            Game.Verbs v = Game.VerbsUtils.ConvertStringToVerbs(verb);
            Game.GameManager.AddGameTimer(n, v, milliseconds);
        }
Example #4
0
 public VerbButton(VerbButtonSet vbs, Resource.ResourceManager content, Game.Nouns noun, Game.Verbs verb, string script,
                   Game.NvcApproachType approach, string approachTarget,
                   string downImage, string hoverImage, string upImage, string disabledImage,
                   string clickedSound, string tooltip)
     : base(vbs, content, downImage, hoverImage, upImage, disabledImage, clickedSound)
 {
     _noun           = noun;
     _verb           = verb;
     _script         = script;
     _approach       = approach;
     _approachTarget = approachTarget;
 }
Example #5
0
        public static int RunSnippet(string snippet, Game.Nouns noun, Game.Verbs verb)
        {
            if (_vm != IntPtr.Zero)
            {
                int result;

                _output.Clear();

                Console.CurrentConsole.WriteLine(ConsoleSeverity.Debug, "Executing snippet: {0}", snippet);

                string script = string.Format("symbols {{ int result$; int n$; int v$; }} code {{ main$() {{ result$ = {0}; }} }}", snippet);

                IntPtr compiledSnippet;
                if (shp_CompileScript(_compiler, script, out compiledSnippet) != SHEEP_SUCCESS)
                {
                    throw new SheepException("Unable to compile snippet");
                }

                IntPtr context;
                if (shp_PrepareScriptForExecution(_vm, compiledSnippet, "main$", out context) != SHEEP_SUCCESS)
                {
                    throw new SheepException("Unable to execute snippet");
                }

                if (shp_SetVariableI(context, 1, (int)noun) != SHEEP_SUCCESS ||
                    shp_SetVariableI(context, 2, (int)verb) != SHEEP_SUCCESS)
                {
                    throw new SheepException("Unable to execute snippet");
                }

                int err = shp_Execute(context);

                if (err != 0)
                {
                    Logger.WriteError("Error ({0}) received when attempting to execute snippet: {1}", err, snippet);
                    throw new SheepException("Unable to execute snippet");
                }

                if (shp_GetVariableI(context, 0, out result) != SHEEP_SUCCESS)
                {
                    throw new SheepException("Unable to get result of snippet");
                }

                return(result);
            }
            else
            {
                throw new SheepException(SheepUnavailableError);
            }
        }