Skip to main content

World Stores

crowdypy.stores is the SDK-managed game state CrowdyJS calls the World Stores, running on CrowdyCPP's native world session. session.tick() applies every notification since the last tick to the stores natively. It then runs your actor's send loop and reaping, and fires your callbacks. Nothing a tick does waits on the network.

from crowdypy.codecs import f32, struct_codec, u16
from crowdypy.stores import create_world_session

pose = struct_codec({"x": f32(), "y": f32(), "z": f32(), "yaw": u16()})
session = create_world_session(game, app_id, actor_codec=pose, host=True, save=True)
session.self.join((0, 0, 0), {"x": 0.0, "y": 64.0, "z": 0.0, "yaw": 0})
session.actors.on_join(lambda actor: print("joined", actor.uuid, actor.value))
asyncio.create_task(session.run()) # tick 60 times a second

snapshot = session.actors.snapshot() # once a frame: every actor at once
states = pose.decode_many(snapshot.state_offsets, snapshot.state_data) # numpy, no loop

The stores​

StoreWhat it holds
session.selfyour actor: join, set or patch state, send-on-change with keyframes and heartbeats
session.actorseveryone else, with staleness, sample history, join, leave and update callbacks, native lanes filtered by state[offset] & mask == value, and snapshot() columns
session.chunksvoxels: real-time merge, optimistic set_voxel (optimistic=False applies an edit only when the server's echo arrives, 0.15.0), ensure_around and hydrate from the Game API, write-back with retries, and an on_missing world-generation hook. A 16×16×16 helper: an edit its one-byte grid cannot hold (a type outside 0-255, a position outside 0-15) is kept in overlay(chunk) (0.8.0)
session.errors, direct_inbox, channel_inbox, eventserrors attributed to your sends, inboxes and the event router
session.host, save, avatarhost election, save state and avatar state, run from the session's timers

Session events (0.8.0): session.on("voxel_update", ...) for every inbound voxel edit after session.chunks merged it, your own echo included (compare the uuid and sequence with your send's); session.on("generic_spatial", ...) for message type 140; and session.on("channel_audio", ...) for channel voice.

Codecs​

json_codec, raw_codec and text_codec cover most states. struct_codec declares a fixed binary layout and decodes a whole lane's states in one call, into a numpy structured array.

The Game Kit​

client.kit(app_id) is the Game Kit: typed clients for the ck-exec starter hubs (kit.world, kit.matchmaking, kit.sessions, kit.npcs, kit.topology), the client conventions (kit.spectate, kit.emotes, kit.shards) and the social helpers (parties, guilds, chat). Beside the World Stores, decode_kit_actor_state and kit_actor_lanes read the mobs, NPCs, pets and balls hubs show; the engine pose format with engine_lanes(), the event parsers and run_optimistic_action are there too (CrowdyPy 0.12.0).