SRL Archive - Help

CountBitmapTolerance problem


marc2333

2012-12-28 06:19:36

I am getting an error compiling this :

Procedure CountBarKnives;
begin
CBars:= CountBitmapTolerance(IronBar, MIX1, MIY1, MIX2, MIY2, 10);
end;

Yes my BitMap is declared before,
Yes Cbars is an Int in my Var

[Error] (40:9): Unknown identifier 'CountBitMapTolerance' at line 39
Compiling failed.


No idea whats wrong :( Anyone can help ?


Edit : seems like CountBitmap doesn't exist but its something I found in this tutorial http://villavu.com/forum/showthread.php?t=47374 and here http://scar-divi.com/oldmanual/ Any idea what it has been replaced for or what I'm doing wrong ?

riwu

2012-12-28 06:28:27

If you are counting inventory:

CountItems('bmp', IronBar, [10]);

marc2333

2012-12-28 06:31:32

From: riwu
If you are counting inventory:

CountItems('bmp', IronBar, [10]);


would it work on a rsps (this means not logged in + no SetupSrl + no SMART) ?

riwu

2012-12-28 06:40:21

From: marc2333
would it work on a rsps (this means not logged in + no SetupSrl + no SMART) ?

The inventory bounds for RSPS may not be the same. Use CountItemsIn() and specify the bounds.

marc2333

2012-12-28 06:54:38

From: riwu
The inventory bounds for RSPS may not be the same. Use CountItemsIn() and specify the bounds.


Here is my script, it always returns me 0 bars found and I know my IronBar btm is fine because it finds it earlier and use it on anvil no problem.


program Smithing;
{$i srl/srl.simba}

var
Q: Array [0..15] of Integer;

x,y,m,n,IronBar,BarWithAnvil,IronKnife,Make10sets,CBars:integer;
aFound: Extended;


procedure SetDTMs;
begin
Q[0]:= DTMFromString('mlwAAAHicY2dgYJjAzMAwBQlPQ8L7gfKTgLgLiJuAuAqIi4A4C4htDfkZ3r5lAOM/f5hQ2P+B8lw4MCMeDAUAnyQU+Q==');
Q[1]:= DTMFromString('mrAAAAHic42BgYFBlYmDQAGIVIFYGYnUgVkLCH4BqHgHxKyC+A8RvgfgNED8H4k9A7GZvz6CqqMhgaWzMYGdhwWBjZgamzQ0NGTwcHRhYgWrwYUYCGAYADDsN5A==');
IronBar:= BitmapFromString(10, 8, 'meJwzNDQ3xEAOjh4QhEcKiKSl5YE' +
'IqxRcFo7oIwt0Bi5ZiCMBzJwvBQ==');
BarWithAnvil:= BitmapFromString(88, 10, 'meJzlk+EOgCAIhH3/l7aa2QjOAz' +
'eLtRw/KAjuPletxynZp4Zl7F0t1q1ukcDBLg3KuAgsRPE5Dsr7KhQ' +
'vc5CL0jnIbyUHKAOWSH8xdnibJUMmC8G3gCXidzz23EssQMEDqRND' +
'IBlYhUYgB+Kd50QevCMCQVatowgHviJ417AtwNCXOsvBBfgfDipP5' +
'OC+kRyUZmUqzqH0PwLm9nEK9aMcNrQX6DQ=');
IronKnife:= BitmapFromString(20, 28, 'meJy90tsKQUEYxXFvsUUIOeTQds' +
'gxGxHa2OQsSd7/Kfxraq73mgvT3P5a3/pmEol/n3y+5Aar1YYbrNf' +
'9YrHiAJvNDtBhYL/V45bLNRV2u6N2ewBUQw3kqluyUA0FGksiW8pm' +
'CypkRSS6QUKxqVQmpu33JxaSCPS8pGT5DHwkCXLG4/nt/omiGzydz' +
'knWwNVqrw5soekrJR6PzzA80Zey8aGxu91lsznwRipkWix7lkItHA' +
'6nNJUgNbE0xVI2vj2dX8bysgwcH16ubywwCBaEStMaSy5Wmvbx+Bo' +
'7m63Vd7EzL5Zbqak9WBX+AFRRU6I=');
Make10sets:= BitmapFromString(85, 10, 'meJzFklEOgDAIQ73/pTF+uCyjdI' +
'Vh5GshUPuKZk9dU5nr+FJmsuv2Vlm2xcnX+BBzdBoT0EHGmHiCskm' +
'bCqo1/gMp/KXOlfX13/HhY/EDDSvDW2OzGrcd3ajWhFb9LaJ3RMER' +
'yvhKn3sodGBQqdxEfGU3FTvUWRR0Coi/DaoXn5jksUQKJ/hkQDdPB' +
'EWFaOUc/wqy5W8oCwfghxTD0PNW04/d3Z5T1w==');
end;

Procedure CountBarKnives;
begin
CBars:= CountItemsIn('inv', 'bmp', IronBar, [10]);
writeln('We found ' + toStr(CBars) + ' iron bars');

end;

procedure FreeD;
begin
FreeDTM(Q[0]);
FreeDTM(Q[1]);
FreeBitMap(IronBar);
FreeBitMap(BarWithAnvil);
FreeBitMap(IronKnife);
FreeBitMap(Make10sets);
end;

procedure BankToAnvil;
begin
if FindDTMRotated(Q[0], x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) then
begin
MoveMouse(x,y);
wait(200);
ClickMouse(x,y,1);
repeat
Wait(200);
Until(FindDTMRotated(Q[1], x, y, MSX1, MSY1, MSX2, MSY2, -Pi/4, Pi/4, Pi/60, aFound))
end;

end;

procedure Smith;
begin
if FindDTMRotated(Q[1], x, y, MSX1, MSY1, MSX2, MSY2, -Pi/4, Pi/4, Pi/60, aFound) and FindBitMapToleranceIn(IronBar,m,n,MIX1,MIY1,MIX2,MIY2,10) then
begin
MoveMouse(m,n);
Wait(300);
ClickMouse(m,n,1);
Wait(300);
MoveMouse(x,y);
Wait(300);
ClickMouse(x,y,0);
Wait(500);
if FindBitMapToleranceIn(BarWithAnvil,x,y,MSX1,MSY1,MSX2,MSY2,10)then
begin
MoveMouse(x,y);
Wait(300);
ClickMouse(x,y,1);
Wait(500);
repeat
Wait(100);
Until(FindColorTolerance(x,y,65535,159,31,206,49,3));
end;
if FindBitMapToleranceIn(IronKnife,x,y,MSX1,MSY1,MSX2,MSY2,10)then
begin
MoveMouse(x,y);
Wait(300);
Clickmouse(x,y,0);
wait(400);
if FindBitMapToleranceIn(Make10sets,x,y,MSX1,MSY1,MSX2,MSY2,10)then
begin
MoveMouse(x,y);
Wait(300);
Clickmouse(x,y,1);
wait(400);
end;
end;
end;

end;

procedure AnvilToBank;
begin
end;

procedure Banking;
begin
end;


begin
SetDTMs
BankToAnvil
Smith
CountBarKnives
FreeD
end.

riwu

2012-12-28 07:06:04

Ops didnt realize CountItemsIn's param is not area bound.

Try this function then:

function CountBitMapTolerance(bitmap, xs, ys, xe, ye, tolerance: Integer): Integer;
var
TPA: TPointArray;
begin
FindBitmapsSpiralTolerance(bitmap, 0, 0, TPA, xs, ys, xe, ye, tolerance);
Result:= Length(TPA);
end;

Use it like how you've been using it in OP.
Note that 'MIX1, MIY1, MIX2, MIY2' is only for the official RS. Change it accordingly.

marc2333

2012-12-28 07:11:06

From: riwu
ops didnt realize countitemsin's param is not area bound.

Try this function then:

function countbitmaptolerance(bitmap, xs, ys, xe, ye, tolerance: Integer): Integer;
var
tpa: Tpointarray;
begin
findbitmapsspiraltolerance(bitmap, 0, 0, tpa, xs, ys, xe, ye, tolerance);
result:= length(tpa);
end;

use it like how you've been using it in op.
Note that 'mix1, miy1, mix2, miy2' is only for the official rs. Change it accordingly.


thanks !!! :)

compiled successfully in 516 ms.
We found 6 iron bars
successfully executed.

Pew

2012-12-29 09:43:18

From: marc2333
would it work on a rsps (this means not logged in + no SetupSrl + no SMART) ?


Why can you not setup SRL on ps? Out of interest what server is this for?

marc2333

2012-12-29 11:52:24

From: Pew
Why can you not setup SRL on ps? Out of interest what server is this for?


Because of the -22 thing, makes me not able to set coords on top of the screen and many shits.. better not using it.