on_pre_player_disconnected event

Post Reply
User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

on_pre_player_disconnected event

Post by Adil »

As notified here viewtopic.php?f=23&t=30418, on_player_left_game is rather useless event, as the only thing you can do is to read player index and print bye-bye message only the other players will see.
However, whenever a mod does need to know that player is not in game anymore, it is often due to the fact the mod alters some player related information in some way, be it temporary boosts to player character, or change of the character altogether. In such cases, modders might have a desire to restore the normal state of player before he disappears.
And without such event, the only workaround for the issue is to periodically memorize all relevant info, so that it could be used after the player in off. For the mods that temporarily change the player's character, like avatars or commandncontrol, that means that all inventories, must be stored every so often, and if player is disconnected during the out of body experience, the mod must perform all the actions the game usually does to his body.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

User avatar
DedlySpyder
Filter Inserter
Filter Inserter
Posts: 253
Joined: Fri Jun 20, 2014 11:42 am
Contact:

Re: on_pre_player_disconnected event

Post by DedlySpyder »

+1

Currently, I just hope no one kills the original character that gets left behind.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13247
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: on_pre_player_disconnected event

Post by Rseding91 »

This seems like the wrong answer to the problem. Although... I don't know what the correct answer is at this point.
If you want to get ahold of me I'm almost always on Discord.

User avatar
Adil
Filter Inserter
Filter Inserter
Posts: 945
Joined: Fri Aug 15, 2014 8:36 pm
Contact:

Re: on_pre_player_disconnected event

Post by Adil »

Well, after a bit of pondering I've come to a thought that it is mostly possible to keep up-to-date copy of character in lua with events less frequent than on_tick, however the implementation would be complex enough to be called a mod on itself.
The problem is, if reference to a disappeared character was used by some mod, then there's no way to update that reference to point to a new copy of the character without the mod itself being written to provide means of alteration of its data.

Keeping the disconnected player object around a single tick longer and remembering the alterations mods perform on it during that period and pushing them to client when it reconnects to server seem to me like a conceptually simplest solution.
I do mods. Modding wiki is friend, it teaches how to mod. Api docs is friend too...
I also update mods, some of them even work.
Recently I did a mod tutorial.

Post Reply

Return to “Implemented mod requests”