Skip to content

SetPlayerDiscovery

Puts a saved record back - the player’s game takes what it was not holding.

The record is a table as GetPlayerDiscovery returns it: the kinds it has are set, the kinds it lacks are left alone. It is taken at once and sent to the player’s game, which adds it to what it holds (the default): the game ends up with the saved discoveries and anything the player found since they joined. A restore made before the player is in the world waits for their spawn, in the order it was made.

With replace the record becomes exactly the one given and the player’s game forgets the kinds present first - for a mode that lets one game play several characters one after the other. The places cannot be replaced yet (the call skips them and returns false; unite them instead).

A block of another level than the server’s is kept in the record and not sent. A block the server cannot read - a format it does not know, text that is no block of that kind, or one over 48,000 bytes (64,000 characters of text) - is skipped, logged and the call returns false; the others are applied. No OnPlayerDiscoveryChange follows a set of the mode’s own; OnPlayerDiscoveryRestore follows when the game has answered.

SetPlayerDiscovery(pid, record [, replace])
Parameter Type
pid number the player
record table { level = , places = { format = , data = }, reading = { ... }, ui = { ... } } - the keys of GetPlayerDiscovery
replace boolean true makes the record exactly this one (the game forgets the kinds first); the default adds (optional)

boolean - false for a player who is not there or when a block was skipped

-- at the login: what the account saved, back to the player
db:Query("SELECT kind, format, data FROM discoveries WHERE player_id = @p", { p = accountId }, function(rows)
local record = {}
for _, row in ipairs(rows) do record[row.kind] = { format = row.format, data = row.data } end
SetPlayerDiscovery(pid, record)
end)

GetPlayerDiscovery · ForgetPlayerDiscovery · OnPlayerDiscoveryRestore · the Discovery - the map and the places a player found group of the index