SRL Archive - Research & Development Lounge

FindObjColorByText


Narcle

2007-10-23 23:46:48

Put in the UpText name and it will start in the center of screen and look around till it finds the UpText then retrieves the color. Once it reaches the edge of the screen it stops looking.

This isn't perfect as you can imagine, but it works Okayish in my Autofigher. ;)

function FindObjColorByText(ObjName:string): integer;//by Narcle
var
xx,yy, MainTimeCount, TimeCount1, TimeCount2, MoP, coloris:integer;
begin
MMouse(258, 180, 1, 1);
MainTimeCount := 1;
GetMousePos(xx, yy);
repeat
repeat
If (MoP = 0) then MMouse(xx,yy-25, 1, 1) else MMouse(xx,yy+25, 1, 1);
GetMousePos(xx, yy);
if IsUpText(ObjName) then
begin
coloris := GetColor(xx,yy);
Writeln('Object color is: '+inttostr(coloris)+' at '+inttostr(xx)+', '+inttostr(yy));
result := coloris;
exit;
end;
TimeCount1 := TimeCount1+1;
until(TimeCount1 = MainTimeCount)
repeat
If (MoP = 0) then MMouse(xx+40,yy, 1, 1) else MMouse(xx-40,yy, 1, 1);
GetMousePos(xx, yy);
if IsUpText(ObjName) then
begin
coloris := GetColor(xx,yy);
Writeln('Object color is: '+inttostr(coloris)+' at '+inttostr(xx)+', '+inttostr(yy));
result := coloris;
exit;
end;
TimeCount2 := TimeCount2+1;
until(TimeCount2 = MainTimeCount)
MainTimeCount := MainTimeCount+1;
TimeCount1 := 0;
TimeCount2 := 0;
if (MoP = 0) then MoP := 1 else MoP := 0;
until(MainTimeCount >= 12)
Writeln('Couldnt find object color!');
result := 0;
end;

R0b0t1

2007-10-25 14:56:51

Hmmm…. Backwards approach, but besides the fact it moves the mouse around a lot its O.K.

Narcle

2007-10-26 19:39:21

yea… not sure how there is a better way (in my experiences so far)

Macrosoft

2007-10-27 00:28:42

how about making it confined to a user set box?

so it would only look for the object in the inventory or something

just sumthin to keep ya busy ;)

Narcle

2007-10-30 03:04:42

From: Macrosoft
how about making it confined to a user set box?

so it would only look for the object in the inventory or something

just sumthin to keep ya busy ;)


Already Done:
function MouseInvText(istextup, option:string; leftclick: Boolean; inv1, inv2, waitfor, xtimes:integer): Boolean; //by Narcle
var
i,x,y, times:integer;
begin
gametab(4);
for i := inv1 to inv2 do
if (ExistsItem(i)) then
begin
MMouseItem(i);
GetMousePos(x, y);
wait(100+random(50));
if (pos(istextup, rs_GetUpText) > 0) then
begin
if (leftclick = true) then
begin
Mouse(x,y,5,5,true);
result := true;
times := times + 1;
end else
begin
Mouse(x,y,5,5,false);
if Chooseoption(option) then
begin
result := true;
times := times + 1;
end;
end;
end;
wait(waitfor+random(100));
if (times = xtimes) then exit;
end else
result := false;
exit;
end;

Its in AutoFight 0.54 ;)

Although this is for inventory only, but its inventory only with many options.