Page 1 of 1

Expose active bot count

Posted: Thu Apr 22, 2021 1:58 am
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

Re: Expose active bot count

Posted: Thu Apr 22, 2021 8:13 am
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.

Re: Expose active bot count

Posted: Sun Apr 25, 2021 6:18 pm
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!

Re: Expose active bot count

Posted: Sat May 01, 2021 7:06 pm
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.