Expand description
Where the mod keeps its data (typed stores by scope, values kept with the world).
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.
Structs§
- Game
Data - A value kept for the install, whatever world (
<game>/yog-data/<mod>/game.ydata): written as it changes. - Player
Data - A value kept for each player of the world (
<world>/yog-data/<mod>/player/<uuid>.ydata, at its key). - 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.
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.