Method - To call and measure if any rats are on current overview


#1

Need help … want to write a method that will

Check to see if any reds are on active overview and return a value greater than 0 or bool of true …

//global
int test

//somewhere call the method then ..

public int RatTest()
	{
	
		if (Parse.IOverviewEntry[] ListRatOverviewEntry => WindowOverview?.ListView?.Entry?.Where(entry =>(entry?.MainIconIsRed ?? false));
			{
				test = test + 1;
			}
		
		return test;
	}

#2

Reminds me of what the older demo mining script integrated with Sanderling does (not the beginner script, the other one). It attacks rats and as far as I remember it uses red color to identify them.


#3

Yes … I believe the statements involved were …

Sanderling.Parse.IWindowOverview WindowOverview => Measurement?.WindowOverview?.FirstOrDefault();

Parse.IOverviewEntry[] ListRatOverviewEntry => 
					WindowOverview?.ListView?.Entry?.
						Where(entry => (entry?.MainIconIsRed ?? false))?.
						ToArray();

but i can’t seem to figure a way for a var or bool to equal the result of that check


#4

you have var:
c#
var SetRatName =
ListRatOverviewEntry?.Select(entry => Regex.Split(entry?.Name ?? “”, @"\s+")?.FirstOrDefault())
?.Distinct()
?.ToArray();
or you can count the list and use if list.count>0
do: …


#5

Building on the code snippet you posted, I guess you can get the bool with the follwing code:

var anyRatsVisible = (ListRatOverviewEntry?.Any() ?? false);

#6

Viir, how you post the code c# ?


#7

Thanks … that works … i will update my scripting post with new code