SRL Archive - OSR Help

FindBitmap not working


Shoyukenn

2010-03-16 05:24:52

For some reason my findbitmap isn't working. It keeps returning the bottom-left corner of my selected app.

This is my first attempt at a scar script, I come from ActionScript so I know the basics of programming (variables etc..)

Here's the script:
program AutoDropper;

const
drop_first = false;
// false if pick/hatchet is in first invy slot.


procedure mouse(x,y:integer; leftMouse:boolean);
begin
moveMouseSmooth(x,y);
wait(50+random(100));
holdMouse(x,y,leftMouse);
wait(50+random(100));
releaseMouse(x,y,leftMouse);
end;

procedure clickInvy(col,row:integer; leftMouse,clickIfItem:boolean; var itemFound:boolean);
var
x,y,x2,y2: integer;
itemPresent: boolean;
begin
x:= 573+(42*(col-1))+random(10);
y:= 222+(36*(row-1))+random(10);

moveMouseSmooth(x,y);
wait(100+random(100));

if(clickIfItem)then
begin
itemPresent:= findColorTolerance(x2,y2,14804451,0,0,15,15,35);
itemFound:= itemPresent;
end;

if((clickIfItem and itemPresent) or not(clickIfItem))then
begin
holdMouse(x,y,leftMouse);
wait(50+random(100));
releaseMouse(x,y,leftMouse);
end;
end;

procedure clearPopUp();
var
x,y: integer;
begin
getMousePos(x,y);
moveMouseSmooth(x-(100+random(50)),y-(100+random(50)));
end;

var
dropImg,col,row,x,y: integer;
itemFound: boolean;

begin
dropImg := BitmapFromString(2, 10, 'beNrbMfXYDnIRAPCmKX0=');
itemFound:= false;
row:= 0;
col:= 1;
if(drop_first)then
begin
col:= 0;
end;

repeat
inc(row);
repeat
inc(col);
clickInvy(col,row,false,true,itemFound);
if(itemFound)then
begin
if(findBitmap(x,y,dropImg))then
begin
moveMouseSmooth(x,y);
wait(1000+random(50));
clickMouse(x,y,true);
end else begin
clearPopUp();
end;
wait(100+random(50));
end;
until(col > 3);
col:= 0;
until(row > 6);

freeBitmap(dropImg);
end.

Any comments on how to improve my script (other than the problem above) would be awesome :)

thanks,
Shoyukenn.

cycrosism

2010-03-16 06:57:18

If you are using a bitmap to find an item on RuneScape, you should use FindBitmapToleranceIn (It allows to you add tolerance, and set parameters on where you want SCAR to search for the bitmap.

If you need help with it, click the bitmap tutorial link that is in my sig.

Shoyukenn

2010-03-16 07:17:56

I don't need to use a tolerance though, the bitmap is being found (findBitmap is returning true).

The problem is that it's returning incorrect x and y coordinates.

cycrosism

2010-03-16 07:23:02

What version of scar are you using? And what OS do you use?

Shoyukenn

2010-03-16 07:26:15

Divi 3.22 w/ XP 32 bit

senrath

2010-03-16 08:22:54

Try 3.23 instead.

Shoyukenn

2010-03-16 22:35:09

from freddy1990.com:


Unless he released a new version and didn't update the website?

NCDS

2010-03-16 22:38:02

From: Shoyukenn
from freddy1990.com:


Unless he released a new version and didn't update the website?


It's a Beta release.

You have to download via SVN.

http://villavu.com/forum/showthread.php?t=47714

Shoyukenn

2010-03-17 05:08:51

Ah, it is my scar. I made a quick test script (should have done it when the problem first occurred, I know) to search for something that I know is there (the firefox icon).

I'll download the new version and tell you how it goes.

Apart from the error, any comments on my first script?

Coh3n

2010-03-17 12:20:03

From: Shoyukenn
Ah, it is my scar. I made a quick test script (should have done it when the problem first occurred, I know) to search for something that I know is there (the firefox icon).

I'll download the new version and tell you how it goes.

Apart from the error, any comments on my first script?

I have no idea what it's for, but for a fist script I don't think it's too bad. Your standards are pretty good. You should add spaces after characters like ',' '+' '-' etc. and after bold words like if (condition) then.