Spezial Miner Active?


sometime i have Problems that a Strip Miner stop when the Asteroid is empty and away. So i want to make a if condition for that, because when the script toggle to much the miner, the capacity is null.

But i have problems with the syntax, can anyone help me?

var ModuleMinerF1 = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule?.Where(module => module?.TooltipLast?.Value?.ToggleKeyTextLabel?.Text?.RegexMatchSuccessIgnoreCase("F1")?? false);

if (!(ModuleMinerF1?.RampActive && CapacitorPercent > 50){
Sanderling.KeyboardPressCombined(new[]{ VirtualKeyCode.F1});

So i have maybe a result but the logic is wrong:

var ModuleMinerF2 = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule?.Where(module => module?.TooltipLast?.Value?.ToggleKeyTextLabel?.Text?.RegexMatchSuccessIgnoreCase("F2")?? false);
var ModuleMinerF2Inactive = ModuleMinerF1?.Where(module => !(module?.RampActive ?? false))?.ToArray();

if ((ModuleMinerF2Inactive == null)&& (CapacitorPercent > 50)){
Sanderling.KeyboardPressCombined(new[]{ VirtualKeyCode.F2});

Has Someone a hint for me?

look here:
I do an array of inactive modules:
(miners are usual inactive)

//all modules 
Sanderling.Accumulation.IShipUiModule[] SetModuleminer =>
    Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule?.Where(module => module?.TooltipLast?.Value?.IsMiner ?? false)?.ToArray();	

Sanderling.Accumulation.IShipUiModule[] SetModuleminerInactive	 =>
SetModuleminer ?.Where(module => !(module?.RampActive ?? false))?.ToArray();

I take first of them

var SetModuleminerInactive	 = SetModuleSalvagerInactive?.FirstOrDefault();

then if there are modules inactives and capacitor is >50 then:

int? CapacitorPercent => ShipUi?.HitpointsAndEnergy?.Capacitor / 10;
if ((SetModuleminerInactive	 != null)&&(CapacitorPercent >50))
do something
1 Like

It works like a Charm!

Thank You!

1 Like

I know is working; I took them from samples scripts( on mining) and adapted at salvagers :d