Easily confirmed by opening a film of a network game, switching to any perspective besides the host’s, then typing the following code into the console:
for p in Players() do p:print(p) end
This will direct a message to each player in the game containing only ‘player x’, where x is their player id. No matter whose perspective you’re viewing, the game will print ‘player 0’. IMO, this is an engine bug; while there’s probably no way to make perspective switching not behave weirdly in live gameplay, ISTM that films should show messages to the player whose perspective you’re viewing, rather than messages to the host. It might also make sense to make a note of the discrepancy somewhere in the Lua documentation.
Edit: I should note that you can probably use a very ugly hack to get around this along the lines of:
function print_player_message(p, m)
if Game.replay and Players.local_player.viewed_player == p
then Players.print(m)
else
p:print(m)
end
end
Then, instead of Players[x]:print(m), you’d use print_player_message(Players[x], m). I think this would work, but it’s ugly and hacky and I hate it.
Easily confirmed by opening a film of a network game, switching to any perspective besides the host’s, then typing the following code into the console:
This will direct a message to each player in the game containing only ‘player x’, where x is their player id. No matter whose perspective you’re viewing, the game will print ‘player 0’. IMO, this is an engine bug; while there’s probably no way to make perspective switching not behave weirdly in live gameplay, ISTM that films should show messages to the player whose perspective you’re viewing, rather than messages to the host. It might also make sense to make a note of the discrepancy somewhere in the Lua documentation.
Edit: I should note that you can probably use a very ugly hack to get around this along the lines of:
Then, instead of
Players[x]:print(m)
, you’d useprint_player_message(Players[x], m)
. I think this would work, but it’s ugly and hacky and I hate it.