Random mining site not work with Bookmark anymore?

Hi there

i search for a failrue in my mining script.

When the script dident found no more useable asteroids in his belt, it has to jump to another in the bookmark list. but it wont work… i have search but for me all looks fine. it allways use only the upper belt.
So when all useabel asteroids are away the script get a error after a long while.

The Script Mining_script_V2.4 D Plagioclase - Pastebin.com

i think the call is in line 265:

if(!(0 < ListAsteroidOverviewEntry?.Length))
		{
			if(ShouldUseMiningBookmarks){
				Host.Log("InitiateWarpToRandomMiningBookmark()");
				InitiateWarpToRandomMiningBookmark();
			}else{
				Host.Log("InitiateWarpToMiningSite()");
				InitiateWarpToMiningSite();
			}
			//InitiateWarpToRandomMiningSite();
			//InitiateWarpToMiningSite();
		}

with

bool InitiateWarpToRandomMiningBookmark() =>
	InitiateDockToOrWarpToLocationInSolarSystemMenu(RandomElement(SetMiningSiteBookmark));

and the workpart

bool InitiateDockToOrWarpToLocationInSolarSystemMenu(
	string submenuLabel,
	Func<IReadOnlyList<MemoryStruct.IMenuEntry>, MemoryStruct.IMenuEntry> pickPreferredDestination = null)
{	
	Host.Log("Attempt to initiate dock to or warp to menu entry in submenu '" + submenuLabel + "'");
	
	DroneEnsureInBay();
	
	var listSurroundingsButton = Measurement?.InfoPanelCurrentSystem?.ListSurroundingsButton;
	
	Sanderling.MouseClickRight(listSurroundingsButton);

	var submenuEntry = Measurement?.Menu?.FirstOrDefault()?.EntryFirstMatchingRegexPattern("^" + submenuLabel + "$", RegexOptions.IgnoreCase);

	if(null == submenuEntry)
	{
		Host.Log("Submenu '" + submenuLabel + "' not found in the solar system menu.");
		return true;
	}

	Sanderling.MouseClickLeft(submenuEntry);

	var submenu = Measurement?.Menu?.ElementAtOrDefault(1);

	var destinationMenuEntry = pickPreferredDestination?.Invoke(submenu?.Entry?.ToList()) ?? submenu?.Entry?.FirstOrDefault();

	if(destinationMenuEntry == null)
	{
		Host.Log("Failed to open submenu '" + submenuLabel + "' in the solar system menu.");
		return true;
	}

	Sanderling.MouseClickLeft(destinationMenuEntry);

	var actionsMenu = Measurement?.Menu?.ElementAtOrDefault(2);

	if(destinationMenuEntry == null)
	{
		Host.Log("Failed to open actions menu for '" + destinationMenuEntry.Text + "' in the solar system menu.");
		return true;
	}

	var dockMenuEntry = actionsMenu?.EntryFirstMatchingRegexPattern("dock", RegexOptions.IgnoreCase);
	var warpMenuEntry = actionsMenu?.EntryFirstMatchingRegexPattern(@"warp.*within.*m", RegexOptions.IgnoreCase);
	var approachEntry = actionsMenu?.EntryFirstMatchingRegexPattern(@"approach", RegexOptions.IgnoreCase);

	var maneuverMenuEntry = dockMenuEntry ?? warpMenuEntry;

	if (null != maneuverMenuEntry)
	{
		Host.Log("initiating '" + maneuverMenuEntry.Text + "' on '" + destinationMenuEntry?.Text + "'");
		Sanderling.MouseClickLeft(maneuverMenuEntry);
		return false;
	}

	if (null != approachEntry)
	{
		Host.Log("found menu entry '" + approachEntry.Text + "'. Assuming we are already there.");
		return false;
	}

	Host.Log("no suitable menu entry found on '" + destinationMenuEntry?.Text + "'");
	return true;
}

Thanks for help in advanced!

1 Like

I think basically you are in Fct InBeltMineSite since you already warped to belt and see the is no more rocks
your line
520

is     if(null == asteroidOverviewEntryNext)
    {
        Host.Log("no asteroid available");
        return null;
    }

replace null with mainstep, so he go to mainstep when there are no more rocks

1 Like

WOW! have you xray eyes? ok i have make the change, script works fine, but i need time to make the next belt empty :wink:
but randomizing belt still not work… maybe it not works for Bockmarks?

stay tuned for results :slight_smile:

Oh yes, that.
Sorry I didn’t see that ( I use glasses, not xray’s)
From what I see, you wanna use InitiateDockToOrWarpToLocationInSolarSystemMenu ( from begginers mining script) and randomise the belts like it was done in mine ore script ( who take bookmarks). hmmm it doesn’t work like that because first it record the belts and take them in order, the second use random generated numbers.
But you are a lucky man; I have just done a snipet to use listsurroundingsbutton and warp to random belts, like in bookmark. Look on my intel script: Intel script

string Folder = "asteroid belts";
int RandomInt() => new Random((int)Host.GetTimeContinuousMilli()).Next();
T RandomElement<T>(IEnumerable<T> sequence)
{
    var array = (sequence as T[]) ?? sequence?.ToArray();
 
    if (!(0 < array?.Length))
        return default(T);
 
    return array[RandomInt() % array.Length];
}
void WarpToRandomFromFolder(string Folder,  string actions)
{
var listSurroundingsButton = Measurement?.InfoPanelCurrentSystem?.ListSurroundingsButton;

Sanderling.MouseClickRight(listSurroundingsButton);
var bookmarkMenuEntry = Measurement?.Menu?.FirstOrDefault()?.EntryFirstMatchingRegexPattern("^" + Folder + "$", RegexOptions.IgnoreCase);
Sanderling.MouseClickRight(bookmarkMenuEntry);
var Menu = Sanderling?.MemoryMeasurementParsed?.Value?.Menu?.ElementAtOrDefault(1);
var SecondLevelMenuEntry = RandomElement(Menu.Entry?.ToArray());
Sanderling.MouseClickLeft(SecondLevelMenuEntry);
if (actions != null)
{
var subMenu = Sanderling?.MemoryMeasurementParsed?.Value?.Menu?.ElementAtOrDefault(2);
var subMenuEntry = subMenu?.EntryFirstMatchingRegexPattern(actions, RegexOptions.IgnoreCase);
Sanderling.MouseClickLeft(subMenuEntry);
}
}

and use him like that:

WarpToRandomFromFolder(Folder, "warp");

you can use him directly with “asteroid belts” folder from system , or create your own folder with saved bookmarks
it warp at zero, if you want to warp at 30 or 100km, you have to change a little more this snipet

2 Likes

well this looks very good for randomising! i think i have search for this solutions! when i hav time try to buil it in!

for my main question:
it dident work with the “mainstep”.
the bot still try to fly to the first site in the bookmarkfolder when all asteroids with plagioclase are away.

Now i understand what you say :slight_smile:
so you have a list of bookmarks ; at a moment, you warp again at the empty bookmarks.

in this case firstly you have to create a array/list with all bookmarks.when it is epty, you simply delete the entry. you have to record position for that.

i have a list of bookmarks and i declare at line 41

//	Bookmarks of places to mine. Add additional bookmarks separated by comma.
string[] SetMiningSiteBookmark = new[] {
	"Mining",
	};

there is one Folder, ad now it wil lbe good when i can use tham random or first, second, an so on.

image

EDIT:
i make a test with multiple folders!
image
I think thats the function… …lets have a try

So you want to take the belt frombookmark and when his veldspar is finished (your mineral) to put the belt on waiting list , so you do not take same belt for a while?

a no :slight_smile: the bot flys after offload randomized to a another belt :wink: when on is empty he flys random to next one…

but in the moment bot wont running… i think something is happens with the license server… so i will test after license server running again :slight_smile:

hello!
I have test the randomizing when i fill the array with multple bookmarks and now it works! so i have missanderstood the funktion befor.

//	Bookmarks of places to mine. Add additional bookmarks separated by comma.
string[] SetMiningSiteBookmark = new[] {
	"Mining00","Mining01","Mining02","Mining03","Mining04","Mining",
	};
2 Likes