Page 1 of 1
Allow for preferred tiles in LuaSurface::request_path
Posted: Sun Feb 15, 2026 11:02 am
by Pi-C
What
Please allow for calling LuaSurface::request_path with a new argument
preferred_tiles. This could be in the form
Code: Select all
-- Array of arrays of tile prototype names.
preferred_tiles = {
-- All tiles listed in an array have the same
{ "concrete", "hazard-concrete-left", "hazard-concrete-right", },
{ "stone-path" },
...
}
-- Map: tile_name --> priority
preferred_tiles = {
["concrete"] = 1,
["hazard-concrete-left"] = 1,
["hazard-concrete-right"] = 1,
["stone-path"] = 2,
...
}
When searching for a path, try to path over preferred tiles even if the path to
goal becomes a bit longer.
Use case
My mod
Autodrive makes use of
LuaSurface::request_path() to navigate vehicles from their current position to another destination. What I've often observed is that vehicles move slowly over unfavourable terrain while, say, a concrete road leads in roughly the same direction just a few tiles away from the calculated path. Being able to optionally (!) specify a list of tile-prototype names to be preferred during pathing would allow players to see their carefully laid out roads actually be used by automatically driving vehicles.
