SRL Archive - Help and Support

Inverting paths


Flight

2011-07-03 05:48:36

I'm wanting to invert 'BankPath' and use it as 'FurnacePath'. Here's what I have:


Tiles[BankPath] := [Tile(2973,3370),Tile(2965,3377),Tile(2950,3375),Tile(2946,3369)];
Tiles[FurnacePath] := InvertPath_F(Tiles[BankPath]);

Here's the 'InvertPath_F' function:

//By Drags111, modified to return path
Function InvertPath_F(var Path: TTileArray): TTileArray;
var
Temp: TTileArray;
i: integer;
begin
for i := High(Path) downto 0 do
begin
SetLength(Temp, Length(Temp)+1);
Temp[High(Temp)] := Path[i];
end;
Result := Temp;
end;

I've tried all of the following:

Tiles[FurnacePath] := InvertPath_F(Tiles[BankPath]);
Tiles[FurnacePath] := [InvertPath_F(Tiles[BankPath])];
Tiles[FurnacePath] := InvertPath_F([Tiles[BankPath]]);
Tiles[FurnacePath] := InvertPath_F([BankPath]);
Tiles[FurnacePath] := InvertPath_F(BankPath);

What am I missing?

Floor66

2011-07-03 05:55:20



//By Drags111, modified to return path
function InvertPath_F(Path: TTileArray): TTileArray;
var
i, j: integer;
begin
SetLength(Result, Length(Path));
j := 0;
for i := High(Path) downto 0 do
begin
Result[j] := Path[i];
Inc(j);
end;
end;

Could you try that?

Flight

2011-07-03 05:57:55

I'll give it a shot, give me a second. By the way, it compiled this time so here's hoping.

Edit: Worked like a charm, thank you Floor66. :) Rep for you. :D