Make my bot sit on a prim

From libopenmetaverse - libomv - Developer Wiki

Jump to: navigation, search

I found this to be particularly tricky, i had to look at the old source code for SLeek just to see how i could get object names...

sure you can try and use Client.Self.RequestSit but then you realize you need an UUID not an object name, so here how we match that UUID to the object Name:

First we need to declare a few variables to store information about our prims:

        public static List<UUID> primIDs=new List<UUID>();
        public static List<String> primNames=new List<string>();
        public static List<Vector3> primPositions=new List<Vector3>();
        public static List<uint> primLocalID = new List<uint>();

Then we need to declare our event handlers in static void Main:

*THIS PART IS OUTDATED. These handlers no longer exist.

                Client.Objects.OnNewPrim += new OpenMetaverse.ObjectManager.NewPrimCallback(Objects_OnNewPrim);
                Client.Objects.OnObjectPropertiesFamily += new OpenMetaverse.ObjectManager.ObjectPropertiesFamilyCallback(Objects_OnObjectPropertiesFamily);                            

Now for our event handlers (after Main):

        static void Objects_OnNewPrim(Simulator simulator, Primitive primd, ulong regionHandle, ushort timeDilation)
            if (primd == null)  return; 
            if (primd.ParentID != 0) return;
            if (primIDs.Contains(primd.ID)) return;
        static void Objects_OnObjectPropertiesFamily(Simulator simulator, Primitive.ObjectProperties props, ReportType type)
            Console.WriteLine("Recording object: " + props.Name);

then i had to add a custom method to grab the object names (after event handlers):

        static void GetObjectNames()
            Console.WriteLine("\n \n===========Fetching Object Names...\n \n");
            foreach (UUID primds in primIDs)
                Client.Objects.RequestObjectPropertiesFamily(Client.Network.CurrentSim, primds);
            Console.WriteLine("\n \n===========Object Names fetch complete...\n \n");
            Console.WriteLine("\n \nLoaded " + primNames.Count +" Objects\n \n");

ok now that we got all that setup we can make our bot sit here is how to do it you have to put this in your self_on_chat event handler:

            if (message.ToLower().Contains("bot sit on"))
                primname = message.Replace("bot sit on ","");
                GetObjectNames();                // <----- this is where we refetch our current object names.
                if (primNames.Contains(primname))
                    int kl = primNames.IndexOf(primname);
                else if (primname.ToLower() == "ground")
            if (message.ToLower().Contains("bot stand up"))