Terpla adventures or blog-style guide for begginers

script
tutorial
sanderling
guide

#21

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)..


Bot 4AFFC743 - Mining script improved by Terpla. Version TPMiningScript-2018-08-02v3
#22

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: Bot 4AFFC743 - Mining script improved by Terpla. Version TPMiningScript-2018-08-02v3


#23

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


#24

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

it might help you as well :slight_smile: