Expand description
Where the mod keeps its data — typed values in stores scoped the way web
storage is (yog-storage), opened for this mod in the right folder:
ⓘ
use yog_api::storage;
storage::game().set("theme", &theme); // the install, whatever world
if let Some(world) = storage::world() { // this world, saved with it
world.update("visits", |n: &mut u32| *n += 1);
}
storage::session().set("last_screen", &screen); // while the game runsOr a value kept for the mod, loaded when first used and saved with the
world (WorldData, PlayerData, GameData):
ⓘ
static LABELS: WorldData<Vec<Label>> = WorldData::new("labels");
LABELS.with_mut(|labels| labels.push(label));What’s kept with the world is written as the world is saved
(server::life::Saving: an autosave, /save-all, the server stopping),
so it’s saved with the world it belongs to.
A value kept for each owner — PlayerData, BlockData (gone as
it’s broken) — is in the owner’s store, at the keys a Yog Script
object’s saved members have; one kept on an entity (EntityData) or
a stack (ItemData) is the game’s, travelling with it.
Structs§
- Block
Data - A value kept for each block, by dimension and place (its chunk’s
store, as
<x>_<y>_<z>.<key>within the chunk): removed as it’s broken or another is put there. - Entity
Data - A value kept on each entity, by uuid, at its key (the mod’s own:
<mod>:<key>); its default where the entity has none yet. - Game
Data - A value kept for the install, whatever world (
<game>/yog-data/<mod>/game.ydata): written as it changes. - Item
Data - A value kept in the data of the stack a player holds, at its key (the
mod’s own:
<mod>:<key>); its default where the stack has none yet. - Player
Data - A value kept for each player of the world, by uuid
(
<world>/yog-data/<mod>/player/<uuid>.ydata, at its key); synced, to that player alone. - Store
- A mod’s store of a scope: values of any
Schematype by key, kept in memory and written when it’s flushed. Handles to one store share it. - World
Data - A value kept with the world (
<world>/yog-data/<mod>/world.ydata, at its key): its default where there’s none yet; with no world open (a client of another’s server) it’s kept in memory only. Synced, to everyone.
Enums§
- Scope
- What a store belongs to — under a root: the game’s folder for
Scope::Game, the world’s for the rest (see the crate docs).
Functions§
- chunk
- This mod’s store for chunk
cx,czof dimensiondimin the open world. - close_
under - Writes and closes every store under
root(the world closed: the next one opened reads its own). - dimension
- This mod’s store for dimension
dimof the open world. - entity
- This mod’s store for entity
uuidin the open world. - flush_
all - Writes every store changed since it was last written; the first failure.
- game
- This mod’s store for the install, whatever world.
- player
- This mod’s store for player
uuidin the open world. - session
- This mod’s session store: kept while the game runs, never written.
- world
- This mod’s store for the open world.