SRL Archive - OSR Help

Out of range


DeSnob

2011-09-18 13:36:09

Hey guys I've been working on a small project for the past few hours, and I'm stuck right now. Firstly, I haven't coded in a while so I'm asking if anyone knows a way to shorten the arrays.
Function Handle: Boolean;
var
i, s: Integer;
T: TRSObject;
E: TNPC;
TP, Tl: TPoint;
ETiles, Tiles: TPointArray;
begin
if (Herbs) then
s := 4
else
s := 5;
Tiles[1] := Point(2906, 5488);
Tiles[2] := Point(2909, 5490);
Tiles[3] := Point(2911, 5485);
Tiles[4] := Point(2921, 5485);
Tiles[5] := Point(2924, 5487);

ETiles[1] := Point(2907, 5484);
ETiles[2] := Point(2907, 5493);
ETiles[3] := Point(2910, 5489);
ETiles[4] := Point(2915, 5484);
ETiles[5] := Point(2923, 5487);
ETiles[6] := Point(2922, 5491);
The actual problem is this error i'm getting on the first array.
Error: Out Of Range at line 206

MylesMadness

2011-09-18 13:54:58

Function Handle: Boolean;
var
i, s: Integer;
T: TRSObject;
E: TNPC;
TP, Tl: TPoint;
ETiles, Tiles: TPointArray;
begin
if (Herbs) then
s := 4
else
s := 5;
SetArrayLenth(Tiles, 5);
Tiles := [Point(2906, 5488), Point(2909, 5490), Point(2911, 5485), Point(2921, 5485), Point(2924, 5487)];

SetArrayLenth(ETiles, 6);
ETiles := [Point(2907, 5484), Point(2907, 5493), Point(2910, 5489), Point(2915, 5484), Point(2923, 5487), Point(2922, 5491)];

Home

2011-09-18 15:30:12

Kinda offtopic. But what's the use of SetArrayLength. I never use it.

~Home

Brandon

2011-09-18 15:51:10

From: Home
Kinda offtopic. But what's the use of SetArrayLength. I never use it.

~Home


Declares the size of the array.. I guess u could say it initiates the array with a size. You can't just use an array without declaring its size first. Though there is dynamic arrays, I don't know that simba supports that.. soo I guess thats what setarray length does.

Gu3st...

2011-09-18 17:10:07

Actually, you should use SetLength() and Length() for arrays instead of SetArrayLength() and GetArrayLength()

Reason: http://bugs.villavu.com/view.php?id=283