The A* algorithm is a pathfinding algorithm: it can be used to search for paths between points in a graph. This mod provides a pathfinding function that can be used to perform such searches in the voxel-based fame world of Luanti. It can be used, for instance, for mob AI.
The intent of this mod is to provide a better alternative for Luanti's built-in pathfinder core.find_path. Although the built-in pathfinder is fast, it lacks various useful features, such as the ability to work with mobs larger than 1x1 nodes. Therefore, this implementation allows specifying width and height and comes with various other improvements.
These improvements are not completely free, and searches will take longer: (on my machine, CPU: Ryzen 5) the built-in core.find_path often takes far less than 1 ms to produce a path. In contrast, it is rare (again, on my machine) for star.find_path to take less than 1 ms. However, the performance is, in my opinion, acceptable after several runs. Maybe LuaJIT somehow optimizes it?
Current status:
- Entity size
works - Avoiding danger (lava, etc.)
works - Climbing ladders
works - Diagonal movement
works?
Testing tool disabled starting from 2026-01-18.
API 🔗
star.find_path(pos1, pos2, settings) 🔗
Returns a path as a flat array (from end to start): {x1, y1, z1, x2, y2, z2, ...}
Arguments:
pos1,pos2:{x = ..., y = ..., z = ...}pos1is the starting position andpos2the target position.
settings:{height = ..., etc.}
Settings (values must be positive natural numbers):
width: Specifies the object size along x- and z-axes. Defaults to1.height: Specifies the object size along the y-axis. Defaults to2.max_jump: Specifies the maximum jump height. Defaults to1.max_drop: Specifies the maximum drop height. Defaults to1.max_iter: Specifies the maximum number of main loop iterations before quitting. Defaults to256. For now, has a hard limit of1024.climb: Sets the ability to climb ladders (trueorfalse). Defaults tofalse.
TODO:
- Weighted terrain
- Sometimes behaves weirdly???