Every few seconds, the Sanderling reads the memory and enters the values into variables:
- MemoryMeasurement - raw memory data
- MemoryMeasurementParsed - converted data for easier use
- MemoryMeasurementAccu - accumulates data that will not change in the future (for example, a set of ship modules)
while(true) // this code will be executed infinitely again and again
{
// We write to the variable the result of reading the memory for a shorter path.
var Measurement = Sanderling?.MemoryMeasurementParsed?.Value;
// Every window in eve represent as object in MemoryMeasurementParsed?.Value
// (see the screenshot below)
// So, ShipUI contains information about what our ship doing now:
// warp, jump trought gate, docked, orbiting, etc.
var ManeuverType = Measurement?.ShipUi?.Indication?.ManeuverType;
if(ShipManeuverTypeEnum.Warp == ManeuverType ||
ShipManeuverTypeEnum.Jump == ManeuverType)
goto loop; // do nothing while warping or jumping.
// Let's skip some code
loop:
// wait for four seconds before repeating.
Host.Delay(4000);
// If you do not want to wait for the next memory reading, you can force this.
Sanderling.InvalidateMeasurement();
}
Some windows from MemoryMeasurementParsed?.Value:
So if we warp or jump through the gate this code wait 4 seconds and start again. Now i want add improvement: some indication about the completion of the trip. So let’s add some sound if our ship is docked.
while(true)
{
var Measurement = Sanderling?.MemoryMeasurementParsed?.Value;
var ManeuverType = Measurement?.ShipUi?.Indication?.ManeuverType;
if(Measurement.IsDocked ?? true) // if Measurement.IsDocked == true or null then
{
Console.Beep(500, 200); // play sound
Host.Delay(6000); // wait 6 sec
goto loop;
}
if(ShipManeuverTypeEnum.Warp == ManeuverType ||
ShipManeuverTypeEnum.Jump == ManeuverType)
goto loop;
loop:
Host.Delay(4000);
Sanderling.InvalidateMeasurement();
}
Why we use
if(Measurement.IsDocked ?? true)
instead of
if(ShipManeuverTypeEnum.Docked == ManeuverType)
for example?
Because our ManeuverType is obtained from the Measurement?.ShipUi, but when we are docked this part of the interface is not available and ShipUi == null.
Also you can use
System.Media.SoundPlayer simpleSound = new System.Media.SoundPlayer(@"path to your Sound.wav");
simpleSound.Play();
instead of Console.Beep.
Ok, Let’s do more improvements. Sometimes script can missclick and close InfoPanelRoute. In this case our RouteElementMarker == null and autopilot will stuck with “no route found in info panel” message:
// from the set of route element markers in the Info Panel pick the one that represents the next Waypoint/System.
// We assume this is the one which is nearest to the topleft corner of the Screen which is at (0,0)
var RouteElementMarkerNext =
Measurement?.InfoPanelRoute?.RouteElementMarker
?.OrderByCenterDistanceToPoint(new Vektor2DInt(0, 0))?.FirstOrDefault();
if(null == RouteElementMarkerNext)
{
Host.Log("no route found in info panel.");
goto loop;
}
In this case, we can try clicking on the ExpandToggleButton:
// from the set of route element markers in the Info Panel pick the one that represents the next Waypoint/System.
// We assume this is the one which is nearest to the topleft corner of the Screen which is at (0,0)
var RouteElementMarkerNext =
Measurement?.InfoPanelRoute?.RouteElementMarker
?.OrderByCenterDistanceToPoint(new Vektor2DInt(0, 0))?.FirstOrDefault();
if(null == RouteElementMarkerNext)
{
Host.Log("no route found in info panel.");
// if we found our button and it's not null
var toogleButton = Measurement?.InfoPanelRoute?.ExpandToggleButton;
if(toogleButton !=null) Sanderling.MouseClickLeft(toogleButton); // click him
goto loop;
}
Well done.