Teleport to another location
From libsecondlife
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.
- A libsl bot that is able to login successfully. If you don't know how to create a libsl bot, please go to the "How to create a basic libSL bot" wikipage
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
//With only a name of a sim and a location client.Self.Teleport("Ahern", new LLVector3(128.0f, 128.0f, 50.0f)); //With the key of a landmark (new!) client.Self.Teleport(new LLUUID("The-key-of-a-landmark"));
You can also fire an event when a Teleport succeeds or fails:
client.Self.OnTeleport += new AgentManager.TeleportCallback(Self_OnTeleport); //Definition of Self_OnTeleport: static void Self_OnTeleport(string message, AgentManager.TeleportStatus status, AgentManager.TeleportFlags flags) { //message contains any messages regarding the teleport //status is an enum of the current teleport status //flags is various flags regarding the teleport }
Notes
- There are overrides for the Teleport Method that allows you to replace the simulator name (the string in the first example) with the region's numerical handle (an unsigned long)
- You can also add a "LookAt" vector that points the avatar at a specific vector location when the avatar teleports.. Just add it as a third parameter to the first example
- Landmarks have built-in LookAt vectors
- See this monodoc page for a listing of teleport statuses
- See this monodoc page for a listing of teleport flags