Page 1 of 1

Reverse lookup: game.forces[force_index]

Posted: Thu May 30, 2019 7:39 pm
by eradicator
What?

Return the force when indexing game.forces with a force's index, the same as it works for game.players and game.surfaces.

Doesn't work:

Code: Select all

/c game.print(game.forces[game.forces['player'].index].name)
Works:

Code: Select all

/c game.print(game.surfaces[game.surfaces['nauvis'].index].name)
/c game.print(game.players[game.players[1].index].name)
Why?

I'm indexing some global tables by force index, and i'd like to get the force back without looping through all forces. Besides to me this was "unexpected behavior" as it works fine with players and surfaces.

Re: Reverse lookup: game.forces[force_index]

Posted: Fri May 31, 2019 5:30 pm
by Rseding91
Ok, i've added support for it for the next version of 0.17.

Re: Reverse lookup: game.forces[force_index]

Posted: Fri May 31, 2019 5:56 pm
by eradicator
Thank you.