Module core.path

The Path class.

The path class is a structure which represents a path (ordered set of nodes) from a start location to a goal. An instance from this class would be a result of a request addressed to Pathfinder:getPath.

This module is internally used by the library on purpose. It should normally not be used explicitely, yet it remains fully accessible.

Class Path

Path:new () Inits a new path .
Path:iter () Iterates on each single node along a path .
Path:nodes () Iterates on each single node along a path .
Path:getLength () Evaluates the path length
Path:addNode (node [, index]) Counts the number of steps.
Path:fill () Path filling modifier.
Path:filter () Path compression modifier.
Path:clone () Clones a path .
Path:isEqualTo (p2) Checks if a path is equal to another.
Path:reverse () Reverses a path .
Path:append (p) Appends a given path to self.


Class Path

The Path class.
This class is callable. Therefore, Path(...) acts as a shortcut to Path:new(...).
Path:new ()
Inits a new path .

Usage:

    local p = Path()

Returns:

    path a path
Path:iter ()
Iterates on each single node along a path . At each step of iteration, returns the node plus a count value. Aliased as Path:nodes

Usage:

     for node, count in p:iter() do
       ...
     end

Returns:

  1. node a node
  2. int the count for the number of nodes

see also:

Path:nodes ()
Iterates on each single node along a path . At each step of iteration, returns a node plus a count value. Alias for Path:iter

Usage:

     for node, count in p:nodes() do
       ...
     end	

Returns:

  1. node a node
  2. int the count for the number of nodes

see also:

Path:getLength ()
Evaluates the path length

Usage:

    local len = p:getLength()

Returns:

    number the path length
Path:addNode (node [, index])
Counts the number of steps. Returns the number of waypoints (nodes) in the current path.

Parameters:

  • node node a node to be added to the path
  • index int the index at which the node will be inserted. If omitted, the node will be appended after the last node in the path.

Usage:

    local nSteps = p:countSteps()

Returns:

    path self (the calling path itself, can be chained)
Path:fill ()
Path filling modifier. Interpolates between non contiguous nodes along a path to build a fully continuous path . This maybe useful when using search algorithms such as Jump Point Search. Does the opposite of Path:filter

Usage:

    p:fill()

Returns:

    path self (the calling path itself, can be chained)

see also:

Path:filter ()
Path compression modifier. Given a path , eliminates useless nodes to return a lighter path
consisting of straight moves. Does the opposite of Path:fill

Usage:

    p:filter()

Returns:

    path self (the calling path itself, can be chained)

see also:

Path:clone ()
Clones a path .

Usage:

    local p = path:clone()

Returns:

    path a path
Path:isEqualTo (p2)
Checks if a path is equal to another. It also supports filtered paths (see Path:filter).

Parameters:

Usage:

    print(myPath:isEqualTo(anotherPath))

Returns:

    boolean a boolean
Path:reverse ()
Reverses a path .

Usage:

    myPath:reverse()

Returns:

    path self (the calling path itself, can be chained)
Path:append (p)
Appends a given path to self.

Parameters:

Usage:

    myPath:append(anotherPath)

Returns:

    path self (the calling path itself, can be chained)
generated by LDoc 1.2