mirror of
https://github.com/rollerozxa/voxelmanip-wiki
synced 2024-05-05 08:01:02 -07:00
18 lines
1.4 KiB
Markdown
18 lines
1.4 KiB
Markdown
PlayerMetaData is a per-world, per-player persistent string key-value store implementing all methods of [[MetaData]].
|
|
|
|
The granularity of the persisted snapshots is determined by the `map_save_interval` setting.
|
|
|
|
NOTE: Since PlayerMetaData is shared across all mods, it is considered good practice to prefix the keys set by your mod with your mod name plus a delimiter such as `:` to avoid collisions: The `score` field of a quest mod and a mobs mod f.E. might be called `fancy_quests:score` and `fancy_mobs:score` respectively.
|
|
|
|
## `player:get_meta()`
|
|
Used to obtain a mutable PlayerMetaData reference.
|
|
|
|
**Arguments:**
|
|
- `player`: A valid Player object
|
|
|
|
NOTE: Minetest requiring a valid `player` object means PlayerMetaData is only accessible while players are online; if you need per-player storage while players are offline, you can use ModStorage and save either a serialized table per-player or concatenate the keys of the per-player entries with the playername using a delimiter. Reusing the above example, `fancy_quests:score` might be stored as `<playername>:score` or as key-value pair with key `<playername>` and value `minetest.write_json{score = ...}` (or `minetest.serialize`) in ModStorage.
|
|
|
|
A [feature request](https://github.com/minetest/minetest/issues/6193) to make PlayerMetaData available for offline players exists;
|
|
|
|
**Returns:**
|
|
- `meta` - PlayerMetaData: Public & shared PlayerMetaData object for the player |