#
pathfinder
Allows control over the pathfinder in lua.
#
Functions
pathfinder.set_destination(x: number, y: number, z: number)
- Sets the destination for the pathfinder.
pathfinder.add_destination(x: number, y: number, z: number)
- Adds a destination to the pathfinder.
pathfinder.clear_destinations()
- Clears all the destinations in the pathfinder.
pathfinder.recalc()
- Force the pathfinder to recalculate the path.
pathfinder.get_destinations(): table
- Retrieves all the destinations in the pathfinder system.
local destinations = secret.pathfinder.get_destinations()
for i, node in ipairs(destinations) do
print("destination " .. i .. ": X=" .. node.x .. ", Y=" .. node.y .. ", Z=" .. node.z)
end
pathfinder.current_destination(): number
- Returns the index of the current destination in the pathfinding sequence.
pathfinder.current_destination_pos(): table
- Returns the position of the destination in the pathfinding.
local pos = secret.pathfinder.current_destination_pos()
print(pos.x, pos.y, pos.z)
pathfinder.get_nodes(): table
- Retrieves all the node positions in the pathfinder system.
local nodes = secret.pathfinder.get_nodes()
for i, node in ipairs(nodes) do
print("Node " .. i .. ": X=" .. node.x .. ", Y=" .. node.y .. ", Z=" .. node.z)
end
pathfinder.remove_nodes(x: number, y: number, z: number, radius: number)
- Removes nodes within a specified radius of a given position.
-- Remove nodes within a 500-unit radius of position (100, 200, 300)
secret.pathfinder.remove_nodes(100, 200, 300, 500)
pathfinder.get_path(): table
- Retrieves the generated path (waypoints) for the pathfinder.
local path = secret.pathfinder.get_path()
for i, waypoint in ipairs(path) do
print("Waypoint " .. i .. ": X=" .. waypoint.x .. ", Y=" .. waypoint.y .. ", Z=" .. waypoint.z)
end
pathfinder.set_path(path: table)
- Sets the path for the pathfinder by providing a table of waypoints.
local new_path = {
{x = 100, y = 200, z = 300},
{x = 150, y = 250, z = 350},
{x = 200, y = 300, z = 400}
}
secret.pathfinder.set_path(new_path)
#
Events
path_found()
- Called when the pathfinder successfully calculates a valid path to the target destination.
secret.pathfinder.listener.add("path_found", "Example", function()
print("path was found!")
end)
start_walking()
- Called when the pathfinder begins moving along the calculated path.
stuck()
- Called when pathfinder is unable to proceed due to an obstruction or unexpected issue.
- Internally, the pathfinder will attempt to recalculate the path when this is called.
path_finished()
- Called when the pathfinder reaches the target destination.