Expose active bot count

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
Xorimuth
Filter Inserter
Filter Inserter
Posts: 625
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Expose active bot count

Post by Xorimuth »

Currently trains with wagons that have equipment grids are given the wait condition "Robots inactive". I'm creating some spidertron wait conditions and I'd like to be able to use whatever is behind this, but I can't find it exposed anywhere. I don't know if it should be in LuaPlayer, LuaControl, LuaEntity, LuaEquipment, or LuaEquipmentGrid... I guess that depends on how it is implemented internally.

For my purposes, a boolean would be sufficient, but an int would be more useful for others.

Thanks!

Image
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

User avatar
Silari
Filter Inserter
Filter Inserter
Posts: 490
Joined: Sat Jan 27, 2018 10:04 pm
Contact:

Re: Expose active bot count

Post by Silari »

Entities have a 'logistic_network' property that returns a LuaLogisticNetwork for whatever network they're in. For player characters and spidertrons (and probably other vehicles with an equipment grid with roboports, though I only verified player characters and spidertrons) that's their personal network. LuaLogisticNetwork has two properties 'all_construction_robots' and 'available_construction_robots' - if the first isn't == to the later, it's got some bots active. Number of active bots is available - all.

Xorimuth
Filter Inserter
Filter Inserter
Posts: 625
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: Expose active bot count

Post by Xorimuth »

Silari wrote:
Thu Apr 22, 2021 8:13 am
Entities have a 'logistic_network' property that returns a LuaLogisticNetwork for whatever network they're in. For player characters and spidertrons (and probably other vehicles with an equipment grid with roboports, though I only verified player characters and spidertrons) that's their personal network. LuaLogisticNetwork has two properties 'all_construction_robots' and 'available_construction_robots' - if the first isn't == to the later, it's got some bots active. Number of active bots is available - all.
Oh brilliant, thank you very much!
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

Xorimuth
Filter Inserter
Filter Inserter
Posts: 625
Joined: Sat Mar 02, 2019 9:39 pm
Contact:

Re: Expose active bot count

Post by Xorimuth »

For some reason doing `logistic_network.all_construction_robots == logistic_network.available_construction_robots` wouldn't quite work. It would usually trigger just before all the robots were back inside the spidertron, leaving some behind. Doing `not next(logistic_network.construction_robots)` works perfectly though.
My mods
Content: Freight Forwarding | Spidertron Patrols | Spidertron Enhancements | Power Overload
QoL: Factory Search | Remote Configuration | Module Inserter Simplified | Wire Shortcuts X | Ghost Warnings

Post Reply

Return to “Modding interface requests”