LuaEntity attributes to associate robots and their delivery destinations

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
shanemadden
Fast Inserter
Fast Inserter
Posts: 128
Joined: Thu Feb 08, 2018 8:25 am
Contact:

LuaEntity attributes to associate robots and their delivery destinations

Post by shanemadden »

Looking for attributes to associate active construction and logistic bots with the entity they're on their way to.

On the robot entity, an attribute like destination or delivery_target with the entity that the robot's on its way to deliver to or build, as well as possibly another for where it's on its way to get the source item from (pickup_target?).

On the destination entity, an attribute that gives an array of the robots that are on their way to deliver something at this entity.

Some of these might make more sense returning LuaLogisticPoint instead of entities, though in some cases a delivery target wouldn't have one, like entity ghosts to be built.
shanemadden
Fast Inserter
Fast Inserter
Posts: 128
Joined: Thu Feb 08, 2018 8:25 am
Contact:

Re: LuaEntity attributes to associate robots and their delivery destinations

Post by shanemadden »

And our friend Stapler would also like an event fired when a robot is 'spawned' / sent out for delivery :)
Rseding91
Factorio Staff
Factorio Staff
Posts: 14345
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaEntity attributes to associate robots and their delivery destinations

Post by Rseding91 »

The robots target we can do. The entity knowing what robots are on the way is an O(N) scan of all robots on the surface so that's not happening. Also, no event when a robot is spawned. The performance issues aside (with how frequently the event would fire): mods mess with things and I don't want to have to safety check every single time a robot is created to work on something that one or more mods hasn't broken something in the logistics system that was trying to dispatch the robot.
If you want to get ahold of me I'm almost always on Discord.
shanemadden
Fast Inserter
Fast Inserter
Posts: 128
Joined: Thu Feb 08, 2018 8:25 am
Contact:

Re: LuaEntity attributes to associate robots and their delivery destinations

Post by shanemadden »

Great, thanks! That's all I need for the use case I'm thinking of, and I suppose if someone wants to do the big O(N) scan and incur the performance pain they would be able to do it directly with find_entities_filtered.
aaron311
Inserter
Inserter
Posts: 21
Joined: Sun Mar 22, 2020 2:30 am
Contact:

Re: LuaEntity attributes to associate robots and their delivery destinations

Post by aaron311 »

I know this is engaging in massive thread-necromancy here but I too really would be interested in this API.

Thinking some way to:
1. Read current long-term destination entity (robot's target job). Write would be nice too, but admittedly the rules around this could be complex.
2. Read/write the current short-term destination entity (e.g. robots target charging station, or maybe would be the target job).
yesennes
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Oct 08, 2021 3:24 pm
Contact:

Re: LuaEntity attributes to associate robots and their delivery destinations

Post by yesennes »

+1 This would be great!

Also, it would be nice if you could nil out the target to get the networks to reassign the job. I hate it when after my first wave of personal robots finish their jobs, I'm stuck waiting for robots on the other side of my base to finish construction of a blueprint. I wish I could tell them to go home and let my now inactive robots have a chance to snag another job
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: LuaEntity attributes to associate robots and their delivery destinations

Post by mrvn »

Rseding91 wrote: Thu Nov 29, 2018 6:06 pm The robots target we can do.
Since this got necroed anyway: It's been 3 years. Have you done it yet? Not seeing it in the Lua docs.

If one could write the short-term destination one could play around with all kinds of optimizations for bots even if the performance would be horrible in lua. Good enough for a proof-of-concept.
Rseding91 wrote: Thu Nov 29, 2018 6:06 pm The entity knowing what robots are on the way is an O(N) scan of all robots on the surface so that's not happening.
How do you get the stats for the logistic chests how many items are getting picked up? Wouldn't that code lend itself to also record the entity IDs of the bots targeting the chest (or any other entity)? You don't need to scan, you only have to keep a record of the bot as you assign them.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14345
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaEntity attributes to associate robots and their delivery destinations

Post by Rseding91 »

Logistic entities keep track of the number of items expected to be delivered/removed from themselves. They do not track what robots are going to be doing that.
If you want to get ahold of me I'm almost always on Discord.
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: LuaEntity attributes to associate robots and their delivery destinations

Post by mrvn »

Rseding91 wrote: Sat Oct 09, 2021 2:59 pm Logistic entities keep track of the number of items expected to be delivered/removed from themselves. They do not track what robots are going to be doing that.
That's not what I said. I mend that that code path already exists and adding what robot is doing it could be simple. No O(n) work needed.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14345
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaEntity attributes to associate robots and their delivery destinations

Post by Rseding91 »

mrvn wrote: Sat Oct 09, 2021 3:20 pm
Rseding91 wrote: Sat Oct 09, 2021 2:59 pm Logistic entities keep track of the number of items expected to be delivered/removed from themselves. They do not track what robots are going to be doing that.
That's not what I said. I mend that that code path already exists and adding what robot is doing it could be simple. No O(n) work needed.
Unless base game would be wanting to use it, we aren't likely to ever add things like that just for modding use. It would add performance overhead, save file size, save time/load time all for something base game wouldn't use.
If you want to get ahold of me I'm almost always on Discord.
mrvn
Smart Inserter
Smart Inserter
Posts: 5884
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: LuaEntity attributes to associate robots and their delivery destinations

Post by mrvn »

Too bad.

I would really like to make Bluebuilt not built ghosts that have a personal construction bot on the way. That just slows down building stuff because it wastes the construction power of the bots.
Post Reply

Return to “Modding interface requests”