How to access robot follower count for a player?

Place to get help with not working mods / modding interface.
Post Reply
slindenau
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Fri Mar 25, 2016 1:46 pm
Contact:

How to access robot follower count for a player?

Post 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 ;)?
My mod: "Auto Deploy Destroyers" (follower robots) viewtopic.php?f=97&t=24545

slindenau
Long Handed Inserter
Long Handed Inserter
Posts: 73
Joined: Fri Mar 25, 2016 1:46 pm
Contact:

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

Post 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 :).
My mod: "Auto Deploy Destroyers" (follower robots) viewtopic.php?f=97&t=24545

User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

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

Post 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).
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.

Post Reply

Return to “Modding help”