Code: Select all
function on_player_created(event)
local player = game.players[event.player_index]
local newForce = createPlayerForce(player)
game.print('1' .. player.force.name)
game.print('2' .. newForce.name)
player.force = newForce
game.print('3' .. player.force.name)
game.print('4' .. newForce.name)
newForce.share_chart = true
befriendRadarForce(newForce)
end
script.on_event(defines.events.on_player_created, on_player_created)
a) first player gets created
b) first player gets assigned to force named after him
c) right after game start I write command to check and first player isn't in his force (he is in 'player' force)
d) another player joins
e) he stays in force named after him
*) force named after first player exists. Probably player got assigned here, but game than moved him to 'player' force.
What I would expect : All players are affected equally by that script
I believe during map starting first player gets created and he is "force-less", only after that forces are being created and player is assigned to first one.
What could solve this : 1. Couldn't player be created after forces? (as I guess it would happen if I ran headless without pause when no-players)
Perhaps I have bad idea on how I do this stuff and by doing it some other way I would avoid that problem, but still, I believe it would be more "proper" if _on_player_created gave me possibility to assign new player properties.