Player-specific debug output in local chat only

Place to get help with not working mods / modding interface.
User avatar
Oktokolo
Filter Inserter
Filter Inserter
Posts: 890
Joined: Wed Jul 12, 2017 5:45 pm
Contact:

Player-specific debug output in local chat only

Post by Oktokolo »

I want to have runtime-per-user settings for enabling debug output for some categories.
Users should also be able to enable debug output relevant to the last entity they themselves placed in their current game session.
Debug messages should only be visible as chat messages to the player, who enabled them.
Messages don't need to be saved or synced to other users as those shouldn't be able to see them anyways.

Are messages output via Player.print only visible to that player (that is what i want)?

Can I call Player.print with a message only in the local instance of the mod which runs on that player's client without causing a desync if I set game_state = false in the PrintSettings given to Player.print?

Is there any way to find out which player runs the client, my code is physically executed on?
I want to use that to skip debug code for players who didn't enable it. The debug code is free of side effects apart from outputting debug messages. It doesn't have state worth saving or syncing.
robot256
Smart Inserter
Smart Inserter
Posts: 1061
Joined: Sun Mar 17, 2019 1:52 am
Contact:

Re: Player-specific debug output in local chat only

Post by robot256 »

1. Yes. Player.print will show just for that player.

2. No, all players clients run exactly the same code. The only way to output for certain players is for every client to check the list of player settings when every print is reached, and every client will run the player.print function for those players. Only the game rendering engine knows which clients' screens do draw which players' prints on.

3. I haven't used it before, but setting game_state=false probably just means the messages will not be visible after saving and reloading the game. It won't have any effect on desyncs.
Post Reply

Return to “Modding help”