Unload ore into space

Hello, Arcitectus!

Teach me please how to write code to unload ore into space (for fleet mining)?

settings group:

//Use station true - unload to UnloadDestContainerName, false - unload to space

var UseStation = false;

Code:

if(UseStation){
        if(Measurement?.IsDocked ?? false)
        {
            InInventoryUnloadItems();
            if (EmergencyWarpOutEnabled)
                return BotStopActivity;
            Undock();
        }
    }
    else{
        ****drop to space   
            if (EmergencyWarpOutEnabled)
                return BotStopActivity;
        }
    }

finction for UnloadToSpace:

check active ship ore hold →  select all → jettison.

===============

Also I translated some code for russian client.

Of course, I did not translate all features but only for the ore mining. Ice harvesting not tested (information of distance harvesting is not translated yet in the program code) because I has not yet learned this method. I can share the Russian version, with everyone on the forum if you greet it. It would be very nice if you have transferred the words (that program is parsing from client) to a lang file, for international users.

Sorry for my bad English - I used a translator. Thank you for a good program, good luck!

Try this

 void DropToStace() {     EnsureWindowInventoryOpenOreHold();    // Fonction is present in the mining script     var OreHoldItem = WindowInventory?.SelectedRightInventory?.ListView?.Entry?.FirstOrDefault();     ClickMenuEntryOnMenuRoot(OreHoldItem, "Select All");// Fonction is present in the mining script     ClickMenuEntryOnMenuRoot(OreHoldItem, "^Jettison");     var BoxJettison = Measurement?.WindowOther?.FirstOrDefault()?.LabelText?.FirstOrDefault(text => text.Text.RegexMatchSuccessIgnoreCase("Jettison") );     var YesButton = Measurement?.WindowOther?.FirstOrDefault()?.ButtonText?.FirstOrDefault(text => text.Text.RegexMatchSuccessIgnoreCase("Yes") );     if(BoxJettison != null)         Sanderling.MouseClickLeft(YesButton); }
2 Likes

Hello, Arcitectus!

Teach me please how to write code to unload ore into space (for fleet mining)?

[…]

finction for UnloadToSpace:

check active ship ore hold →  select all → jettison.

I would first try this:

  • to open the ore hold reuse the function from the included mining script.
  • get a reference to one of the items in the ore hold.
  • open a menu on that item
  • click menu entry “select all”
  • open a menu again on that item
  • click menu entry “jettison”

I suggest you try the code posted by Without and then modify it for more robustness: The way the window is choosen from “WindowOther” in that code looks fragile to me. The property “WindowOther” can contain different kinds of windows. You can exclude other windows for example by constraining to modal windows. The code would then look like this:

     var ConfirmWindow = Measurement?.WindowOther?.FirstOrDefault(w => w?.isModal ?? false);     var ConfirmButton = ConfirmWindow.ButtonText?.FirstOrDefault(text => text.Text.RegexMatchSuccessIgnoreCase("Yes") );     if(ConfirmButton != null)          Sanderling.MouseClickLeft(ConfirmButton);

===============

Also I translated some code for russian client.

Of course, I did not translate all features but only for the ore mining. Ice harvesting not tested (information of distance harvesting is not translated yet in the program code) because I has not yet learned this method. I can share the Russian version, with everyone on the forum if you greet it.

Yes, I would appreciate it if you share the translation. We have quite some users here who will understand russian, but I don’t know how important it is for them to use the russian localization in the game client.

It would be very nice if you have transferred the words (that program is parsing from client) to a lang file, for international users.

The current plan to solve this is by making it easier integrate and modify the code for parsing in the code which is compiled with the script. I am working on a development tool to enable this.

1 Like

I missed some important detail in the last code I posted. This would be better:

     var ConfirmWindow = Measurement?.WindowOther?.FirstOrDefault(w =>          (w?.LabelText?.Any(label => label.Text.RegexMatchSuccessIgnoreCase("Jettison")) ?? false) && (w?.isModal ?? false));      var ConfirmButton = ConfirmWindow.ButtonText?.FirstOrDefault(text => text.Text.RegexMatchSuccessIgnoreCase("Yes") );      if(ConfirmButton != null)           Sanderling.MouseClickLeft(ConfirmButton);

As I understand the code posted by Without, it would only work when the window to confirm happens to be the first one in “WindowOther”.

Maybe the “jettison” text is also to be found in the Caption of the window, then this would suffice:

    var ConfirmWindow = Measurement?.WindowOther?.FirstOrDefault(w =>          (w?.Caption.RegexMatchSuccessIgnoreCase("Jettison") ?? false) && (w?.isModal ?? false));

thank you guys.
I’m happy as an elephant!
That’s what I did:

//Использовать станцию, POS - true, или выкидывать в космос - false.
var UseStation = false;

// Func<object> MainStep() code segment:if(UseStation){ if(Measurement?.IsDocked ?? false) { InInventoryUnloadItems(); if (EmergencyWarpOutEnabled) return BotStopActivity; Undock(); } } else{ DropToSpace();  Host.Log("сбрасываю руду в космос.");  if (EmergencyWarpOutEnabled) return BotStopActivity; } // Func<object> InBeltMineStep() code segment:if(UseStation){ if(OreHoldFilledForOffload) return null; } else{ if(OreHoldFilledForOffload) DropToSpace();  Host.Log("ВНИМАНИЕ! Активирован режим сброса руды в космос."); }// сброс руды за бортvoid DropToSpace() { EnsureWindowInventoryOpenOreHold(); // Fonction is present in the mining script var OreHoldItem = WindowInventory?.SelectedRightInventory?.ListView?.Entry?.FirstOrDefault(); ClickMenuEntryOnMenuRoot(OreHoldItem, "Выбрать все");// Fonction is present in the mining script ClickMenuEntryOnMenuRoot(OreHoldItem, "^Сбросить за борт"); var BoxJettison = Measurement?.WindowOther?.FirstOrDefault()?.LabelText?.FirstOrDefault(text => text.Text.RegexMatchSuccessIgnoreCase("Сбросить за борт") ); var YesButton = Measurement?.WindowOther?.FirstOrDefault()?.ButtonText?.FirstOrDefault(text => text.Text.RegexMatchSuccessIgnoreCase("Да") ); if(BoxJettison != null) Sanderling.MouseClickLeft(YesButton); //var ConfirmWindow = Measurement?.WindowOther?.FirstOrDefault(w => w?.isModal ?? false); // var ConfirmButton = ConfirmWindow.ButtonText?.FirstOrDefault(text => text.Text.RegexMatchSuccessIgnoreCase("Да") ); // if(ConfirmButton != null) // Sanderling.MouseClickLeft(ConfirmButton);  }

also have wished to see a button to “delete code” in the script editing window. wink

It will be very comfortable for a quick change of scripts.

What do you think about it?

CTRL+A, DELETE

2 Likes

CTRL+A, DELETE

Ops… im nooblaughing

J’ai un petit problème avec :

Maybe the “jettison” text is also to be found in the Caption of the window, then this would suffice:

    var ConfirmWindow = Measurement?.WindowOther?.FirstOrDefault(w =>          (w?.Caption.RegexMatchSuccessIgnoreCase("Jettison") ?? false) && (w?.isModal ?? false));

Caption est toujours null!?