SRL Archive - SRL Archives

Some functions...


Cazax

2008-03-23 15:33:17

I wrote some functions:

- function A:
function SmeltingScreen: boolean;
var
x,y : integer;
begin
result := FindText(x, y, 'smelt', npcchars, 155, 354, 374, 387);
end;
for smithing.scar.

- function B:
function FindCookedFishInInv(Tol : integer; var x,y : integer; fish : string): boolean;
begin
GameTab(4);
case lowercase(fish) of
'shrimps': if FindBitmapToleranceIn(srl_GetBitmap(76), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'anchovies': if FindBitmapToleranceIn(srl_GetBitmap(77), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'tuna': if FindBitmapToleranceIn(srl_GetBitmap(78), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'trout': if FindBitmapToleranceIn(srl_GetBitmap(79), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'pike': if FindBitmapToleranceIn(srl_GetBitmap(80), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'salmon': if FindBitmapToleranceIn(srl_GetBitmap(81), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'lobster': if FindBitmapToleranceIn(srl_GetBitmap(82), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'swordfish': if FindBitmapToleranceIn(srl_GetBitmap(83), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
else
Writeln('Invalid option');
Result := False;
end; // case
end;
for cooking.scar, you have to include srl/srl/misc/bitmaps.scar, but, it gave me this error:
Line 14: [Error] (12595:1): Duplicate identifier 'srl_Bitmaps' in script

-function C:
function FindRawFishInInv(Tol : integer; var x,y : integer; fish : string): boolean;
begin
GameTab(4);
case lowercase(fish) of
'shrimps': if FindBitmapToleranceIn(srl_GetBitmap(86), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'anchovies': if FindBitmapToleranceIn(srl_GetBitmap(87), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'tuna': if FindBitmapToleranceIn(srl_GetBitmap(88), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'trout': if FindBitmapToleranceIn(srl_GetBitmap(89), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'pike': if FindBitmapToleranceIn(srl_GetBitmap(90), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'salmon': if FindBitmapToleranceIn(srl_GetBitmap(91), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'lobster': if FindBitmapToleranceIn(srl_GetBitmap(92), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
'swordfish': if FindBitmapToleranceIn(srl_GetBitmap(93), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then Result := True; srl_FreeBitmaps;
else
Writeln('Invalid option');
Result := False;
end; // case
end;
for cooking.scar, but the same error as the function B…

- function D:
function CookScreen: boolean;
var
x,y : integer;
begin
result := FindText(x, y, 'cook', npcchars, 137, 355, 384, 385);
end;

n3ss3s

2008-03-23 15:39:39

You got the error, because you exactly are not supposed to include it - it's already being included.

Also, it might look cleaner if you make a new integer, "bmp", and just define the bmp in the case, and then do just one FindBitmap…

Santa_Clause

2008-03-23 19:13:50

function FindCookedFishInInv(Tol : integer; var x,y : integer; fish : string): boolean;
begin
GameTab(4);
case lowercase(fish) of
'shrimps': BitmapNumber := 76;
'anchovies': BitmapNumber := 77;
'tuna': BitmapNumber := 78;
'trout': BitmapNumber := 79;
'pike': BitmapNumber := 80;
'salmon': BitmapNumber := 81;
'lobster': BitmapNumber := 82;
'swordfish': BitmapNumber := 83;
else
Writeln('Invalid option');
Result := False;
Exit;
end;
if FindBitmapToleranceIn(srl_GetBitmap(BitmapNumber), x, y, MIX1, MIY1, MIX2, MIY2, Tol) then
Result := True;

srl_FreeBitmaps;
end;

:D

XcanadamanX

2008-03-23 19:55:07

i use this for my bar screen. im guessing it would work with the cooking screen too.
Function BarScreen:boolean;
begin
result:=GetColor(37, 373)=10264383
end;

Wizzup?

2008-03-23 19:57:32

From my cooker:

      Until FindNpcChatText('aw', ClickRight);
Wait(50 + Random(100));
ChooseOption('All');

FindNpcChatText should work… :)

Cazax

2008-03-24 16:14:11

i tried my find cook screen and find smelt screen and booth worked :)

ZephyrsFury

2008-03-24 20:44:29

Instead of searching for text it might be better to search for a colour instead or check for the existance of a colour. Its a lot faster searching for a colour than searching for text.

Naum

2008-03-25 11:02:46

Maybe make a bitmap???
Make it small takes less than a sec to find a well made bitmap.

XcanadamanX

2008-03-25 16:07:25

or do one simple getcolor as in post #4

Cazax

2008-03-25 16:18:37

Maybe getcolor could be faster… but i think finding a text is more accurate.

XcanadamanX

2008-03-25 17:03:58

not if the color is constant and never changes places :p and is a very odd color in the first place. (for the smithing screen - the jewel or whatever on the sword in the top right corner)

Santa_Clause

2008-03-25 17:49:11

I prefer to use a couple of GetColors, just in case anything odd happens and it finds the same colour in 2 different screens.

n3ss3s

2008-03-26 10:09:56

You could do a compromise - use FindTextTPA ;)

Santa_Clause

2008-03-28 08:44:44

From: n3ss3s
You could do a compromise - use FindTextTPA ;)


I wanted to use that for ClickToContinue…but I'm not sure which chars I'm meant to be using…

ZephyrsFury

2008-03-28 10:23:56

The click to continue text is NPCChars.

Santa_Clause

2008-03-28 17:37:10

From: ZephyrsFury
The click to continue text is NPCChars.


Well then, I was using the right one and FindTextTPA was being stupid :D