Regarding ship inventory


#1

hi

I’m trying to make my bot to use boosters from it’s cargo. But it always click the firts row in a list instead of a booster line. Would you please tell me what I’m doing wrong?

string BoosterName = "Agency 'Overclocker' SB5 Dose II";

void UseBooster ()
{
	var BoosterItem = WindowInventory?.SelectedRightInventory?.ListView?.Entry?.FirstOrDefault()?.LabelText?.FirstOrDefault(entry => entry?.Text?.RegexMatchSuccessIgnoreCase(BoosterName) ?? false);
	Sanderling.MouseClickLeft(BoosterItem);
    ClickMenuEntryOnMenuRoot(WindowInventory?.SelectedRightInventory?.ListView?.Entry?.FirstOrDefault(), "Consume");
}

Thank you.


#2

because you take allaways first entry

var BoosterItem = WindowInventory?.SelectedRightInventory?.ListView?.Entry?.FirstOrDefault()?.

or you tape a filter like here(assuming your cargo if full of other items:

 Sanderling.MouseClickLeft(WindowInventory?.InputText?.FirstOrDefault());
    Sanderling.TextEntry(BoosterName );

var RefillListItem = WindowInventory?.SelectedRightInventory?.ListView?.Entry?.ToArray();
    if (!RefillListItem?.IsNullOrEmpty() ?? false)
    Host.Log("              Filling with : " +BoosterName );
    var RefillItem = RefillListItem?.FirstOrDefault();
 ClickMenuEntryOnMenuRoot(WindowInventory?.SelectedRightInventory?.ListView?.Entry?.FirstOrDefault(), "Consume");

or if you have a really big inventory window to fit all items from inside without scrolling, you can create a list with all items where your condition is true and then click on first or default


#3

it works, thank you for your help and explanations!


#4

still i would change to

 Sanderling.MouseClickLeft(WindowInventory?.InputText?.FirstOrDefault());
    Sanderling.TextEntry(BoosterName );
var RefillListItem = WindowInventory?.SelectedRightInventory?.ListView?.Entry?.ToArray();
  var RefillItem = RefillListItem?.FirstOrDefault();
    if (RefillItem  != null) 
    ClickMenuEntryOnMenuRoot(RefillItem , "Consume");
else
 Host.Log("              no more : " +BoosterName );