Spielerando

World State Flags

World state flags are the game's memory of what has happened: the bridge is down, the smith has been met, three keys are found. Doors, conversations and cutscenes ask this one list instead of keeping private notes. Names come from a fixed list, so a typing mistake is caught and never becomes a second, silent flag.

Also called: Story flags, Game flags, World variables, Quest flags.

A round-eared otter in a green coat pulls a brass lever as a drawbridge swings down, while on a clothesline above, one more paper lantern flares to life among the dark ones.
Quillmoth Crossing, an invented paper-craft adventure. Invented game, image generated with AI.

Paste this to your AI

Copy it into Claude, Cursor or ChatGPT. It already has good values and the usual mistakes in it.

Add "World State Flags" to my game.

What it should do: One shared memory lets any part of the game react to what the player did, without the parts knowing about each other, so choices and progress can change the world in many places at once.

Use these starting values:
- historyLimit: 20 changes

Watch out for these common mistakes:
- A typing mistake becomes a second flag: Tell your AI: keep one list of all flag names, refuse any name that is not on it, and check every door and conversation against that list when the game loads.
- A condition with an empty list: Tell your AI: an empty list asks for nothing and always passes.
- A counter goes below zero or past its top: Tell your AI: give every counter a top, keep it between zero and the top, and only accept whole numbers.
- An old save has names the game no longer has: Tell your AI: when loading a save, drop every name the game no longer lists and cut each counter to its current top.
- Setting a flag twice looks like news: Tell your AI: report whether a flag really changed, and only react to real changes.

Do not change anything else in the game. Do not claim anything without proof: model what it takes, and show me what your solution rests on and how I can see that it works. If you cannot show something, say you do not know. When you are done, tell me in plain words how to try it.

Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP

What it does

One shared memory lets any part of the game react to what the player did, without the parts knowing about each other, so choices and progress can change the world in many places at once.

Good starting values

ValueStart withWhat it changes
historyLimit20 changesHow many recent changes are remembered. More helps when hunting a strange bug, but every saved game carries them.

What usually goes wrong

A typing mistake becomes a second flag

The story sets "bridge-dwon" and the door waits for "bridge-down". Nothing complains, the door never opens, and nobody sees why.

Fix: Tell your AI: keep one list of all flag names, refuse any name that is not on it, and check every door and conversation against that list when the game loads.

A condition with an empty list

A line of talk says "any of these flags" with no flags in the list. A careless check says no, and the line can never be said.

Fix: Tell your AI: an empty list asks for nothing and always passes.

A counter goes below zero or past its top

The player hands in four keys but only three were found, and the counter shows minus one. Or a bonus adds ten moths to a jar that holds ten, and a later check for exactly ten fails.

Fix: Tell your AI: give every counter a top, keep it between zero and the top, and only accept whole numbers.

An old save has names the game no longer has

An update renames or removes a flag. Old saves still carry it, and the world is a little wrong for the player who loads one.

Fix: Tell your AI: when loading a save, drop every name the game no longer lists and cut each counter to its current top.

Setting a flag twice looks like news

Every time the player walks past the smith, the "met the smith" flag is set again and the game shows a new-entry sign or plays the jingle again.

Fix: Tell your AI: report whether a flag really changed, and only react to real changes.

How to check it works

Works well with

Common questions

what are story flags in a game

Named yes or no notes the game keeps about what has happened, such as the bridge being down. Any door, conversation or cutscene can look at them, so one deed can change the world in many places.

how do i stop typos in flag names

Keep one list of every allowed name and refuse any other name. Then check every door and conversation against that list when the game loads, so a mistyped name shows up before a player meets it.

what do i tell my ai to add story flags

Paste this: Add world state flags. Keep one list of allowed flag and counter names, refuse unknown names, keep counters between zero and a top value, report whether a change really happened, and drop unknown names when loading an old save.

should a flag be a number or a yes or no

Use a yes or no for things that either happened or did not. Use a counter, with a top value, when you need to count, such as keys found. A counter with a top is easier to check than a pile of separate flags.

Where it comes from

We could not find a reliable origin for this one yet.

Where this mechanic comes from has not been researched yet.

Games are named only as references. Names and marks belong to their owners, and nothing here is endorsed by them.

What was checked

This is what separates the blueprint from a catalogue entry: the values on this page come from code that runs.

Your AI gets the code

Tested example code comes through the Spielerando connection, so your AI can use it right away. How to connect it