Module core.node
The Node class.
The node represents a cell (or a tile) on a collision map. Basically, for each single cell (tile) in the collision map passed-in upon initialization, a node object will be generated and then cached within the grid .
In the following implementation, nodes can be compared using the <
operator. The comparison is
made with regards of their f
cost. From a given node being examined, the pathfinder will expand the search
to the next neighbouring node having the lowest f
cost. See core.bheap for more details.
Class Node
Node:new (x, y) | Inits a new node |
Node:getX () | Returns x-coordinate of a node |
Node:getY () | Returns y-coordinate of a node |
Node:getPos () | Returns x and y coordinates of a node |
Node:getClearance (walkable) | Returns the amount of true clearance for a given node |
Node:removeClearance (walkable) | Removes the clearance value for a given walkable. |
Node:reset () | Clears temporary cached attributes of a node . |
Class Node
The Node class.This class is callable. Therefore,_
Node(...)
acts as a shortcut to Node:new(...)
.
- Node:new (x, y)
-
Inits a new node
Parameters:
- x int the x-coordinate of the node on the collision map
- y int the y-coordinate of the node on the collision map
Usage:
local node = Node(3,4)
Returns:
- Node:getX ()
-
Returns x-coordinate of a node
Usage:
local x = node:getX()
Returns:
-
number
the x-coordinate of the node
- Node:getY ()
-
Returns y-coordinate of a node
Usage:
local y = node:getY()
Returns:
-
number
the y-coordinate of the node
- Node:getPos ()
-
Returns x and y coordinates of a node
Usage:
local x, y = node:getPos()
Returns:
- Node:getClearance (walkable)
-
Returns the amount of true clearance
for a given node
Parameters:
Usage:
-- Assuming walkable was 0 local clearance = node:getClearance(0)
Returns:
- Node:removeClearance (walkable)
-
Removes the clearance value for a given walkable.
Parameters:
Usage:
-- Assuming walkable is defined node:removeClearance(walkable)
Returns:
- Node:reset ()
-
Clears temporary cached attributes of a node .
Deletes the attributes cached within a given node after a pathfinding call.
This function is internally used by the search algorithms, so you should not use it explicitely.
Usage:
local thisNode = Node(1,2) thisNode:reset()
Returns: