[0.17.79] get_associated_characters() returns empty table on new game with character

Place to get help with not working mods / modding interface.
Honktown
Smart Inserter
Smart Inserter
Posts: 1058
Joined: Thu Oct 03, 2019 7:10 am
Contact:

[0.17.79] get_associated_characters() returns empty table on new game with character

Post by Honktown »

I was testing unrelated things with console commands in a new single player game, and using

Code: Select all

game.players[1].get_associated_characters()
returns an empty table, but

Code: Select all

game.players[1].character
returns my character.

I don't know if that's intentional behavior or not, that the starting character is not "associated". Honestly I'm not sure what being associated means if this is expected behavior. I got the impression a player "owned" characters, and may be assigned multiple, so they could switch them without searching/keeping track of the individual character entities. In that sense, I'd expect the starting character to be associated.

Example command:

Code: Select all

/c game.print(#game.players[1].get_associated_characters())
prints 0

Code: Select all

/c game.print(game.players[1].character.name)
prints character

(searched forum but didn't find much of anything on the topic, and not this particular example)
I have mods! I guess!
Link
Rseding91
Factorio Staff
Factorio Staff
Posts: 15996
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17.79] get_associated_characters() returns empty table on new game with character

Post by Rseding91 »

Thanks for the report. That's intended: associated characters is not the character entity the player is currently controlling.

Moving to modding help.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Modding help”