SRL Archive - OSR Help

Help, function to get the last TPoint of a TPointArray


Haxz

2014-06-26 05:38:43

Normally if you wanna get the first TPoint of a TPointArray should be using tpa[0], second would be tpa[1] and so on.

But how do I get the last TPoint without using numbers?

Thanks

masterBB

2014-06-26 05:52:06

tpa[High(tpa)]

High(tpa) returns the index of the last element of an array

it is basically

Length(tpa) - 1

Haxz

2014-06-26 05:55:43

Weird, I tried to do this but it failed to compile.

Result := R_DistanceFromTile(high(path)) < 2;

Probably some mistake on my side, I'll try to fix it. Thanks!

Frement

2014-06-26 06:14:57

From: Haxz
Weird, I tried to do this but it failed to compile.

Result := R_DistanceFromTile(high(path)) < 2;

Probably some mistake on my side, I'll try to fix it. Thanks!


High(path) returns the highest index in the array, you need get the element in the array and pass that to the function, path[high(path)]

Haxz

2014-06-26 06:25:45

From: Frement
High(path) returns the highest index in the array, you need get the element in the array and pass that to the function, path[high(path)]


I got it done right, thanks!