Simulation API (BETA)
Drive authoritative game state through the Venus simulation system. Execute recipes, manage inventories and slots, and resolve dynamic fields directly from the platform.
⚠️ The Simulation API only runs inside the Venus host environment. Mock/test harnesses throw helpful errors when these methods are called locally.
Quick Start
import VenusAPI from '@series-inc/venus-sdk/api'
const state = await VenusAPI.simulation.getStateAsync()
const config = await VenusAPI.simulation.getConfigAsync()State Management
const personalState = await VenusAPI.simulation.getStateAsync()
const roomState = await VenusAPI.simulation.getStateAsync('room_123')
const config = await VenusAPI.simulation.getConfigAsync()
// { version, entities, recipes }getStateAsync returns inventory quantities, active recipe runs, and disabled recipes. Pass a roomId to inspect shared rooms; omit it for personal state.
Recipe Execution
// Server-authoritative action
const craft = await VenusAPI.simulation.executeRecipeAsync('craft_sword', {
materials: ['iron', 'wood'],
})
// Entity-scoped recipe
const upgrade = await VenusAPI.simulation.executeScopedRecipeAsync(
'upgrade_weapon',
'sword_123',
{ level: 5 },
)
// Track and collect runs
const runs = await VenusAPI.simulation.getActiveRunsAsync()
const collected = await VenusAPI.simulation.collectRecipeAsync(runs[0].id)
// Trigger chained behaviour
await VenusAPI.simulation.triggerRecipeChainAsync('battle_complete')Recipe Requirements & Availability
Use these helpers to pre-flight UI, disable unaffordable buttons, or build crafting browsers without guessing requirements.
Slot Management
Field Resolution & Metadata
Use field resolution for derived stats (power, crit chance, etc.) and metadata lookups for UI tooltips or detail panes.
Real-Time Subscriptions (BETA)
Update types: entity, activeRuns, snapshot.
Filters: subscribe by entities, tags, activeRuns, and/or roomId.
Only entities marked clientViewable: true in your simulation config are streamed to clients.
Best Practices
Batch operations with
executeBatchOperationsAsyncwhen you need atomic updates.Use simulation results as the source of truth—mirror UI state from responses rather than guessing.
Guard recipe calls with optimistic UI but reconcile against the final data returned by the host.
Last updated