SRL Archive - OSR Help

Need help with WaitFuncEx


bud_wis_er_420

2013-03-04 18:17:23

I keep getting an error while trying to use WaitFuncEx

Error: Exception: Invalid type cast at line 267

Here is the procedure I'm trying to use. It should clean a full inv of herbs.

procedure Clean_Herbs;
var
TVA: TVariantArray;
begin
if(Found_Bank = true)then
begin

if not FindColorTolerance(x, y, 2366993, 58, 65, 80, 75, 5) then
InvMouse(1, 1);

TVA := [58, 65, 2366993, 58, 65, 80, 75, 5];
if WaitFuncEx('FindColorTolerance', TVA, 200, 2000) then
begin
Mouse(316, 307, 100, 14, 1);
TVA := [216, 167, 263410, 216, 167, 305, 186, 15];
if WaitFuncEx('FindColorTolerance', TVA, 200, 2000) then
begin
writeln('Making...');
TVA := [216, 167, 11698698 , 216, 167, 305, 186, 15];
WaitFuncEx('FindColorTolerance', TVA, 200, 30000);
end;
end;
end;
end;

Le Jingle

2013-03-04 18:29:23

TypeCast probably coming from the var x var y, where you fill in the zero and first index of the variant array with static numbers.
Side note: would seem much easier to use while (condition) do here..

bud_wis_er_420

2013-03-04 19:03:52

From: Le Jingle
TypeCast probably coming from the var x var y, where you fill in the zero and first index of the variant array with static numbers.
Side note: would seem much easier to use while (condition) do here..


Doing this
TVA := [ax, ay, 2366993, 58, 65, 80, 75, 5];
if WaitFuncEx('FindColorTolerance', TVA, 200, 2000) then
is the same thing as doing this
TVA := [0, 0, 2366993, 58, 65, 80, 75, 5];
if WaitFuncEx('FindColorTolerance', TVA, 200, 2000) then

I tried both '0' and a number inside the box I was searching colors for and I keep getting the error. And yes I could use while loops, that was what I was originally using. But I was trying to shorten the code

Here it showing how to set up in srl file.
(*

Example:

.. code-block:: pascal

var
V: TVariantArray;
begin
V := [0, 0, 16711680, 4, 4, 500, 500];
WriteLn(WaitFuncEx('FindColorEx', V, 10 + Random(15), 1000));
end.
*)

I'm doing the same thing, right?

bud_wis_er_420

2013-03-04 19:17:54

I think it has something to do with passing the x, y vars back thats messing it up.

I just fixed it by doing this:

function FindWaitColor(Color, x1, y1, x2, y2, Tol: integer): Boolean;
var
cx, cy: integer;
begin
Result := False;
if FindColorTolerance(cx, cy, Color, x1, y1, x2, y2, Tol) then
Result := True;
end;


procedure Clean_Herbs;
var
TVA: TVariantArray;
begin
if not FindColorTolerance(x, y, 2366993, 58, 65, 80, 75, 5) then
InvMouse(1, 1);

TVA := [2366993, 58, 65, 80, 75, 15];
if WaitFuncEx('FindWaitColor', TVA, 200, 2000) then
begin
Mouse(316, 307, 100, 14, 1);
TVA := [263410, 216, 167, 305, 186, 15];
if WaitFuncEx('FindWaitColor', TVA, 200, 2000) then
begin
writeln('Making...');
TVA := [11698698 , 216, 167, 305, 186, 15];
WaitFuncEx('FindWaitColor', TVA, 200, 30000);
end;
end;
end;

Olly

2013-03-04 19:22:52

iirc there's wait color functions in timing.simba?

bud_wis_er_420

2013-03-04 21:00:32

opps your right I forgot about those thx a bunch.