LuaSurface.request_path documentation

Place to post guides, observations, things related to modding that are not mods themselves.
Post Reply
Honktown
Smart Inserter
Smart Inserter
Posts: 1025
Joined: Thu Oct 03, 2019 7:10 am
Contact:

LuaSurface.request_path documentation

Post by Honktown »

(Note from Therenas: Split this discussion out to its own thread so the doc improvements one isn't cluttered up with it)
Pi-C wrote:
Wed Jun 23, 2021 9:41 am
LuaSurface.request_path
Starts a path find request without actually ordering a unit to move. Result is ultimately returned asynchronously via on_script_path_request_finished.
This looks like it is for units (biters/spitters) only, but we use that for "car" prototypes in the "Autodrive" mod and I suppose it will also work with "spider-vehicle" prototypes.
Erm, it doesn't take an entity prototype or anything at all, only a bounding box and collision mask. The bounding box could even be dimensions that no prototype uses. I suppose the use of "unit" in the description might confuse someone. If you were to "clarify" it, would you have any suggestions?
I have mods! I guess!
Link

Pi-C
Smart Inserter
Smart Inserter
Posts: 1652
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Small documentation improvement requests

Post by Pi-C »

Honktown wrote:
Thu Jun 24, 2021 1:32 am
Pi-C wrote:
Wed Jun 23, 2021 9:41 am
LuaSurface.request_path
Erm, it doesn't take an entity prototype or anything at all, only a bounding box and collision mask. The bounding box could even be dimensions that no prototype uses.
Oh, you're right. :oops:
I suppose the use of "unit" in the description might confuse someone.
Especially if that someone is working on a vehicle mod and has to deal with another mod replacing cars with units for pathfinding. That's why my first reaction was: "Wait, that's not limited to units, we've used that for cars!" :-)
If you were to "clarify" it, would you have any suggestions?
Prototype/Unit is a subset of Prototype/EntityWithHealth, so replacing "a unit" with "an entity" should be clear enough. "Entity" is such a general term that it covers even particles and projectiles.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

posila
Factorio Staff
Factorio Staff
Posts: 5202
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Small documentation improvement requests

Post by posila »

Pi-C wrote:
Thu Jun 24, 2021 6:16 am
Prototype/Unit is a subset of Prototype/EntityWithHealth, so replacing "a unit" with "an entity" should be clear enough. "Entity" is such a general term that it covers even particles and projectiles.
I feel like such phrasing might create an impression that it is possible to order any entitiy to follow a path found by the pathfinder ... which is not true. Only units (and ) can follow (pathfinder) paths. What about changing "a unit" to "any unit"? :D

Pi-C
Smart Inserter
Smart Inserter
Posts: 1652
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Small documentation improvement requests

Post by Pi-C »

posila wrote:
Thu Jun 24, 2021 12:16 pm
Pi-C wrote:
Thu Jun 24, 2021 6:16 am
Prototype/Unit is a subset of Prototype/EntityWithHealth, so replacing "a unit" with "an entity" should be clear enough. "Entity" is such a general term that it covers even particles and projectiles.
I feel like such phrasing might create an impression that it is possible to order any entitiy to follow a path found by the pathfinder ... which is not true. Only units (and ) can follow (pathfinder) paths. What about changing "a unit" to "any unit"? :D
Then we'd still have the issue that "unit" is the prototype for biters/spitters. You could leave the sentence as it is if you'd add another one where you point out what prototypes this applies to: unit, car, spider-vehicle and character would be the most obvious. But perhaps somebody would make a mod where you place just one miner (thinking of big excavators) on an ore patch and let it path to another patch once the first has been depleted? The term "entity" would allow for that. :-)
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

posila
Factorio Staff
Factorio Staff
Posts: 5202
Joined: Thu Jun 11, 2015 1:35 pm
Contact:

Re: Small documentation improvement requests

Post by posila »

Pi-C wrote:
Thu Jun 24, 2021 12:59 pm
Then we'd still have the issue that "unit" is the prototype for biters/spitters. You could leave the sentence as it is if you'd add another one where you point out what prototypes this applies to: unit, car, spider-vehicle and character would be the most obvious. But perhaps somebody would make a mod where you place just one miner (thinking of big excavators) on an ore patch and let it path to another patch once the first has been depleted? The term "entity" would allow for that. :-)
But car, spider-vehicle nor character cannot be ordered to move along the path, only units can. The sentence is there just to make it clear, the pathfinding request is not tied to any unit actually moving. And unit is the only possible entity type that could be ordered to follow the path on its own.

Pi-C
Smart Inserter
Smart Inserter
Posts: 1652
Joined: Sun Oct 14, 2018 8:13 am
Contact:

Re: Small documentation improvement requests

Post by Pi-C »

posila wrote:
Thu Jun 24, 2021 1:38 pm
But car, spider-vehicle nor character cannot be ordered to move along the path, only units can. The sentence is there just to make it clear, the pathfinding request is not tied to any unit actually moving. And unit is the only possible entity type that could be ordered to follow the path on its own.
Sorry, you're right! Looked at the mod code again: We've abused request_path to get the path and moved our cars to the next position on it per script … Yes, it's been a long time since I've touched that mod (it hasn't even been updated to 1.1 yet), so I'm afraid I mixed things up.
A good mod deserves a good changelog. Here's a tutorial (WIP) about Factorio's way too strict changelog syntax!

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: Small documentation improvement requests

Post by eradicator »

posila wrote:
Thu Jun 24, 2021 1:38 pm
The sentence is there just to make it clear, the pathfinding request is not tied to any unit actually moving. And unit is the only possible entity type that could be ordered to follow the path on its own.
Wait wait wait.......

As far as I understand LuaSurface.request_path and on_script_path_request_finished are exclusively used to calculate paths for non-units. Moving units is done via LuaEntity.set_command or LuaUnitGroup.set_command, neither of which takes <path :: array[PathfinderWaypoint]> as an input paramter. Units can calculate the path themselfs. So the main usecase for LuaSurface.request_path to me seems to be giving scripts the ability to move $something *like* it was a unit, but without it *being* a unit.

Code: Select all

Starts a path find request without actually ordering a unit to move.

Code: Select all

Finds a path using the unit pathfinding algorithm.
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

User avatar
Therenas
Factorio Staff
Factorio Staff
Posts: 232
Joined: Tue Dec 11, 2018 2:10 pm
Contact:

Re: LuaSurface.request_path documentation

Post by Therenas »

Appreciate all the feedback, I'll change the method description to lay out these nuances.

Post Reply

Return to “Modding discussion”