Page 1 of 1

How to access robot follower count for a player?

Posted: Fri Apr 29, 2016 8:08 pm
by slindenau
For my mod im trying to access the current robot follower count on a player.
I looked over the API, and there is a call for the max follower count, but i couldn't find one for the actual current follower count.

Currently i use this call:

Code: Select all

player.force.get_entity_count("destroyer")
It works fine in singleplayer, but in multiplayer this count returns ALL the follower bots in the same force.
And by default in multiplayer all players are in the same force...so for my goal it doesn't work.

Is there a "cheap" way to count the current robot followers for a player, or do i need to make a modding interface request for this? Or did i totally miss something ;)?

Re: How to access robot follower count for a player?

Posted: Tue Jun 28, 2016 7:50 am
by slindenau
Small bump...looked over the new 0.13 API, but i still don't see a way to retrieve this information.
Any suggestions? Else i will request this to be moved to "Modding interface requests".

Thanks :).

Re: How to access robot follower count for a player?

Posted: Sat Sep 10, 2016 3:17 am
by aubergine18
Assuming that the robots stay close to player, you could maybe use player.surface.count_entities_filtered?

http://lua-api.factorio.com/latest/LuaS ... s_filtered

It's still going to be much slower than get_entity_count() though, as it's having to search the map for entities instead of just counting entities. It's probably worth making a request for a player.get_entity_count() function (like the force.get_entity_count() but specific to entities built by that player, which hopefully won't be too painful for devs to implement).