aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ExportBot/Commands/TouchCommand.cs
blob: 4103d210fdd43dfe5158ca542489c8ceee6e928a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.Collections.Generic;
using System.Text;
using libsecondlife;
using libsecondlife.Packets;

namespace libsecondlife.TestClient
{
    public class TouchCommand: Command
    {
        public TouchCommand(TestClient testClient)
		{
			Name = "touch";
			Description = "Attempt to touch a prim with specified UUID";
		}
		
        public override string Execute(string[] args, LLUUID fromAgentID)
		{
		    Primitive target = null;

		    lock (Client.SimPrims)
		    {
                if (Client.SimPrims.ContainsKey(Client.Network.CurrentSim))
                {
                    foreach (Primitive p in Client.SimPrims[Client.Network.CurrentSim].Values)
                    {
                        if (args.Length == 0)
                            return "You must specify a UUID of the prim.";

                        try
                        {
                            if (p.ID == args[0])
                                target = p;
                        }
                        catch
                        {
                            // handle exception
                            return "Sorry, I don't think " + args[0] + " is a valid UUID.  I'm unable to touch it.";
                        }
                    }
                }
		    }

            if (target != null)
            {
                Client.Self.Touch(target.LocalID);
                return "Touched prim " + target.ID + ".";
            }
            else
            {
                return "Couldn't find that prim.";
            }
		}
    }
}