Using arrays to selectively color search.(HELP! with main screen item finding)
For my program im having trouble finding bones on the ground. The FindMSColorTol keeps mistaking the chickens and daisy's for bones, and searching them for uptext. I though of an idea to use tpointarrays(but couldnt get it to work) so I tried using regular arrays. The idea was this:
Find a color
mouse over the color
check the up text
if it is not 'take'
add the x,y to an array
find another instance of the color
if that color is less than 30 pixels away than the coordinates in the array
search for a different instance.
else
check it for its up text
if the up text is 'take'
then click on it
else
add those x,y to the array.
search for another instance of the color
and so on.
I got the following together, but it only works once. finds the color, adds it to the array, looks for another color, and gives up( but the program is still running)....wait a sec.... is this because of how Find MSColorTol works? what is happening here is that it is continually looking at the same spot(therefore triggering the function that the color is not more than 30 pixels away, so find another instance(but it just continues to find the same instance)...DAMMIT!! 2 hours of work wasted!!!
Oh well, im not going to give up. If someone could show me how to find items on the ground(in an area where there are similar non item colors such as bones near chickens) it would be GREATLY appreciated and +rep.
SCAR Code:
program BoneCollectorAndBurier;
{.include srl/srl.scar}
var
NormalBoneDTM,bone,NoBone,i:Integer;
NoBoneCoordsX,NoBoneCoordsY:array of Integer;
const
BonesToBury=50;
Procedure LoadDTMs;
begin
NormalBoneDTM := DTMFromString('78DA635CC9C4C02007C448E0FCF1E30CFF813' +
'42310FF0702C6E5407951543510591809A43700E5A551D5182828' +
'A0AA590394572060CE12A0BC2A0135F380F2B2F8D50000EC180C8' +
'F');
end;
Procedure prepareClient;
begin
SetupSRL;
Cleardebug;
ActivateClient;
LoadDTMs;
MakeCompass('N');
HighestAngle;
//SetRun(true);
NoBone:=0;
end;
Procedure NotABoneCoords(nxc,nyc:Integer);
begin
writeln('doing bone procedure');
SetArrayLength(NoBoneCoordsX,NoBone+1)
SetArrayLength(NoBoneCoordsY,NoBone+1)
NoBoneCoordsX[NoBone]:=nxc
NoBoneCoordsY[NoBone]:=nyc
writeln(inttoStr(NoBoneCoordsX[NoBone]));
writeln(inttoStr(NoBoneCoordsY[NoBone]));
end;
Function IsNotABone(nx,ny,nb:Integer):boolean;
begin
i:=0
writeln('doing bone function');
while i<nb do
begin
writeln('works');
if ((nx+30<NoBoneCoordsX[i])or
(nx-30>NoBoneCoordsX[i]))and
((ny+30<NoBoneCoordsY[i])or
(ny-30>NoBoneCoordsY[i])) then
begin
Result:=false
writeln('returned false');
end;
i:=i+1
end;
end;
Procedure FindBones;
begin
repeat
repeat
FindMSColorTol(x,y,11316663,5)
if (not(IsNotABone(x,y,NoBone)))then
begin
MMouse(x,y,0,0)
wait(10+random(10));
end;
if (not(isUpText('ake')))then
begin
NotABoneCoords(x,y);
NoBone:=NoBone+1
end;
until(isUpText('ake'))
Mouse(x, y, 2, 2, False);
Wait(150 + Random(100));
ChooseOption(x,y,'ones')
flag;
Wait(100+Random(150));
until(InvFull)
end;
begin
prepareClient;
FindBones;
end.