Allow for preferred tiles in LuaSurface::request_path

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Pi-C
Smart Inserter
Smart Inserter
Posts: 1792
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Allow for preferred tiles in LuaSurface::request_path

Post 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. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!
Post Reply

Return to “Modding interface requests”