Terpla adventures or blog-style guide for begginers

Looks like i cant modify reserved post anymore…
After testing my script I found that the ModuleMeasureAllTooltip() function does not work well in a small amount of memory. So I changed it.
Now we specify in the configuration section how many Mining modules we have, how many ShieldBoosters and ArmorRepaiers.

//	Numbers of miner laser
const int MinerLasersCount = 2;
//	Numbers of ShieldBoosters
const int ShieldBoostersCount = 1;
// 	Number of ArmorRepeirs
const int ArmorRepairsCount = 0;

Our function goes through all the modules until it finds the number specified in the configuration.

void ModuleMeasureAllTooltip()
{
	Host.Log("measure tooltips of all modules.");
	
		var shieldBoostersCount = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule.Count(m => m?.TooltipLast?.Value?.IsShieldBooster ?? false);
		var armorRapairCount = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule.Count(m => m?.TooltipLast?.Value?.IsArmorRepairer ?? false);
		var miningLasersCount = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule.Count(m => m?.TooltipLast?.Value?.IsMiner ?? false);

	while( (shieldBoostersCount <  ShieldBoostersCount) ||	(armorRapairCount < ArmorRepairsCount) || (miningLasersCount <  MinerLasersCount)	)
	{
		if(Sanderling.MemoryMeasurementParsed?.Value?.IsDocked ?? false)
			break;
		foreach(var NextModule in Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule)
		{
			if(null == NextModule)
				break;
	
			Host.Log("measure module.");
			//	take multiple measurements of module tooltip to reduce risk to keep bad read tooltip.
			Sanderling.MouseMove(NextModule);
			Sanderling.WaitForMeasurement();
			Sanderling.MouseMove(NextModule);
		}		
	
		shieldBoostersCount = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule.Count(m => m?.TooltipLast?.Value?.IsShieldBooster ?? false);
		armorRapairCount = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule.Count(m => m?.TooltipLast?.Value?.IsArmorRepairer ?? false);
		miningLasersCount = Sanderling.MemoryMeasurementAccu?.Value?.ShipUiModule.Count(m => m?.TooltipLast?.Value?.IsMiner ?? false);
	
		Host.Log("Shield Boosters count = " + shieldBoostersCount + ", Armor Repair count = " + armorRapairCount + ", Mining Lasers Count = " + miningLasersCount );

	}
}

All script can be found here (TPMiningScript-2018-08-02v3)..

3 Likes

Hey Terpla, looks like you have discovered a new bot! Thank you for sharing this with us!
I added a link to this bot to the bot catalog: https://forum.botlab.org/t/bot-4affc743-mining-script-improved-by-terpla-version-tpminingscript-2018-08-02v3/1231

is not simpler to use that?

if(Measurement?.InfoPanelRoute?.IsExpanded == false) Sanderling.MouseClickLeft(toogleButton);
else goto loop;

it happens to stay in space when you don’t travel to a station and he keeps clicking on the toggle button

@Terpla
It’s not caused by memory but by cpu
take a look onto this

it might help you as well :slight_smile:

1 Like

@Terpla
Can we add like this kind of thing ?

string[] BaseOre = new[] {
“Dark Glitter”, “Clear Icicle”, “Gelidus”,
“Mercoxit”, “Bistot”, “Arkonor”,
“Crokite”, “Spodumain”, “Ochre”,
“Gneiss”, “Hedbergite”, “Hemorphite”,
“Jaspet”, “Kernite”, “Omber”,
“Plagioclase”, “Pyroxeres”,
“Scordite”, “Veldspar”

};

string[] ModifierOrePreference = new[] {
“Concentrated Veldspar”, “Dense Veldspar”, “Stable Veldspar”,
“Condensed Scordite”, “Massive Scordite”, “Glossy Scordite”,
“Solid Pyroxeres”, “Viscous Pyroxeres”, “Opulent Pyroxeres”,
“Azure Plagioclase”, “Rich Plagioclase”, “Sparkling Plagioclase”,
“Silvery Omber”, “Golden Omber”, “Platinoid Omber”,
“Luminous Kernite”, “Fiery Kernite”, “Resplendant Kernite”,
“Pure Jaspet”, “Pristine Jaspet”, “Immaculate Jaspet”,
“Vivid Hemorphite”, “Radiant Hemorphite”, “Scintillating Hemorphite”,
“Vitric Hedbergite”, “Glazed Hedbergite”, “Lustrous Hedbergite”,
“Iridescent Gneiss”, “Prismatic Gneiss”, “Brilliant Gneiss”,
“Onyx Ochre”, “Obsidian Ochre”, “Jet Ochre”,
“Bright Spodumain”, “Gleaming Spodumain”, “Dazzling Spodumain”,
“Sharp Crokite”, “Crystalline Crokite”, “Pellucid Crokite”,
“Crimson Arkonor”, “Prime Arkonor”, “Flawless Arkonor”,
“Triclinic Bistot”, “Monoclinic Bistot”, “Cubic Bistot”,
“Magma Mercoxit”, “Vitreous Mercoxit”,
“Gelidus”, “Icicle”, “Dark Glitter”, “Glare Crust”,

I tried but i did not figure out