Greetings everyone,
I eventually decided to join the forum - as I can't find any questions/answers relating to my problem.
I'd like to access game.players - multiplayer name for each player who has joined.
I hope someone can help me with this
How to get multiplayer name?
- MisterBrownZA
- Burner Inserter
- Posts: 8
- Joined: Mon Nov 02, 2015 7:10 am
- Contact:
Re: How to get multiplayer name?
MisterBrownZA wrote:Greetings everyone,
I eventually decided to join the forum - as I can't find any questions/answers relating to my problem.
I'd like to access game.players - multiplayer name for each player who has joined.
I hope someone can help me with this
Code: Select all
for _, v in pairs(game.players) do game.local_player.print(v.name) end
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
- MisterBrownZA
- Burner Inserter
- Posts: 8
- Joined: Mon Nov 02, 2015 7:10 am
- Contact:
Re: How to get multiplayer name?
Amazing! So easy!prg wrote:Code: Select all
for _, v in pairs(game.players) do game.local_player.print(v.name) end
Quick question. I couldn't find local_player.print() method in the wiki, so wasn't sure how I was supposed to do this.
I'll try this when I get home tonight.
I'm guessing v.name returns the player's "get_localised_entity_name"
Re: How to get multiplayer name?
Lua/Game#local_playerMisterBrownZA wrote:Quick question. I couldn't find local_player.print() method in the wiki, so wasn't sure how I was supposed to do this.
Lua/Player#print
That contains whatever the player entered in options -> other -> multiplayer username. localised_name is only a thing for entities, like the player's character, but that only ever says "player" so it's not very interesting.MisterBrownZA wrote:I'm guessing v.name returns the player's "get_localised_entity_name"
Automatic Belt (and pipe) Planner—Automate yet another aspect of constructing your factory!
- MisterBrownZA
- Burner Inserter
- Posts: 8
- Joined: Mon Nov 02, 2015 7:10 am
- Contact:
Re: How to get multiplayer name?
Bravo. Everything worked perfectly!prg wrote:Lua/Game#local_playerMisterBrownZA wrote:Quick question. I couldn't find local_player.print() method in the wiki, so wasn't sure how I was supposed to do this.
Lua/Player#print
That contains whatever the player entered in options -> other -> multiplayer username. localised_name is only a thing for entities, like the player's character, but that only ever says "player" so it's not very interesting.MisterBrownZA wrote:I'm guessing v.name returns the player's "get_localised_entity_name"
Thanks a lot prg!