SRL Archive - OSR Help

Trouble with bitmaps.


Littma

2010-01-28 16:30:15

First off here's the part of the script I'll be asking about. (Thanks to The Man for cleaning it up.)


procedure FireRain;
var i, fire, bandage: Integer;
begin
repeat
Wait(2 * 250 + random(50));
Writeln('Casting Fire Rain.');
if FindBitmap(fire, x, y) then
begin
HoldMouse(x, y, True);
Wait(2 * 500 + random(50));
ReleaseMouse(x, y, True);
end;
Wait(6 * 1500 + random(50));
Writeln('Healing with Bandage.');
if FindBitmap(bandage, x, y) then
begin
MoveMouseSmooth(x, y);
ClickMouse(x, y, True);
end;
Wait(2 * 2000 + random(50));
Inc(i);
until (i = 10);
end;

For some odd reason, everything works perfect in the script besides this one procedure. It compiles perfect with 0 errors, though it does not run the procedure correctly so there is something wrong.

It only does the 'FireRain' (fire bitmap) command without doing the 'bandage' command following afterwards. So basically it ignores the whole bandage section of the procedure and only does the hold mouse/release mouse on the fire bitmap, will not do the bandage.

Any advice on what this could be? I'm starting to think I need a Begin somewhere in the script for it to begin the one section of the procedure which is Bandage. Thanks in advance <3

Notes:
I have the bitmaps loaded and identified.
I tried adding a Begin since theres a end in the middle of the procedure though comes back requesting an identifier near the end of the script that is NOT an end.

Dynamite

2010-01-28 16:45:56

Not sure but here is your script with some standards :P
procedure FireRain;
var i, fire, bandage: Integer;
begin
repeat
Wait(2 * 250 + random(50));
Writeln('Casting Fire Rain.');
if FindBitmap(fire, x, y) then
begin
HoldMouse(x, y, True);
Wait(2 * 500 + random(50));
ReleaseMouse(x, y, True);
end;
Wait(6 * 1500 + random(50));
Writeln('Healing with Bandage.');
if FindBitmap(bandage, x, y) then
begin
MoveMouseSmooth(x, y);
ClickMouse(x, y, True);
end;
Wait(2 * 2000 + random(50));
Inc(i);
until (i = 10);
end;

Gu3st...

2010-01-28 16:55:34

I don't know if it will make any difference, but have you tried declaring x and y locally instead of globally?

Littma

2010-01-28 17:03:56

From: The Man
Not sure but here is your script with some standards :P
procedure FireRain;
var i, fire, bandage: Integer;
begin
repeat
Wait(2 * 250 + random(50));
Writeln('Casting Fire Rain.');
if FindBitmap(fire, x, y) then
begin
HoldMouse(x, y, True);
Wait(2 * 500 + random(50));
ReleaseMouse(x, y, True);
end;
Wait(6 * 1500 + random(50));
Writeln('Healing with Bandage.');
if FindBitmap(bandage, x, y) then
begin
MoveMouseSmooth(x, y);
ClickMouse(x, y, True);
end;
Wait(2 * 2000 + random(50));
Inc(i);
until (i = 10);
end;


Thank you, much cleaner than what I had. Getting back into Pascal is a pain :duh:

Doesn't solve the problem, but I appreciate you cleaning it up a bit.

Littma

2010-01-28 17:06:38

From: Zyt3x
I don't know if it will make any difference, but have you tried declaring x and y locally instead of globally?


Hmm, no I have not. Interesting thought though.
I might know a solution to it.
Making FireRain + Bandage separate procedures then repeating in the loop?
It seems logical, but I can't be sure.
Also, declaring x and y's coordinates globaly? I personally would not know how.

Kyle Undefined

2010-01-28 17:27:55

You're already declaring x, y globally. in the var section of your function add x, y and that will declare them locally, it *may* solve your problem.

~Camo

Bionicle

2010-01-28 17:28:43

From: Littma
Also, declaring x and y's coordinates globaly? I personally would not know how.


Program New;
{.Include SRL/srl.scar}

Var
x, y, Fire, Bandage: Integer; //Globally declared variables, as they are not declared in a procedure/function

Procedure DoWat;

Var
I, R: Integer; //Locally declared variables, as they are declared in a procedure

Begin
End;

Procedure DoNotherThing;

Begin
End;

Begin
DoWat;
DoNotherThing;
End.

Also try declaring fire and bandage globally too

Frement

2010-01-28 17:31:52

From: Camo Developer
You're already declaring x, y globally. in the var section of your function add x, y and that will declare them locally, it *may* solve your problem.

~Camo


Why would it? If you have the bitmaps already declared, there should be no need for the variable bandage. Try removing it from everywhere and add it globally.

Coh3n

2010-01-29 02:21:54

It's probably not finding the bitmap. Try running this:

procedure FireRain;
var i, fire, bandage: Integer;
begin
repeat
Wait(2 * 250 + random(50));
Writeln('Casting Fire Rain.');
if FindBitmap(fire, x, y) then
begin
HoldMouse(x, y, True);
Wait(2 * 500 + random(50));
ReleaseMouse(x, y, True);
end else
Writeln('Didn''t find fire bitmap.');
Wait(6 * 1500 + random(50));
Writeln('Healing with Bandage.');
if FindBitmap(bandage, x, y) then
begin
MoveMouseSmooth(x, y);
ClickMouse(x, y, True);
end else
Writeln('Didn''t find bandage bitmap.');
Wait(2 * 2000 + random(50));
Inc(i);
until (i = 10);
end;