SRL Archive - Help and Support

Out of range error


Phran6

2012-05-11 15:03:18

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

var
Box : array of array of tbox;


Procedure mq;
var
DeskDTM,x,y,i,j : Integer;
begin
DeskDTM := DTMFromString('mbQAAAHicY2VgYPgFxZ1MEHyQkYFhF5CvyATBIHYjUMySk5FBl42BQY2dicGOm5lBk5+VARtgxILBAABk8wdB');
FindDTM(DeskDTM,x,y,0,0,1365,767);
// x-> 399; y-> 359 ; 10 carré en x et 9 carré en y
for i := 0 to 9 do
for j := 0 to 8 do
begin
Box[i][j] := IntToBox((x+(i*40)),(y+(j*40)),(x+((i+1)*40)),(y+((j+1)*40)));
end;
MMouse((Box[1][1].x1+Box[1][1].x2)/2,(Box[1][1].y1+Box[1][1].y2)/2,0,0);
FreeDTM(DeskDTM);
end;

begin
SetupSRL();
ClearDebug();
mq;
end.

Im trying to do a script for the game diamond dash and i get the error :Error: Out Of Range at line 18 and the line is
Box[i][j] := IntToBox((x+(i*40)),(y+(j*40)),(x+((i+1)*40)),(y+((j+1)*40)));

the dtm find the top left of the game and i want the tbox of each square
any idea ?

Abu

2012-05-11 15:21:30

I'm not sure if Box[j] is possible….

You can only do Box or Box[j]

Correct me if I'm wrong


EDIT: Also, three threads? Really?

Phran6

2012-05-11 15:23:39

but it is an array of array of tbox ? it should be ok ?

Abu

2012-05-11 15:25:33

Then I think it should be

Box[i, j]

Phran6

2012-05-11 15:29:01

with Box[i,j] script dont compile

Yago

2012-05-11 15:48:19

If you set the length's of the 2DArray or check the length, then you should be good…

Phran6

2012-05-11 15:52:56

how i set the lenght of the 2DArray ? like i i it should be 10 and j 9

Yago

2012-05-11 15:58:01

From: Phran6
how i set the lenght of the 2DArray ? like i i it should be 10 and j 9


Yeah, either that or break out of the loop if length of box < i or j….

SO you can either set the length of break out of the loop.

Phran6

2012-05-11 16:01:17

got it working :
 Box : array [0..9] of array [0..8] of tbox; 


Thanx for help :)

Yago

2012-05-11 16:03:27

From: Phran6
got it working :
 Box : array [0..9] of array [0..8] of tbox; 


Thanx for help :)


Welcome, you would be using LAPE right?