Update Movement.cs
This commit is contained in:
parent
aefd1936bb
commit
25e8e68684
1 changed files with 33 additions and 24 deletions
|
|
@ -254,45 +254,54 @@ namespace BetterSecondBot.HttpService
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[About("Attempt to teleport to a new region via a SL url")]
|
||||||
|
[ReturnHints("slurl is empty")]
|
||||||
|
[ReturnHints("True|False")]
|
||||||
|
[ArgHints("slurl", "Text", "a full SLurl")]
|
||||||
|
[Route(HttpVerbs.Post, "/TeleportSLURL/{token}")]
|
||||||
|
public object TeleportSLURL([FormField] string slurl, string token)
|
||||||
|
{
|
||||||
|
if (tokens.Allow(token, "movement", "TeleportSLURL", handleGetClientIP()) == false)
|
||||||
|
{
|
||||||
|
return Failure("Token not accepted");
|
||||||
|
}
|
||||||
|
if(helpers.notempty(slurl) == false)
|
||||||
|
{
|
||||||
|
return Failure("slurl is empty");
|
||||||
|
}
|
||||||
|
return BasicReply(TeleportRequest(new string[] { slurl }).ToString());
|
||||||
|
}
|
||||||
|
|
||||||
protected bool TeleportRequest(string[] args)
|
protected bool TeleportRequest(string[] args)
|
||||||
{
|
{
|
||||||
bot.GetClient.Self.AutoPilotCancel();
|
bot.GetClient.Self.AutoPilotCancel();
|
||||||
if (args[0].Contains("http://maps.secondlife.com/secondlife/") == true)
|
if (args[0].Contains("http://maps.secondlife.com/secondlife/") == true)
|
||||||
{
|
{
|
||||||
bot.TeleportWithSLurl(args[0]);
|
if (bot.TeleportWithSLurl(args[0]) == "ok")
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float posX = 128;
|
List<string> argvalues = new List<string>(args);
|
||||||
float posY = 128;
|
if(argvalues.Count == 3)
|
||||||
float posZ = 0;
|
{
|
||||||
string regionName = bot.GetClient.Network.CurrentSim.Name;
|
string regionName = bot.GetClient.Network.CurrentSim.Name;
|
||||||
bool ok = true;
|
argvalues = new List<string>() { regionName };
|
||||||
int offset = 0;
|
argvalues.AddRange(args);
|
||||||
string[] tp_args = args[0].Split('/');
|
|
||||||
if ((tp_args.Length == 4) || (tp_args.Length == 1))
|
|
||||||
{
|
|
||||||
regionName = tp_args[0];
|
|
||||||
offset = 1;
|
|
||||||
}
|
}
|
||||||
if (tp_args.Length >= 3)
|
if (argvalues.Count == 4)
|
||||||
{
|
|
||||||
float.TryParse(tp_args[offset + 0], out posX);
|
|
||||||
float.TryParse(tp_args[offset + 1], out posY);
|
|
||||||
float.TryParse(tp_args[offset + 2], out posZ);
|
|
||||||
}
|
|
||||||
else if (tp_args.Length == 2)
|
|
||||||
{
|
|
||||||
ok = false;
|
|
||||||
}
|
|
||||||
if (ok == true)
|
|
||||||
{
|
{
|
||||||
|
string regionName = argvalues[0];
|
||||||
|
float.TryParse(argvalues[1], out float posX);
|
||||||
|
float.TryParse(argvalues[2], out float posY);
|
||||||
|
float.TryParse(argvalues[3], out float posZ);
|
||||||
bot.SetTeleported();
|
bot.SetTeleported();
|
||||||
bool status = bot.GetClient.Self.Teleport(regionName, new Vector3(posX, posY, posZ));
|
bool status = bot.GetClient.Self.Teleport(regionName, new Vector3(posX, posY, posZ));
|
||||||
bot.ResetAnimations();
|
bot.ResetAnimations();
|
||||||
return status;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue