SRL Archive - SRL Development and Help

Problems with script interpreter? Mousebox function randomly crashes?


KM_01

2013-11-14 00:27:45

Hey dev's.. I've discovered some weird issues and I don't know if it's SRL or Simba at fault here, please move this thread if this isn't the appropriate forum..

I can't seem to get some functions to call when they are in the until(); bracket of a loop.. Here is an example of what I had to do to get findcolourtol to be called:

  repeat
z:= z + 1;
SleepAndMoveMouse(384 + random(253));
if (findcolortolerance(x,y,2340527,525, 445, 527, 447, 10)) then
begin
z:= 111;
end;
until(z >= 111); //found colour

This is the code which will compile but causes an endless loop:

  repeat
SleepAndMoveMouse(384 + random(253));
until([B]findcolortolerance(x,y,2340527,525, 445, 527, 447, 10)[/B]); //never looks for colour

I had another problem, but it is no longer present..
I would also appreciate if a mod would remove the "Miserable user" status from my account, as happened with Wanted.. I don't think such an open-source-preaching community should be so closed-source with it's member structure anyway..

Coh3n

2013-11-15 19:24:50

I can't explain your first problem; that's really odd. I've used loops that way plenty of times and it's always worked fine. You could write a wrapper, and add a writeln() to it, then you'll know for sure if it's being called. Add this above the function that your loop is in:

function FindColorToleranceEx(x, y, color, x1, y1, x2, y2, tol: integer): boolean;
begin
Writeln('FindColorTolerance is being called.');
Result := FindColorTolerance(x, y, color, x1, y1, x2, y2, tol);
end;
And call FindColorToleranceEx in your loop.

Your second problem: MouseBox will not move the mouse if the mouse pointer is already in the box you want to move to. So if it moves there once, but doesn't find the "hover color", it won't move the mouse again, it'll just keep looking for the hover color. Maybe some more debugging will tell you whether or not the hover color is being found.

Hope this helps,
Coh3n

KM_01

2013-11-17 19:42:30

Thanks Coh3n, I'll add that debug to my script and see what's happening..
On the mousebox issue, it actually does move the mouse when the pointer is already within the box (this happens 9.99 times out of 10), it mouses around within the defined box until it detects the hover colour..
I suspected that it had something to do with the other findcolortol in the same loop which uses diff x and y vars, maybe it returned true for the hover color and (because there is only 1 wait() between findcolortol's) the first findcolortol is mis-interpreted as true from the end of the last loop.
The interpreter error seems likely to be on my end, and not a problem with SRL or Simba.. I might re-install SRL completely and see if the issue resolves itself.. I haven't experienced the problem with mousebox in a long time also..

Coh3n

2013-11-17 22:40:50

From: KM_01

On the mousebox issue, it actually does move the mouse when the pointer is already within the box (this happens 9.99 times out of 10), it mouses around within the defined box until it detects the hover colour..
That's not supposed to happen. Does it move anywhere in the box, or just slightly move the mouse from the point it's already at (if the mouse is already in the box, I mean)?

KM_01

2013-11-20 21:06:03

It seems to just move anywhere within the box (regardless of where the pointer already is).. I'm using an out-dated version of SMART too.. 8.3 is old now I think..
Here is the method straight from my include, I see it is supposed to move within the box unless the pointer is already there.. I have no idea why it would be doing this for me and nobody else..
    procedure mouseBox(b: TBox; button: integer = MOUSE_MOVE);

Moves the mouse somewhere inside the box b. Will just move my default. Click
depends on what button is set to. It is more likely to click around the middle
of the box.

.. note::

- by Coh3n
- Last Updated: Mar. 17, 2013 by Coh3n

Example:

.. code-block:: pascal

mouseBox(b, MOUSE_LEFT);
*)
procedure mouseBox(b: TBox; button: integer = MOUSE_MOVE; mmType: integer = MOUSE_HUMAN);
var
p: TPoint;
x, y: integer;
begin
getMousePos(x, y);

if (not pointInBox(point(x, y), b)) then // if the mouse is already in the box
begin
gaussBox(p, b);
mouse(p, button, mmType);
end else
mouse(point(x, y), button, mmType);
end;

The spamming of "Detected bank chest" seems to verify that the method was working correctly because the mouse was just sitting and was recognised as being within the box (so mousebox won't move it).. But that only happened 0.01% of the time, mostly it would move within the box, failing to find the hover colour, it would re-position the mouse at random co-ords within the same box. Very unusual problem..

Coh3n

2013-11-20 22:46:53

Odd. Can you run this code (drag your Simba crosshairs to anything). It should move the mouse once and sit there, which is exactly what it does for me.

program new;
{$i srl-6/lib/core/mouse.simba}

begin
clearDebug();

repeat
mouseBox(intToBox(0, 0, 300, 300), MOUSE_MOVE);
wait(500);
until(false);
end.

E: Also, are you still using the same code as in the OP?

KM_01

2013-11-21 19:21:31

Everything appears to be working normally, the mouse didn't move unless it was outside the defined box. I'm not sure what was happening last week in the script.. Now it won't move the mouse around once inside the box.
Thanks for the assistance, Coh3n :)
I'm going to update SMART and see if findcolortol() will work from inside an until() bracket.

Coh3n

2013-11-21 23:09:51

From: KM_01
Everything appears to be working normally, the mouse didn't move unless it was outside the defined box. I'm not sure what was happening last week in the script.. Now it won't move the mouse around once inside the box.
Thanks for the assistance, Coh3n :)
I'm going to update SMART and see if findcolortol() will work from inside an until() bracket.
Lol, weird. Well, I'm glad it's working again. :)