SRL Archive - OSR Help

Out of Range GRRRR


bbri06

2010-05-19 20:11:35

The Function

Function WalkPath(Dir: String): boolean;
var
Path, OnMap: TPointArray;
BankTile: TTile;
ThePoint: TPoint;
i: integer;
begin
SetLength(Path, 40);
SetLength(OnMap, 1);
Path := LoadPath;
BankTile := Tile(3093, 3490);
repeat
if(not(R_LoggedIn))then
if(not(LoggedInBB))then
begin
Players[CurrentPlayer].Active := False;
LogOut;
end;
if(TileOnMM(BankTile))then
begin
ThePoint := TileToMM(BankTile);
Mouse(ThePoint.x, ThePoint.y, 3, 3, true);
Wait(100 + random(50));
R_Flag;
Result := True;
Exit;
end;
for i := 0 to 40 do
begin
ThePoint := TileToMM(Tile(Path[i].x, Path[i].y));
if(PointInBox(ThePoint, IntToBox(mmx1, mmy1, mmcx, mmy2)))then
begin
OnMap[High(OnMap)] := ThePoint;
SetLength(OnMap, High(OnMap) + 2);
end;
end;
if(Length(OnMap) = 0)then
begin
Result := False;
Exit;
end;
if(Dir = 'N')then
SortTPAFrom(OnMap, IntToPoint(mmcx, mmy1))
else
SortTPAFrom(OnMap, IntToPoint(mmcx, mmy2));
ThePoint := OnMap[0];
if(ThePoint.x > 0) and (ThePoint.y > 0)then
begin
Mouse(ThePoint.x, ThePoint.y, 3, 3, true);
Wait(100 + random(50));
R_FFlag(10);
end else
begin
Result := False;
Exit;
end;
until(false)
end;

The error is this line


ThePoint := TileToMM(Tile(Path[i].x, Path[i].y));

And I'm using Simba.

noidea

2010-05-19 21:22:19

for i := 0 to 39 do//needs to be one less than the length. the actual length of the array is outside the largest slot number.
begin
ThePoint := TileToMM(Tile(Path.x, Path.y));

bbri06

2010-05-19 21:32:28

The length is correct at 40 for the array.

Blumblebee

2010-05-19 21:33:38

no length 40 goes for 0..39

you go

from i := 0 to 40 do

it should be

from i := 0 to 39 do 

or alternatively

for i := 0 to high(Path) do

bbri06

2010-05-19 21:38:48

:duh: Thanks a lot.

noidea

2010-05-19 21:45:28

From: bbri06
:duh: Thanks a lot.


Thats what I told you.

bbri06

2010-05-19 21:51:55

I know, that's why I repped you, Noidea. I just was somehow thinking I had it right -.-