Login to a specified location

From libopenmetaverse - libomv - Developer Wiki

Jump to: navigation, search

Contents

Prerequisites

The following prerequisites are required in order for you to create your first bot by following this tutorial.

Real World

  • This tutorial assumes that you were able to successfully build libsecondlife! If you have not compiled libsl, please follow the instructions on the Getting Started wikipage.
  • Also, if you have no experience with the C# (c-sharp) programming language, I highly recommend that you stop now and please follow the list of links to csharp tutorials located here.

The Code

Note: We are assuming that our main "SecondLife" variable is named "client." If you have a different name for this variable, please substitute the name accordingly

  • Csharp code:

 
    string startLocation = NetworkManager.StartLocation("Morris", 128, 128, 128);
    if (client.Network.Login("firstname", "lastname","password","Application Name", startLocation, "Your name"))
    {
        //login success
    }
    else
    {
        //login error
    }
 

Please note the vbcode asumes you are using the vb version of the example bot and that you already have an understanding of vb.net change names accordingly ~deatos

  • VB.net code:

 
Dim startlocation As String = slclient.Network.StartLocation("simname", 0, 0, 0) 'create startlocation string containing the data
' then pass it to slclient.network.login
'......
        If slclient.Network.Login(first_name, last_name, password, "My First Bot", startlocation, "Your name") Then
            Console.WriteLine("Logged in")
        Else
            Console.WriteLine("I couldn't log in, here is why: " + slclient.Network.LoginMessage)
        End If
 

  • Use the Network.Login() method, but add the startLocation variable after the application's name. This startLocation variable is a string that can be constructed using the static method "NetworkManager.StartLocation." The parameters for this method are:
    • Simulator (string) Not case sensitive
    • X (integer) - the local x position you want the bot to login at
    • Y (integer) - the local y position you want the bot to login at
    • Z (integer) - the local z position you want the bot to login at

Notes

  • If you are starting on land, it can be useful to set the z to a couple meters higher than the land's height.. especially if you are running multiple bots all logging in at the same spot.