git-svn-id: http://libopenmetaverse.googlecode.com/svn/trunk@279 52acb1d6-8a22-11de-b505-999d5b087335
111 lines
3.4 KiB
C#
111 lines
3.4 KiB
C#
using System;
|
|
using System.Collections;
|
|
|
|
using libsecondlife;
|
|
|
|
|
|
namespace Teleport
|
|
{
|
|
class Teleport
|
|
{
|
|
protected SecondLife client;
|
|
|
|
static void Main(string[] args)
|
|
{
|
|
if (args.Length < 4)
|
|
{
|
|
Console.WriteLine("Usage: Teleport [loginfirstname] [loginlastname] [password] [sim/x/y/z]");
|
|
return;
|
|
}
|
|
|
|
char[] seps = { '/' };
|
|
string[] destination = args[3].Split(seps);
|
|
if( destination.Length != 4 )
|
|
{
|
|
Console.WriteLine("Destination should be specified as: sim/x/y/z");
|
|
return;
|
|
}
|
|
|
|
string sim = destination[0];
|
|
float x = float.Parse(destination[1]);
|
|
float y = float.Parse(destination[2]);
|
|
float z = float.Parse(destination[3]);
|
|
|
|
Console.WriteLine("Will attempt a teleport to " + sim + " {" + x + "," + y + "," + z + "}...");
|
|
Console.WriteLine();
|
|
|
|
Teleport app = new Teleport();
|
|
app.Connect(args[0], args[1], args[2]);
|
|
app.doStuff(sim, new LLVector3(x,y,z));
|
|
app.Disconnect();
|
|
|
|
}
|
|
|
|
protected Teleport()
|
|
{
|
|
try
|
|
{
|
|
client = new SecondLife();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
// Error initializing the client
|
|
Console.WriteLine();
|
|
Console.WriteLine(e.ToString());
|
|
}
|
|
}
|
|
|
|
protected void Connect(string FirstName, string LastName, string Password)
|
|
{
|
|
Console.WriteLine("Attempting to connect and login to SecondLife.");
|
|
|
|
// Setup Login to Second Life
|
|
Hashtable loginParams = NetworkManager.DefaultLoginValues(FirstName, LastName, Password, "00:00:00:00:00:00",
|
|
"last", 1, 12, 12, 12, "Win", "0", "createnotecard", "static.sprocket@gmail.com");
|
|
Hashtable loginReply = new Hashtable();
|
|
|
|
// Login
|
|
if (!client.Network.Login(loginParams))
|
|
{
|
|
// Login failed
|
|
Console.WriteLine("Error logging in: " + client.Network.LoginError);
|
|
return;
|
|
}
|
|
|
|
// Login was successful
|
|
Console.WriteLine("Login was successful.");
|
|
Console.WriteLine("AgentID: " + client.Network.AgentID);
|
|
Console.WriteLine("SessionID: " + client.Network.SessionID);
|
|
}
|
|
|
|
protected void Disconnect()
|
|
{
|
|
// Logout of Second Life
|
|
Console.WriteLine("Request logout");
|
|
client.Network.Logout();
|
|
}
|
|
|
|
protected void doStuff(string sim, LLVector3 coords)
|
|
{
|
|
System.Threading.Thread.Sleep(5000);
|
|
Console.WriteLine();
|
|
Console.WriteLine("Okay, hopefully all the initial connect stuff is done, trying now...");
|
|
|
|
client.Avatar.OnTeleport += new TeleportCallback(Avatar_OnTeleportMessage);
|
|
|
|
|
|
client.Avatar.Teleport(sim, coords);
|
|
|
|
System.Threading.Thread.Sleep(15000);
|
|
|
|
Console.WriteLine("Press Enter to finish");
|
|
Console.ReadLine();
|
|
}
|
|
|
|
protected void Avatar_OnTeleportMessage(string message)
|
|
{
|
|
Console.WriteLine(message);
|
|
}
|
|
}
|
|
}
|