Great work, you're really getting the basics now! To load smart I'm guessing the problem lies within you calling "{DEFINE SMART}" AFTER including Aerolib, try the other way around.
Remember what I said earlier about this being a bare-bones script (no pun intended)? The thing that our current color-finding function utilizes CTS1 (ColorToleranceSpeed1) which is very simple: it only look for a color with a certain tolerance. This results in a few problems as there are probably a lot of other items which share the same color. Now is the time to switch to CTS2 which is more accurate and uses hue and sat modifiers to determine the correct color. Don't worry, it's not as advanced as it sounds.
We're gonna use the following function to create a CTS2-color:
color_Item.create(color, tolerance, hue, sat);
All of these values can easily be retrieved by using a nifty tool called ACA, see tutorial
here. When you've got all of the values (color, tolerance, hue, and sat) we can begin.
We previously used color_Item.findIn(Area_MS, pnt) to retrieve a point (the first) where the color is found. Let's step it up and look for ALL of them:
color_Item.findAllIn(Area_MS, TPA);
So what this does is that it searches for all of the point on the mainscreen which have the colors we're looking for, and stores them in an array consisting of TPoints.
What we have so far is:
Simba Code:
var
color_Item : TColEx;
TPA : TPointArray;
begin
color_Item.create(color, tolerance, hue, sat); //replace color, tolerance, hue and sat with respective values (from ACA)
if color_Item.findAllIn(Area_MS, TPA) then
//do stuff
end;
Our current TPA looks like this:
http://i.imgur.com/nAuseJl.png
The red dots are the TPoints found.
Now, to make it easier to find what we're looking for, we're gonna make another array, out of TPA:s! These are called ATPA:s. There are several ways to do this, I'm gonna use TPAtoATPAEx (read more about these
here). What this is gonna do is turn these TPA:s into small boxes, with a specified width and height, like this:
http://i.imgur.com/15L57I2.png
Our code so far:
Simba Code:
var
color_Item : TColEx;
TPA : TPointArray;
begin
color_Item.create(color, tolerance, hue, sat); //replace color, tolerance, hue and sat with respective values (from ACA)
if color_Item.findAllIn(Area_MS, TPA) then
TPAtoATPAEx(TPA, 5, 5); //split these into 5x5 boxes, change these parameters as you like
end;
Now we might wanna sort these ATPA:s a little. It's pretty logical to assume that the place where you're most likely to find a bone is where the ATPA:s are the biggest (biggest = more TPA:s = more matching colors). So let:s sort them from biggest to smallest:
SortATPASize(ATPA, true);
Now what we're gonna do is create a for...to do loop:
Simba Code:
for i := 0 to high(ATPA) do
begin
...
end;
What this loop will do is that it search through every single ATPA, starting at zero. But we want it to actually click something too!
Simba Code:
for i := 0 to high(ATPA) do
begin
pnt := MiddleTPA(ATPA[i]); //set our pnt to the middle of the ATPA
HumanMMouse(pnt, random(5), random(5)); //move the mouse to our point
if isUpTextMulti(['Ta', 'ke B', 'ones']) then //if the uptext is what we want it to be
begin
FastClick(Mouse_right);
ChooseOption(['text', 'here']);
break; //("break" out of the for..to..do loop, we found our point)
end;
end;
So to summarize, here's our new, and improved pickup-procedure!
Simba Code:
{$DEFINE SMART}
{$I AeroLib/AeroLib.simba}
Procedure GetMyStuff()
var
color_Item : TColEx;
TPA : TPointArray;
ATPA : T2DPointArray;
pnt : TPoint;
i : Integer;
begin
color_Item.create(color, tolerance, hue, sat); //replace color, tolerance, hue and sat with respective values (from ACA)
if color_Item.findAllIn(Area_MS, TPA) then
TPAtoATPAEx(TPA, 5, 5); //split these into 5x5 boxes, change these parameters as you like
SortATPASize(ATPA, true); //sort big first, these are the ones who we will search first
for i := 0 to high(ATPA) do
begin
pnt := MiddleTPA(ATPA[i]); //set our pnt to the middle of the ATPA
HumanMMouse(pnt, random(5), random(5)); //move the mouse to our point
if isUpTextMulti(['Ta', 'ke B', 'ones']) then //if the uptext is what we want it to be
begin
FastClick(Mouse_right);
ChooseOptionMulti(['text', 'here']);
break; //("break" out of the for..to..do loop, we found our point)
end;
end;
end;
begin
InitAL;
GetMyStuff();
end.