Skip to content

Save a number on a kingdom

✅ Runtime verifiedWBML-0001 / WBML-0003PoliticalWorldAPI 1.14.0

Store an integer owned by your addon on a Kingdom, then read it back later.

This recipe assumes your Political World addon is already registered.

This snippet is not a complete mod by itself. Put it inside code that already has a real Kingdom kingdom, for example an event callback, action handler or another feature method. If you do not have a kingdom object yet, solve that first instead of inventing one.

const string AddonId = "Example.MyAddon";
const string Key = "reputation";
int current = PoliticalWorldAPI.GetKingdomInt(
kingdom,
AddonId,
Key,
0
);
bool written = PoliticalWorldAPI.SetKingdomInt(
kingdom,
AddonId,
Key,
current + 1
);

0 is the fallback returned when the value does not exist yet.

On the tested stack, kingdom addon int data survived:

immediate read
same-save reload
full WorldBox process restart

WBML also verified tested cross-world isolation for kingdom addon state.

Do not invent Political World’s internal save key yourself. Use the public GetKingdom* / SetKingdom* methods so addon ID and local key remain namespaced correctly.

The same public family exists for:

string
bool
float

Open the full addon-private kingdom data reference for exact behavior, storage notes and limits.