Use libopenmv to login to the SL grid

From libopenmetaverse - libomv - Developer Wiki

Jump to: navigation, search


Creating your FirstBot

This article will show you the most basic steps required to log a bot into the Second Life grid:

Download and Compile the libOpenMetaverse Library

Follow the instructions here to download and compile the library

Create a project for your Bot in Visual Studio

Open Visual Studio, select File -> New -> Project from the toolbar Under Project Types, select Visual C# -> Windows Select Console Application from the Templates list

For the project Name, Etc

Name: FirstBot Location: select a location on your local hard disk, or use the default Solution Name: FirstBot, Go ahead and check the "Create directory for solution" checkbox. Click the OK Button

Add required library references to your project

  1. Click View -> Solution Explorer on the toolbar
  2. In the solution explorer right click the References item, then click Add References
  3. In the Add Reference Dialog click the Browse Tab, now navigate to the directory where you compiled the libOpenMetaverse library (you should see a folder named "bin", open this)
  4. Now select the following files (To select multiple files hold down the control key on your keyboard before you click each one): OpenMetaverse.dll and OpenMetaverseTypes.dll
  5. If you get a warning dialog asking about dependency versions click the "Apply to all items" checkbox, then click the Yes button
  6. Now paste the following code into the Editor (it should be Program.cs by default) (Note: You will have to change the values for Avatar FirstName, LastName and Pasword)

FirstBot Code listing

using System;
using System.Collections.Generic;
using System.Text;
using OpenMetaverse;
namespace FirstBot
    class Program
        // GridClient is the primary class the library uses for almost all things
        private static GridClient Client = new GridClient();
        static void Main(string[] args)
            if (Client.Network.Login("Avatar FirstName", "Avatar LastName", "Avatars Password", "FirstBot", "1.0"))
                // Yay we made it! let's print out the message of the day
                Console.WriteLine("You have successfully logged into Second Life!\n The Message of the day is {0}\nPress any Key to Logout", 
                Console.ReadLine(); // Wait for user to press a key before we continue
                Client.Network.Logout(); // Lets logout since we're done here
                // tell the user why the login failed
                Console.WriteLine("We were unable to login to Second Life, The Login Server said: {0}",
            Console.WriteLine("Press Any Key to Exit");
            Console.ReadLine(); // Wait for user to press a key before we exit

Compile and Run your application

Press your F5 Key to compile and run your FirstBot application

If All went well you should have gotten a message saying you successfully logged in and the message of the day, otherwise you should get a hint at why the login failed.