SRL Archive - General Botting Help

Exception in Script: Runtime error: "You passed a wrong ye to a finder function: 1040


Zeta Matt

2014-02-07 22:27:18

"Exception in Script: Runtime error: "You passed a wrong ye to a finder function: 1040. The client has a height of 1018, thus the ye is out of bounds." at line 208, column 28"

This is what I've been getting after I converted a script of mine from SRL5 to SRL6. This happens because I set the script to look for SkyBoxes on the coordinates (DivinationWispX-10, DivinationWispY, DivinationWispX+300, DivinationWispY+300) and sometimes these coordinates go out of bounds. On SRL5, the coordinates would be rounded down so as to fit in the client, which made my script perfect, since the skyboxes also have its coordinates rounded down. How can I make SRL6 do it, also, instead of adding a bunch of conditions like 'if DivinationWispY+300 > BoundY then CoordinateToFindSkyBox = BoundY'?

Zeta Matt

2014-02-09 19:57:05

I gave up on SRL-6. I really won't add lines over lines of conditions so as to avoid any coordinate that goes beyond the client bounds. My scripts won't work if the coordinates gets rounded, and what finally made me give up was that a function of SRL-6 itself put a coordinate off the script and for that reason it didn't work:

function didClick(Red: Boolean; Time: Integer = 1000): boolean;
var
TimeOut, x, y, w, h, R, G: integer;
B: TBox;
begin
fastClick(MOUSE_LEFT);

GetMousePos(x, y);
GetClientDimensions(w, h);
B := IntToBox(x - 15, y - 15, x + 15, y + 15); //It was probably this that got a coordinate off.

if (B.x1 < 0) then B.x1 := 0;
if (B.y1 < 0) then B.y1 := 0;
if (B.x2 > w) then B.x2 := w;
if (B.y2 > h) then B.y2 := h;

TimeOut := GetSystemTime() + Time;

while (GetSystemTime() < TimeOut) and (not Result) do
begin
R := CountColorTolerance(395675, B.x1, B.y1, B.x2, B.y2, 15);
G := CountColorTolerance(1695663, B.x1, B.y1, B.x2, B.y2, 15);

if Red then
begin
if (G > 8) then
Exit(false);

Result := (R > 20);
end else
begin
if (R > 5) then
Exit(false);

Result := (G > 35);
end;
end;
end;

I feel that it is so much easier to script on SRL5 '-'

Olly

2014-02-09 20:03:28

I don't get it… How was it easier to stop Simba to not search outside the clients bounds on srl-5?

rj

2014-02-09 20:13:39

@archermaths;

You're comparing apples to oranges. The did click function has a check:


if (B.x1 < 0) then B.x1 := 0;
if (B.y1 < 0) then B.y1 := 0;
if (B.x2 > w) then B.x2 := w;
if (B.y2 > h) then B.y2 := h;

Does your function check and see if the search box is out of bounds?
(show code)

The Mayor

2014-02-09 20:20:01

Are to trying to draw the boxes on smart?

Zeta Matt

2014-02-10 03:09:39

From: Officer Barbrady
@archermaths;

You're comparing apples to oranges. The did click function has a check:


if (B.x1 < 0) then B.x1 := 0;
if (B.y1 < 0) then B.y1 := 0;
if (B.x2 > w) then B.x2 := w;
if (B.y2 > h) then B.y2 := h;

Does your function check and see if the search box is out of bounds?
(show code)


No, my I didn't put any function to check, since I didn't need to on SRL5 and I'm just converting my scripts from SRL5 to SRL6. It's exactly those 5 lines of scripting (considering GetClientBounds) that I don't want to add to many parts of my script. I know how to fix it, but since it has been easier with SRL5, I might use SRL5 until I stop being lazy >.> My script is already a mess due to my lack of experience on making things shorter. Even I have some kind of difficulty reading my own script, imagine if I write like 100 (5 lines x ~20 times I want to draw boxes) more lines that I wouldn't have to on SRL5? Maybe later '-'

Zeta Matt

2014-02-10 03:10:57

From: The Mayor
Are to trying to draw the boxes on smart?


No, I'm trying to draw boxes on a client I set SIMBA to work on. Specifically, it is the Runescape client.

Zeta Matt

2014-02-10 03:19:01

From: Olly
I don't get it… How was it easier to stop Simba to not search outside the clients bounds on srl-5?


Using SRL5, this is what happens when I ask him to

program new;
{$i srl/srl.simba}

var
x, y: integer;

Begin
SetupSRL;
FindColorTolerance(x, y, 1245, 1, 1, 10000, 10000, 5);
end.


Compiled successfully in 421 ms.
SRL Compiled in 16 msec
Warning! You passed a wrong xe to a finder function: 10000. The client has a width of 1906, thus the xe is out of bounds. Setting the value to 1905 (w-1) for now.
Warning! You passed a wrong ye to a finder function: 10000. The client has a height of 764, thus the ye is out of bounds. Setting the value to 763 (h-1) for now.
Successfully executed.

This made a natural failsafe for when any coordinate went out of bounds. It seems to me as if, in any case, this would be helpful. At least it doesn't interrupt the script.

[EDIT] Forgot to say that the SRL6 instantly interrupts the script if there is a coordinate out of bounds.

The Mayor

2014-02-10 03:27:57

From: archermaths
No, I'm trying to draw boxes on a client I set SIMBA to work on. Specifically, it is the Runescape client.


So I'll take that as a yes? Just put it in a try..except.

Zeta Matt

2014-02-10 03:28:45

What I was thinking on doing was to change functions on their core.

function findColorTolerance(var x, y: Integer; color: integer; searchBox: TBox; tol: Integer; settings: TColorSettings): Boolean; overload;
var
cs: TColorSettings;
begin
cs.retrieve();
settings.apply();
Result := findColorTolerance(x, y, color, searchBox, tol);
cs.apply();
end;

I could insert conditions in that function just to check if the given TBox is on bounds. But this would require to change every Color, DTM, bitmap and other functions like those, and their bunch of Overload functions… But this could work on a script that uses 1 color function intensively. Well, there are some ways to fix it; all of them are quite boring '-'

Zeta Matt

2014-02-10 03:32:46

From: The Mayor
So I'll take that as a yes? Just put it in a try..except.


Oh it could make things easier :O I can think on something useful to put on the Except part. I like this, it seems better than adding failsafes against coordinates out of bounds everywhere in my script! Thanks :) but I still would love round ups and downs >.> Round ups and downs would allow me to successfully find stuff that actually exist and are on the edge of the client, while Try..Except will make me put it to find the same stuff on different parts. This narrows my possibilities, but seems very handy.

The Mayor

2014-02-10 04:18:30

From: archermaths


[EDIT] Forgot to say that the SRL6 instantly interrupts the script if there is a coordinate out of bounds.


From what I understand there isn't a difference between SRL5 and SRL6. Your script will only terminate if you try to draw something on the SMART canvas which is out of bounds (which is why I asked you before). If you are simple searching for a color within a box that is out of bounds, it will adjust your coordinates, just like srl5 (so I don't know what you are trying to do?). Output from SRL6:


Warning! You passed a wrong xs to a finder function: -20. That is below 0, thus out of bounds. Setting the value to 0 for now.

footballjds

2014-02-10 07:51:10

SmartImage.drawClippedBox();

Brandon

2014-02-10 08:19:21

From: archermaths
No, I'm trying to draw boxes on a client I set SIMBA to work on. Specifically, it is the Runescape client.


Specifically? You cannot do this atm. Not until the Simba that exports the GetWindowHandle function is pushed. You can compile Simba's source or use the buildbot to do it.. Then you can use the WindowHandle to do some of the following:

Minimize or bring windows to the foreground.
Draw on any window.
Resize any window.
Use WinAPI functions.
Get Process information.
Screenshot that specific window.
Inject into that window's process.


etc.. Most of which requires a plugin or enabling system api calls.

Olly

2014-02-10 12:14:25

SupressExceptions are turned on in SRL-6 so i'm not sure why Simba is raising a exception for searching outside of client bounds. And as others have said you can't just draw onto any client other than SMART (unless you use some sort of plugin).

Zeta Matt

2014-02-10 14:30:00

From: The Mayor
From what I understand there isn't a difference between SRL5 and SRL6. Your script will only terminate if you try to draw something on the SMART canvas which is out of bounds (which is why I asked you before). If you are simple searching for a color within a box that is out of bounds, it will adjust your coordinates, just like srl5 (so I don't know what you are trying to do?). Output from SRL6:


Warning! You passed a wrong xs to a finder function: -20. That is below 0, thus out of bounds. Setting the value to 0 for now.


Noooooooooo, Sorry, 'draw' wasn't even nearly the correct word. I don't know what to say, to be honest. FindColorTolerance, for example, finds colors inside a box, defined by the given coordinates. Those are the boxes I'm doing. Well, sorry for causing this confusion. I'll reproduce my problem in a simple script:

program new;
{$I SRL-6/SRL.simba}

var
x, y: integer;

begin
FindColorTolerance(x, y, 1234, 1593, 274, 1720, 449, 5);
end.


Compiled successfully in 1061 ms.
Exception in Script: Runtime error: "You passed a wrong xe to a finder function: 1720. The client has a width of 1602, thus the xe is out of bounds." at line 8, column 21
The following bitmaps were not freed: [Minimap Mask]

So, an example in my script:

if FindColorsSpiralTolerance(960, 515, WispTPA, 7234624, MMSX1, MMSY1, MMSX2, MMSY2, 10) or
FindColorsSpiralTolerance(960, 515, WispTPA, 7234624, MMSX1, MMSY1, MMSX2, MMSY2, 10) then
begin
WispTPAA := TPAToATPAEx(WispTPA, 32, 32);
SortATPASize(WispTPAA, True);
MiddleTPAEx(WispTPAA[0], WispX, WispY);
MouseSpeed := RandomRange(40, 46);
Mouse(WispX, WispY, 1, 1);
MouseSpeed := 25; //Move Mouse to the coordinates found
T.start();
repeat
FindBitmapToleranceIn(bmpWispSkyBoxBitMap, x, y, WispX, WispY, WispX+300, WispY+300, 5); //THIS IS THE PROBLEM!!!!!!!!!!!!!!!!!!!

The problem in this script of mine comes when the Divination Wisp is found near the edge of the screen, and then WispX+300, WispY+300 goes out of bounds, returning the same report as above.

Zeta Matt

2014-02-10 14:52:07

From: Brandon
Specifically? You cannot do this atm. Not until the Simba that exports the GetWindowHandle function is pushed. You can compile Simba's source or use the buildbot to do it.. Then you can use the WindowHandle to do some of the following:

Minimize or bring windows to the foreground.
Draw on any window.
Resize any window.
Use WinAPI functions.
Get Process information.
Screenshot that specific window.
Inject into that window's process.


etc.. Most of which requires a plugin or enabling system api calls.


Sorry, I should have added the information on my post above earlier. I'm not trying to draw on the screen; what I meant was that some functions act in boxes, and I think I meant 'draw theoretical boxes' where it searches in it, but this was wrong due to the correct meaning of 'draw' >.> Really sorry.

footballjds

2014-02-10 15:00:16

archermaths, I think there are a ton of simple solutions.

Here is one… The logic is there, not tested so i could've made a stupid logic error.


program new;
{$I SRL-6/SRL.Simba}

const
CONST_MAX_WIDTH = 1000;
CONST_MAX_HEIGHT = 600;
var
screenSearchArea: TBox;

function TBox.clipIt: TBox;
begin
if (self.x1 < 0) then self.x1 := 0;
if (self.y1 < 0) then self.y1 := 0;
if (self.x2 > CONST_MAX_WIDTH) then self.x2 := CONST_MAX_WIDTH
if (self.y2 > CONST_MAX_HEIGHT) then self.y2 := CONST_MAX_HEIGHT;
result := self;
end;

var
tpointsss: TPointArray;
clientBounds: TBox := [0, 0, 1000, 600];
begin
findColorsTolerance(tpointsss, 1727723, screenSearchArea.clipIt, 7);//Searches in screenSearchArea constrained by the const max w and h
findColorsTolerance(tpointsss, 1727723, clientBounds, 7);//searches in the client boundries
end.


there are other more elegant solutions, you take your pick

here's an SRL function:
procedure TBox.setLimit(b: TBox);
begin
if (self.x1 < b.x1) then self.x1 := b.x1;
if (self.x2 > b.x2) then self.x2 := b.x2;
if (self.y1 < b.y1) then self.y1 := b.y1;
if (self.y2 > b.y2) then self.y2 := b.y2;
end;

Olly

2014-02-10 15:32:17

You need to call setupSRL(). Would have been the same with srl5.

Or do setSupressExceptions(true);