OnPlayerDiscoveryChange
What the player discovered grew - the moment to save it.
The player’s game reported more of a kind than the record held - a place found, a book studied further -
or it reported a kind for the first time. That first whole report is also the sign that GetPlayerDiscovery now holds the game’s own
state: a mode that restores a character waits for it before it trusts what it reads. The record already holds the new state when this
runs. It runs at most once per kind every five seconds, with the rest waiting for the next window, so a walk across the map is a few
calls and not hundreds - read the record then and write only what differs from your last save.
A change still waiting for its window when the player leaves is told at once, just before OnPlayerDisconnect (and before a
reloaded or stopped mode’s own goodbye), so what a player found in their last seconds reaches a mode that saves what it is told.
It does not run for a set of the mode’s own (SetPlayerDiscovery).
Syntax
Section titled “Syntax”function OnPlayerDiscoveryChange(pid, kind, level) -- ...end| Parameter | Type | |
|---|---|---|
pid |
number | the player |
kind |
string | "places", "reading" or "ui" |
level |
string | the level of the record; empty for the global reading |
Returns
Section titled “Returns”nothing
Example
Section titled “Example”local dirty = {}function OnPlayerDiscoveryChange(pid, kind, level) dirty[pid] = dirty[pid] or {} dirty[pid][kind] = level -- written by the minute's timer and when the player leavesendSee also
Section titled “See also”GetPlayerDiscovery · IsPlayerDiscoveryKnown · SetDiscoveryTracking · the Discovery - the map and the places a player found group of the index
