Waypoint finder

I currently have a table full of coordinates.

If I pick out a set of coordinates from that table, is there a way I can loop through that table, and find all the coordinates required, to go to the selected location?

Eg.

Going from Coords[1] to Coords[10] (Not my actual coords)

``````

local Coords = {
Vector( 100, 0, 0),
Vector( 110, 0, 0),
Vector( 120, 0, 0),
Vector( 130, 0, 0),
Vector( 140, 0, 0),
Vector( 150, 0, 0),
Vector( 160, 0, 0),
Vector( 170, 0, 0),
Vector( 180, 50, 0),
Vector( 190, 100, 0),
}

``````

Sure you can loop through them and compare, but what exactly are you trying to do?

A kind of GMOD Sat nav system.

Every time aplayer gets to one of the coords, I want to find the next coord they need to go to.

[editline]9th May 2015[/editline]

A kind of GMOD Sat nav system.

Every time a player gets to one of the coords, I want to find the next coord they need to go to, in order to complete their journey.

Each player has a value on their object ( pl.CurrentPoint = 1 )

In an appropriate hook such as Move or Think, for each player, check how close they are to the point in their table ( dist = pl:GetPos( ):Distance( Coords[ pl.CurrentPoint ] ) ).

If they are within an acceptable distance ( I’d suggest within to 10 ), add 1 to their current point.

If their current point is greater than the number of points in the table, they have completed the route.