PLEASE HELP ME! player.character

Place to get help with not working mods / modding interface.
User avatar
Stx3
Fast Inserter
Fast Inserter
Posts: 201
Joined: Wed Nov 05, 2014 9:04 am
Contact:

PLEASE HELP ME! player.character

Post by Stx3 »

Heelo!
After update to 0.15.x i cant use command player.character
Attemp to index field "character" (a nil value)

Code: Select all

character
Type: Lua/Character

The character controlled by this player.

   game.player.character.health = 50
   local character = game.player.character -- store the pointer to the character
   game.player.character = nil -- disconnect the character, player will gain ghost view
   game.player.character = character -- connect player to the character again
please help me!
Image
Image
User avatar
Stx3
Fast Inserter
Fast Inserter
Posts: 201
Joined: Wed Nov 05, 2014 9:04 am
Contact:

Re: PLEASE HELP ME! player.character

Post by Stx3 »

in pvp mode player dont have a character! lol thx)))
Image
Image
Rseding91
Factorio Staff
Factorio Staff
Posts: 14720
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: PLEASE HELP ME! player.character

Post by Rseding91 »

"game.player" isn't valid in mods since 0.13.0.

You have to reference some specific player - or iterate all players. All events related to a player will contain player_index as a property which you can use with game.players[index] to work on that player.
If you want to get ahold of me I'm almost always on Discord.
Post Reply

Return to “Modding help”