Why bookmark doesn't worked?

My code

WindowChatChannel chatLocal =>
     Sanderling.MemoryMeasurementParsed?.Value?.WindowChatChannel
     ?.FirstOrDefault(windowChat => windowChat?.Caption?.RegexMatchSuccessIgnoreCase(“local”) ?? false); 
     
//    assuming that own character is always visible in local
bool hostileOrNeutralsInLocal => 1 != chatLocal?.ParticipantView?.Entry?.Count(IsNeutralOrEnemy); 
bool IsNeutralOrEnemy(IChatParticipantEntry participantEntry) =>
   !(participantEntry?.FlagIcon?.Any(flagIcon =>
     new { “good standing”, “excellent standing”, “Pilot is in your (fleet|corporation)”, }
     .Any(goodStandingText =>
        flagIcon?.HintText?.RegexMatchSuccessIgnoreCase(goodStandingText) ?? false)) ?? false);

var Measurement = Sanderling?.MemoryMeasurementParsed?.Value;

var ManeuverType = Measurement?.ShipUi?.Indication?.ManeuverType;

while(true)
{  
    if(ShipManeuverTypeEnum.Warp == ManeuverType    ||
        ShipManeuverTypeEnum.Jump == ManeuverType)
        goto loop;    //    do nothing while warping or jumping.
        
     if (hostileOrNeutralsInLocal == true){         
        var WPAP = Measurement?.WindowPeopleAndPlaces[0]?.LabelText;        
          string pattern = “base”;
         
          int i = 0;          
        for (i = 0; i < WPAP.Count(); i++){
                Match m = Regex.Match(WPAP.ToArray()[i].Text, pattern, RegexOptions.IgnoreCase);
                if (m.Length > 1){
                break;                
                }
        }
             
         Host.Log(WPAP.ToArray()[i].Text);
         Host.Log(WPAP.ToArray()[i]);
        Sanderling.MouseClickRight(WPAP.ToArray()[i]);            
 
        Host.Delay(1000);

pattern = “Warp Squad to Location Within 0 m”;
          i = 0;          
          Host.Log(Measurement.Menu);
          if (Measurement.Menu != null){
                       
              var menu = Measurement.Menu.ToArray()[0].Entry;
            for (i = 0; i < menu.Count(); i++){
                    Match m = Regex.Match(menu.ToArray()[i].Text, pattern, RegexOptions.IgnoreCase);
                    if (m.Length > 1){ 
                    break;                        
                    } 
            }
            
            Sanderling.MouseClickRight(menu.ToArray()[i]);        
        } 
        
     }
loop:
    //    wait for four seconds before repeating.
    Host.Delay(3000);
    //    make sure new measurement will be taken.
    Sanderling.InvalidateMeasurement();
}

i use bookmark, solar fleeet, but that doesn’t worked

What should the bot do? Create a bookmark?

Which part of your code does not work as you expect? Where does the execution deviate from your expectation?

  1. Check local
  2. If have enemy, then go to base at bookmark. Bookmark doesn’t always workedbut sometimes all is well

Here in your loop you use the Measurement you have taken at the beginning of the script:

var menu = Measurement.Menu.ToArray()[0].Entry;

That seems at odds with the goal you stated.

You can change those variables which are assigned at the start to properties to have them evaluated again at each access:

Sanderling.Parse.IMemoryMeasurement Measurement => Sanderling?.MemoryMeasurementParsed?.Value;Nullable<ShipManeuverTypeEnum> ManeuverType => Measurement?.ShipUi?.Indication?.ManeuverType;
1 Like

In case the bookmark still not works after that change, you can use the bookmark code from the sample mining script which has been tested by many users and implement it like this:

while(true){     if (hostileOrNeutralsInLocal)         InitiateDockToOrWarpToBookmark("base");}  bool InitiateDockToOrWarpToBookmark(string bookmarkOrFolder) {     Host.Log("dock to or warp to bookmark or random bookmark in folder: '" + bookmarkOrFolder + "'");          var listSurroundingsButton = Measurement?.InfoPanelCurrentSystem?.ListSurroundingsButton;          Sanderling.MouseClickRight(listSurroundingsButton);          var bookmarkMenuEntry = Measurement?.Menu?.FirstOrDefault()?.EntryFirstMatchingRegexPattern("^" + bookmarkOrFolder + "$", RegexOptions.IgnoreCase);      if(null == bookmarkMenuEntry)     {         Host.Log("menu entry not found for bookmark or folder: '" + bookmarkOrFolder + "'");         return true;     }      var currentLevelMenuEntry = bookmarkMenuEntry;      for (var menuLevel = 1; ; ++menuLevel)     {         Sanderling.MouseClickLeft(currentLevelMenuEntry);          var menu = Measurement?.Menu?.ElementAtOrDefault(menuLevel);         var dockMenuEntry = menu?.EntryFirstMatchingRegexPattern("dock", RegexOptions.IgnoreCase);         var warpMenuEntry = menu?.EntryFirstMatchingRegexPattern(@"warp.*withins*0", RegexOptions.IgnoreCase);         var approachEntry = menu?.EntryFirstMatchingRegexPattern(@"approach", RegexOptions.IgnoreCase);          var maneuverMenuEntry = dockMenuEntry ?? warpMenuEntry;          if (null != maneuverMenuEntry)         {             Host.Log("initiating '" + maneuverMenuEntry.Text + "' on entry '" + currentLevelMenuEntry?.Text + "'");             Sanderling.MouseClickLeft(maneuverMenuEntry);             return false;         }          if (null != approachEntry)         {             Host.Log("found menu entry '" + approachEntry.Text + "'. Assuming we are already there.");             return false;         }          var setBookmarkOrFolderMenuEntry =             menu?.Entry;    //    assume that each entry on the current menu level is a bookmark or a bookmark folder.          var nextLevelMenuEntry = RandomElement(setBookmarkOrFolderMenuEntry);          if(null == nextLevelMenuEntry)         {             Host.Log("no suitable menu entry found");             return true;         }          currentLevelMenuEntry = nextLevelMenuEntry;     } }