SRL Archive - OSR Help

Need help: out of range error


Phran6

2012-05-11 15:20:38

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 ?

J J

2012-05-11 16:05:36

 for i := 0 to 9 do
begin
for j := 0 to 8 do
Box[i][j] := IntToBox((x+(i*40)),(y+(j*40)),(x+((i+1)*40)),(y+((j+1)*40)));
end;

Might fix it. With your code it basicly does for i = 0-> 10 it will call j = 0 -> 8 and check the boxes? Just a thought.

Out of range means that the result is outside the client area. It might fix it :P

Phran6

2012-05-11 17:58:12

i fixed it, i didnt set the lenght of the array Box