SRL Archive - OSR Help

Is it possible to do this?


Emu

2012-02-21 21:15:28

until((failtwo>50) or findbitmaptoleranceIn(ore, x, y, MIX1, MIY1, MIX2, MIY2, 10, False));

Is it possible to repeat until either fail two is greater than 50 OR until 'ore' can no longer be found?

If not any alternatives to what I'm trying to achieve would be greatly appreciated!

Brandon

2012-02-21 21:19:47

Seems fine to me.. if failtwo > 50, the loop will break OR if the bitmap is found, the loop will break.

I'd probably use a timer.. MarkTime(T)… Do Loop while (TimeFromMark(T) < 20000).. thats 20 seconds..

Though I think failtwo > 50 is a large condition. Are you really going to try 50 times before giving up?

YoHoJo

2012-02-21 21:21:17

Yeah it's possible I believe.
What's wrong wit the code you have?

Also you can use a break (which ends a loop too).
Like inside the loop (after the repeat, before the until) put If FailTwo>50 then Break
or the findbitmap.
Know though that after that script will do whatever it is told to do next after the loop, so you may need a failsafe.

Emu

2012-02-21 21:28:39


if (FindBitmapToleranceIn(ore, x, y, MIX1, MIY1, MIX2, MIY2, 10)) then
begin
repeat
failtwo:=(failtwo+1)
wait(350+random(200));
Case (random(200)) of
1..2: mmouse(x-64, y-146, 90, 40);
2..3: mmouse(x+116, y+15, 30, 60);
4..5: mmouse(x+326, y-353, 90, 90);
6..7: mouse(531, 96, 5, 5, true);
8..9: mouse(531, 63, 5, 5, true);
end;
writeln('Failed:' +toStr (failtwo));
until((failtwo>50) or findbitmaptoleranceIn(ore, x, y, MIX1, MIY1, MIX2, MIY2, 10, False));
end;

[Error] (438:92): Invalid number of parameters at line 437

This is the error - line 438 is 'until' statement.

Thanks for the help though, ill use a break until i get it sorted (Still don't understand how to make it stop if it cannot find the ore using 'findbitmaptoleranceIn' though)

YoHoJo

2012-02-21 21:30:58

Not sure what/if you need that false in FindBitmapToleranceIn? Look up it's parameters.

Emu

2012-02-21 21:33:48

The parameters are: function FindBitmapToleranceIn(bitmap: integer; var x, y,: Integer; xs, ys, xe, ye: Integer; tolerance: Integer): Boolean;

I thought that booleans returned either true or false, so is it possible to loop until it returns false?

YoHoJo

2012-02-21 21:35:47

The function itself is a boolean!
So just findbitmaptoleranceIn(ore, x, y, MIX1, MIY1, MIX2, MIY2, 10) is enough!

Emu

2012-02-21 21:37:40

Yes I know lol, but i only want it to end if it returns false (it cannot find the ore) - is this possible?

YoHoJo

2012-02-21 21:39:07

  until( (failtwo>50) or  (NOT (findbitmaptoleranceIn(ore, x, y, MIX1, MIY1, MIX2, MIY2, 10, False))));
Like that.
With a NOT!

Emu

2012-02-21 21:41:36

It works!

Thanks heaps for the help!!!