add support for DefaultHoverHeight and new HoverHeight command

This commit is contained in:
Madpeter 2023-12-01 11:06:33 +00:00
parent 736dd1c539
commit 3e58148299
6 changed files with 52 additions and 1 deletions

View file

@ -25,6 +25,8 @@ COPY --from=publish /app/publish .
ENV basic_Username='' \ ENV basic_Username='' \
basic_Password='' \ basic_Password='' \
basic_LoginURI='secondlife' \ basic_LoginURI='secondlife' \
basic_LogCommands='true' \
basic_DefaultHoverHeight=0.1 \
commands_AllowFundsCommands='false' \ commands_AllowFundsCommands='false' \
commands_AllowIMcontrol='false' \ commands_AllowIMcontrol='false' \
commands_SharedSecret='examplecode' \ commands_SharedSecret='examplecode' \

View file

@ -13,6 +13,24 @@ namespace SecondBotEvents.Commands
{ {
} }
[About("Adjusts Hover height")]
[ReturnHints("ok")]
[ReturnHintsFailure("Convert to float has failed")]
[ReturnHintsFailure("value out of range (-2.0, 2.0)")]
[ArgHints("height", "what height to hover at from (-2.0, 2.0)")]
public object HoverHeight(string height)
{
if (double.TryParse(height, out double level) == false)
{
return Failure("Convert to float has failed", new[] { height });
}
if (SecondbotHelpers.inrange(level, -2.0, 2.0) == false)
{
return Failure("height value out of range(-2.0 to 2.0)", new[] { height });
}
GetClient().Self.SetHoverHeight(level);
return BasicReply("ok", new[] { height });
}
[About("uses the AutoPilot to move to a location")] [About("uses the AutoPilot to move to a location")]
[ReturnHints("Error Unable to AutoPilot to location")] [ReturnHints("Error Unable to AutoPilot to location")]

View file

@ -14,8 +14,13 @@ namespace SecondBotEvents.Config
settings.Add("Password"); settings.Add("Password");
settings.Add("LoginURI"); settings.Add("LoginURI");
settings.Add("LogCommands"); settings.Add("LogCommands");
settings.Add("DefaultHoverHeight");
} }
public double GetDefaultHoverHeight()
{
return ReadSettingAsDouble("DefaultHoverHeight", 0.1);
}
public bool GetLogCommands() public bool GetLogCommands()
{ {
return ReadSettingAsBool("LogCommands"); return ReadSettingAsBool("LogCommands");

View file

@ -169,5 +169,15 @@ namespace SecondBotEvents.Config
} }
return value; return value;
} }
protected double ReadSettingAsDouble(string key, double defaultValue = 0)
{
bool result = double.TryParse(ReadSettingAsString(key, defaultValue.ToString()), out double value);
if (result == false)
{
return defaultValue;
}
return value;
}
} }
} }

View file

@ -1,4 +1,5 @@
using OpenMetaverse; using log4net.Core;
using OpenMetaverse;
using OpenMetaverse.Assets; using OpenMetaverse.Assets;
using SecondBotEvents.Config; using SecondBotEvents.Config;
using Swan; using Swan;
@ -61,6 +62,10 @@ namespace SecondBotEvents.Services
protected void BotSimConnected(object o, SimConnectedEventArgs e) protected void BotSimConnected(object o, SimConnectedEventArgs e)
{ {
if(AutoRestartLoginTimer.Enabled == true)
{
GetClient().Self.SetHoverHeight(basicCfg.GetDefaultHoverHeight());
}
AutoRestartLoginTimer.Stop(); AutoRestartLoginTimer.Stop();
LogFormater.Info("Client service ~ Connected to sim: "+e.Simulator.Name); LogFormater.Info("Client service ~ Connected to sim: "+e.Simulator.Name);
} }

View file

@ -81,6 +81,17 @@ namespace SecondBotEvents
} }
return false; return false;
} }
public static bool inrange(double current, double min, double max)
{
if (current <= max)
{
if (current >= min)
{
return true;
}
}
return false;
}
public static bool inbox(float expected, float current, float drift) public static bool inbox(float expected, float current, float drift)
{ {
return distance_check(expected, current, drift, true); return distance_check(expected, current, drift, true);