Example #1
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
                return ShowUsage();
            if (args.ContainsFlag("--all"))
            {
                List<uint> ids = new List<uint>();
                foreach (SimObject o in TheSimAvatar.Children)
                {
                    Success("Detatching " + o);
                    ids.Add(o.LocalID);
                }
                Client.Objects.DetachObjects(TheSimAvatar.GetSimulator(), ids);
                return Success("detatched all " + ids.Count);
            }

            int argsUsed;
            string[] keyargs = args.GetProperty("targets");
            List<SimObject> PS = WorldSystem.GetPrimitives(keyargs, out argsUsed);
            List<uint> idz = new List<uint>();
            foreach (var o in PS)
            {
                Success("Detatching " + o);
                idz.Add(o.LocalID);
            }
            Client.Objects.DetachObjects(TheSimAvatar.GetSimulator(), idz);
            return Success("detatched  " + args.str + " " + idz.Count);
        }
Example #2
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return(ShowUsage());
                // "rezitem [avatar5,prev,sim/123/232/23@360] "fairyverse Goodies" [item2] [item3] [...]";
            }

            int         argsUsed   = 0;
            string      lowerMatch = args[0].ToLower();
            SimPosition dest       = null;

            if (!args.ContainsFlag("--prev"))
            {
                dest = WorldSystem.GetVector(args.GetProperty("location"), out argsUsed);
            }
            var man   = Client.BotInventory;
            var found = man.FindAll(args.GetProperty("items"), true,
                                    inventoryName => Failure("No inventory item named " + inventoryName + " found."));

            foreach (InventoryBase ib in man.ItemsOnly(found))
            {
                RezAll(man, ib, dest);
            }
            return(Success("found.Count=" + found.Count));
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return(ShowUsage());
            }
            if (args.ContainsFlag("--all"))
            {
                List <uint> ids = new List <uint>();
                foreach (SimObject o in TheSimAvatar.Children)
                {
                    Success("Detatching " + o);
                    ids.Add(o.LocalID);
                }
                Client.Objects.DetachObjects(TheSimAvatar.GetSimulator(), ids);
                return(Success("detatched all " + ids.Count));
            }

            int argsUsed;

            string[]         keyargs = args.GetProperty("targets");
            List <SimObject> PS      = WorldSystem.GetPrimitives(keyargs, out argsUsed);
            List <uint>      idz     = new List <uint>();

            foreach (var o in PS)
            {
                Success("Detatching " + o);
                idz.Add(o.LocalID);
            }
            Client.Objects.DetachObjects(TheSimAvatar.GetSimulator(), idz);
            return(Success("detatched  " + args.str + " " + idz.Count));
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            bool writeInfo = !args.IsFFI;
            int  count     = 0;

            if (args.ContainsFlag("--presence"))
            {
                foreach (var A in WorldObjects.SimAccounts)
                {
                    count++;
                    AppendItem("agents", A);
                    if (writeInfo)
                    {
                        WriteLine(A + " local=" + A.IsLocal);
                    }
                }
            }
            else
            {
                int[] count0 = { 0 };
                foreach (Simulator sim in LockInfo.CopyOf(Client.Network.Simulators))
                {
                    if (sim.ObjectsAvatars.Count == 0)
                    {
                        continue;
                    }
                    if (writeInfo)
                    {
                        WriteLine("");
                    }
                    if (writeInfo)
                    {
                        WriteLine("Region: " + sim);
                    }
                    Simulator simulator = sim;
                    sim.ObjectsAvatars.ForEach(
                        delegate(Avatar av)
                    {
                        count0[0]++;
                        SimObject A = WorldSystem.GetSimObject(av, simulator);
                        AppendItem("avatars", A);
                        if (string.IsNullOrEmpty(av.Name))
                        {
                            Client.Objects.SelectObjects(simulator, new uint[] { av.LocalID }, true);
                        }
                        if (writeInfo)
                        {
                            WriteLine(" {0} (Group: {1}, Location: {2}, UUID: {3})",
                                      av.Name, av.GroupName, av.Position, av.ID.ToString());
                        }
                    }
                        );
                }
                count = count0[0];
            }
            SetResult("count", count);
            return(SuccessOrFailure());
        }
Example #5
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            int used = 0;

            if (args.Length == 0)
            {
                return(ShowUsage());
            }
            else
            {
                if (args.ContainsFlag("listns"))
                {
                    foreach (var c in MushDLR223.ScriptEngines.ScriptManager.GetNameSpaces(TheBotClient))
                    {
                        AddSuccess(c);
                    }
                    return(SuccessOrFailure());
                }
                if (args.ContainsFlag("vars") || args.ContainsFlag("list"))
                {
                    foreach (var c in ScriptManager.GetNameSpaces(TheBotClient))
                    {
                        foreach (var s in ScriptManager.GetProviders(TheBotClient, c))
                        {
                            foreach (var s1 in s.SettingNames(TheBotClient, 1))
                            {
                                GetValue(c, s1, AddSuccess);
                            }
                        }
                    }
                    return(SuccessOrFailure());
                }

                string nss     = TheBotClient.GetName();
                string varname = args[0];
                if (args.tokens.Length > 1)
                {
                    string[] sa    = Parser.SplitOff(args.tokens, 1);
                    string   value = string.Join(" ", sa);
                    ScriptManager.AddSetting(TheBotClient, nss, varname, value);
                }
                GetValue(nss, varname, AddSuccess);
                return(SuccessOrFailure());
            }
        }
Example #6
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            int used = 0;
            if (args.Length == 0)
            {
                return ShowUsage();
            }
            else
            {
                if (args.ContainsFlag("listns"))
                {
                    foreach (var c in MushDLR223.ScriptEngines.ScriptManager.GetNameSpaces(TheBotClient))
                    {
                        AddSuccess(c);
                    }
                    return SuccessOrFailure();
                }
                if (args.ContainsFlag("vars") || args.ContainsFlag("list"))
                {
                    foreach (var c in ScriptManager.GetNameSpaces(TheBotClient))
                    {
                        foreach (var s in ScriptManager.GetProviders(TheBotClient, c))
                        {
                            foreach (var s1 in s.SettingNames(TheBotClient, 1))
                            {
                                GetValue(c, s1, AddSuccess);
                            }
                        }
                    }
                    return SuccessOrFailure();
                }

                string nss = TheBotClient.GetName();
                string varname = args[0];
                if (args.tokens.Length > 1)
                {
                    string[] sa = Parser.SplitOff(args.tokens, 1);
                    string value = string.Join(" ", sa);
                    ScriptManager.AddSetting(TheBotClient, nss, varname, value);
                }
                GetValue(nss, varname, AddSuccess);
                return SuccessOrFailure();
            }
        }
Example #7
0
 public override CmdResult ExecuteRequest(CmdRequest args)
 {
     bool writeInfo = !args.IsFFI;
     int count = 0;
     if (args.ContainsFlag("--presence"))
     {
         foreach (var A in WorldObjects.SimAccounts)
         {
             count++;
             AppendItem("agents", A);
             if (writeInfo) WriteLine(A + " local=" + A.IsLocal);
         }
     }
     else
     {
         int[] count0 = {0};
         foreach (Simulator sim in LockInfo.CopyOf(Client.Network.Simulators))
         {
             if (sim.ObjectsAvatars.Count == 0) continue;
             if (writeInfo) WriteLine("");
             if (writeInfo) WriteLine("Region: " + sim);
             Simulator simulator = sim;
             sim.ObjectsAvatars.ForEach(
                 delegate(Avatar av)
                     {
                         count0[0]++;
                         SimObject A = WorldSystem.GetSimObject(av, simulator);
                         AppendItem("avatars", A);
                         if (string.IsNullOrEmpty(av.Name))
                         {
                             Client.Objects.SelectObjects(simulator, new uint[] {av.LocalID}, true);
                         }
                         if (writeInfo)
                             WriteLine(" {0} (Group: {1}, Location: {2}, UUID: {3})",
                                       av.Name, av.GroupName, av.Position, av.ID.ToString());
                     }
                 );
         }
         count = count0[0];
     }
     SetResult("count", count);
     return SuccessOrFailure();
 }
Example #8
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            if (args.Length < 1)
            {
                return ShowUsage();
                    // "rezitem [avatar5,prev,sim/123/232/23@360] "fairyverse Goodies" [item2] [item3] [...]";
            }

            int argsUsed = 0;
            string lowerMatch = args[0].ToLower();
            SimPosition dest = null;
            if (!args.ContainsFlag("--prev"))
            {
                dest = WorldSystem.GetVector(args.GetProperty("location"), out argsUsed);
            }
            var man = Client.BotInventory;
            var found = man.FindAll(args.GetProperty("items"), true,
                                    inventoryName => Failure("No inventory item named " + inventoryName + " found."));
            foreach (InventoryBase ib in man.ItemsOnly(found))
            {
                RezAll(man, ib, dest);
            }
            return Success("found.Count=" + found.Count);
        }
Example #9
0
        public override CmdResult ExecuteRequest(CmdRequest argsI)
        {
            ListAsSet<SimPosition> objs = TheSimAvatar.GetSelectedObjects();

            if (argsI.Length == 0)
            {
                foreach (var o in objs)
                {
                    WriteLine(" " + o);
                }
                return SuccessOrFailure();
            }
            if (argsI.ContainsFlag("--clear"))
            {
                objs.Clear();
                bool was = TheSimAvatar.SelectedBeam;
                TheSimAvatar.SelectedBeam = !was;
                TheSimAvatar.SelectedBeam = was;
            }
            var args = argsI.GetProperty("targets");
            {
                int used = 0;
                bool remove = false;
                while (used < args.Length)
                {
                    args = Parser.SplitOff(args, used);
                    string s = args[0];
                    if (s.StartsWith("-"))
                    {
                        remove = true;
                        s = s.Substring(1);
                    }
                    if (s.StartsWith("+"))
                    {
                        remove = false;
                        s = s.Substring(1);
                    }
                    if (s.Length < 0)
                    {
                        used = 1;
                        continue;
                    }
                    args[0] = s;
                    List<SimObject> PS = WorldSystem.GetPrimitives(args, out used);
                    foreach (var P in PS)
                    {
                        if (P == null)
                        {
                            WriteLine("Cannot find " + s);
                            used = 1;
                            continue;
                        }
                        if (remove)
                        {
                            WriteLine("Removing " + P);
                            TheSimAvatar.SelectedRemove(P);
                        }
                        else
                        {
                            WriteLine("Adding " + P);
                            TheSimAvatar.SelectedAdd(P);
                        }
                    }
                    if (used == 0) break;
                }
            }
            return Success("selected objects count=" + objs.Count);
        }
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            string filename;

            if (args.TryGetValue("save", out filename))
            {
                FileStream w = null;
                try
                {
                    w = File.OpenWrite(filename);
                    StreamWriter sw = new StreamWriter(w);
                    SysVarHtml((s, args0) =>
                    {
                        try
                        {
                            sw.WriteLine(DLRConsole.SafeFormat(s, args0));
                        }
                        catch (Exception)
                        {
                            return;
                        }
                    }, true);
                }
                finally
                {
                    if (w != null)
                    {
                        w.Close();
                    }
                    ;
                }
                return(Success("Wrote " + filename));
            }
            if (args.TryGetValue("load", out filename))
            {
                LoadSysVarHtml(File.OpenRead(filename));
                return(Success("Loaded " + filename));
            }
            if (args.ContainsFlag("htmldoc"))
            {
                StringBuilder sw = new StringBuilder(1024 * 900);
                SysVarHtml((s, ags) => sw.AppendFormat(s, ags), false);
                return(Success(sw.ToString()));
            }

            bool exactMatch    = args.ContainsFlag("--exact");
            bool caseSensitive = args.ContainsFlag("--case");

            int    used    = 0;
            var    sysvars = GetSysVars();
            string find;

            if (!args.TryGetValueOr("key", 0, out find))
            {
                // display all
                foreach (var sv in sysvars)
                {
                    var svv = sv;
                    WriteLine(string.Format("{0}={1} //{2}", (svv.Key), svv.Value, svv.Comments));
                }
                return(Success("count=" + sysvars.Count));
            }
            if (!caseSensitive)
            {
                find = find.ToLower();
            }
            var setThese = ScriptManager.FindMatchingSysvars(sysvars, find, exactMatch, caseSensitive);
            int found    = 0;

            foreach (var svv in setThese)
            {
                {
                    found++;
                    WriteLine(svv.DebugInfo);
                }
            }
            string value;

            if (!args.TryGetValueOr("value", 1, out value))
            {
                return(Success("Found sysvars: " + found));
            }
            int changed = 0;

            foreach (var one in setThese)
            {
                try
                {
                    one.Value = value;
                    AddSuccess("Set sysvar: " + one.Key + " to " + one.Value);
                    changed++;
                }
                catch (Exception e)
                {
                }
            }
            return(Success("set vars = " + changed));
        }
Example #11
0
        public override CmdResult ExecuteRequest(CmdRequest argsI)
        {
            ListAsSet <SimPosition> objs = TheSimAvatar.GetSelectedObjects();

            if (argsI.Length == 0)
            {
                foreach (var o in objs)
                {
                    WriteLine(" " + o);
                }
                return(SuccessOrFailure());
            }
            if (argsI.ContainsFlag("--clear"))
            {
                objs.Clear();
                bool was = TheSimAvatar.SelectedBeam;
                TheSimAvatar.SelectedBeam = !was;
                TheSimAvatar.SelectedBeam = was;
            }
            var args = argsI.GetProperty("targets");

            {
                int  used   = 0;
                bool remove = false;
                while (used < args.Length)
                {
                    args = Parser.SplitOff(args, used);
                    string s = args[0];
                    if (s.StartsWith("-"))
                    {
                        remove = true;
                        s      = s.Substring(1);
                    }
                    if (s.StartsWith("+"))
                    {
                        remove = false;
                        s      = s.Substring(1);
                    }
                    if (s.Length < 0)
                    {
                        used = 1;
                        continue;
                    }
                    args[0] = s;
                    List <SimObject> PS = WorldSystem.GetPrimitives(args, out used);
                    foreach (var P in PS)
                    {
                        if (P == null)
                        {
                            WriteLine("Cannot find " + s);
                            used = 1;
                            continue;
                        }
                        if (remove)
                        {
                            WriteLine("Removing " + P);
                            TheSimAvatar.SelectedRemove(P);
                        }
                        else
                        {
                            WriteLine("Adding " + P);
                            TheSimAvatar.SelectedAdd(P);
                        }
                    }
                    if (used == 0)
                    {
                        break;
                    }
                }
            }
            return(Success("selected objects count=" + objs.Count));
        }
Example #12
0
        public override CmdResult ExecuteRequest(CmdRequest args)
        {
            string filename;
            if (args.TryGetValue("save", out filename))
            {
                FileStream w = null;
                try
                {
                    w = File.OpenWrite(filename);
                    StreamWriter sw = new StreamWriter(w);
                    SysVarHtml((s, args0) =>
                                   {
                                       try
                                       {
                                           sw.WriteLine(DLRConsole.SafeFormat(s, args0));
                                       }
                                       catch (Exception)
                                       { 
                                           return;
                                       }
                                   }, true);
                }
                finally
                {
                    if (w != null) w.Close();
                    ;   
                }
                return Success("Wrote " + filename);
            }
            if (args.TryGetValue("load", out filename))
            {
                LoadSysVarHtml(File.OpenRead(filename));
                return Success("Loaded " + filename);
            }
            if (args.ContainsFlag("htmldoc"))
            {
                StringBuilder sw = new StringBuilder(1024*900);
                SysVarHtml((s, ags) => sw.AppendFormat(s, ags), false);
                return Success(sw.ToString());
            }

            bool exactMatch = args.ContainsFlag("--exact");
            bool caseSensitive = args.ContainsFlag("--case");

            int used = 0;
            var sysvars = GetSysVars();
            string find;
            if (!args.TryGetValueOr("key", 0, out find))
            {
                // display all
                foreach (var sv in sysvars)
                {
                    var svv = sv;
                    WriteLine(string.Format("{0}={1} //{2}", (svv.Key), svv.Value, svv.Comments));
                }
                return Success("count=" + sysvars.Count);
            }
            if (!caseSensitive) find = find.ToLower();
            var setThese = ScriptManager.FindMatchingSysvars(sysvars, find, exactMatch, caseSensitive);
            int found = 0;
            foreach (var svv in setThese)
            {
                {
                    found++;
                    WriteLine(svv.DebugInfo);
                }
            }
            string value;
            if (!args.TryGetValueOr("value", 1, out value))
            {
                return Success("Found sysvars: " + found);
            }
            int changed = 0;
            foreach (var one in setThese)
            {
                try
                {
                    one.Value = value;
                    AddSuccess("Set sysvar: " + one.Key + " to " + one.Value);
                    changed++;
                }
                catch (Exception e)
                {
                }
            }
            return Success("set vars = " + changed);
        }