Example #1
0
        public object invoke(VerbParameters param)
        {
            // Inject the verb script blob parameters as script variables.
            var scope = new Scope();
            scope.set("input", param.input);
            scope.set("inputwords", param.inputwords);
            scope.set("self", new Proxies.MobProxy(param.self, param.player));
            scope.set("obj", new Proxies.MobProxy(param.dobj, param.player));
            if (param.prep != Prep.None)
            scope.set("prep", param.prep.ToString().ToLowerInvariant());
            else
            scope.set("prep", null);
            scope.set("indobj", new Proxies.MobProxy(param.iobj, param.player));
            if (param.prep2 != Prep.None)
            scope.set("prep2", param.prep2.ToString().ToLowerInvariant());
            else
            scope.set("prep2", null);
            scope.set("indobj2", new Proxies.MobProxy(param.iobj2, param.player));

            scope.set("objwords", param.dobjwords);
            scope.set("prepwords", param.prepwords);
            scope.set("indobjwords", param.iobjwords);
            scope.set("prep2words", param.prep2words);
            scope.set("indobj2words", param.iobj2words);

            // Inject some standard MOO objects.
            scope.set("ambiguous", Proxies.MobProxy.Ambiguous);
            scope.set("none", Proxies.MobProxy.None);

            // Inject the player object.
            Proxies.PlayerProxy player = null;
            if (param.player != null)
            player = new Proxies.PlayerProxy( param.player, param.world );
            scope.set("player", player);

            // "caller" is the same as the player, unless otherwise specified.
            if (param.caller != null)
            scope.set("caller", new Proxies.MobProxy(param.caller, param.player));
            else
            scope.set("caller", player);

            scope.set("args", param.args);
            scope.set("world", new Proxies.WorldProxy(param.world, param.player));
            scope.set("$", new Proxies.MobProxy(param.world.findObject(1), param.player));
            scope.set( "perms", Proxies.PermBitsProxy.Static );

            scope.queryForItem = (name) => {
            if (name.StartsWithI("#")) {
                int number = CultureFree.ParseInt(name.Substring(1));
                if( number == Mob.Anon.id )
                {
                    Mob m = param.player.anonMob;
                    if( m != null )
                        return new Proxies.MobProxy( m, param.player );
                }
                return new Proxies.MobProxy(param.world.findObject(number), param.player);
            }
            return null;
            };

            // Pass these on literally to any down-stream invokes.
            scope.baggageSet(VerbParamsKey, param);

            return _script.execute(scope);
        }
Example #2
0
        public override object callMethod(Scope scope, string name, object[] args)
        {
            // Make sure there's a matching verb to be found. Unlike the input
            // parser, this pays no attention to verb signatures.
            SourcedItem<Verb> v = _mob.findVerb(name);
            if (v == null)
            throw new NotImplementedException("No verb named '" + name + "'.");

            // Look for the previous verb parameters.
            Verb.VerbParameters param = (Verb.VerbParameters)scope.baggageGet(Verb.VerbParamsKey);

            // Make a new one based on it. Most of this will stay the same.
            var newparam = param.clone();
            newparam.self = _mob;
            newparam.caller = param.self;
            newparam.args = args;

            if( Perm.IsVerbAntistick( _mob, name ) )
            return v.item.invoke(newparam);
            else
            {
            using( var ac = new ActorContext( _player, v.source.id ) )
                return v.item.invoke(newparam);
            }
        }
Example #3
0
 public object execute(Scope scope)
 {
     Script recontexted =_compiled.DuplicateWithNewContext(scope.context);
     return recontexted.Execute();
 }
Example #4
0
 public virtual object callMethod(Scope scope, string name, object[] args)
 {
     throw new DynamicObjectFailure("No matching methods are available.");
 }