Ren'Py New Game carryover? Use default for per-play state
Fix New Game carryover bugs by separating Ren'Py init constants from saveable per-play state.
08 Jun 2026, 23:22 UTC

The bug: your New Game remembers the last one
You create an inventory list at the top of your script:
define inventory = []
During play, the player picks up a key:
$ inventory.append('key')
You return to the main menu and start a new game. The inventory still contains 'key.' Affection flags, quest progress, and counters can leak the same way.
The cause is not a save-file bug. It is a lifetime issue. define runs once when Ren'Py initializes the script, before the main menu appears. A list or dictionary created there lives for the entire session. Mutating it mutates the same object for every game until you restart the application.
The useful takeaway: declare mutable per-play state with default, not define, and copy constants before mutating them.
The fix: default resets per game, define stays constant
Use define for values that should never change during play: characters, styles, configuration, and lookup tables. Use default for mutable state that belongs to a single playthrough. Ren'Py resets default variables when a player chooses New Game, and it includes them in saves and rollback.
| Keyword | Runs | Resets on New Game | Saved | Best for |
|---|---|---|---|---|
define | Once at init | No | No | Characters, styles, config, constants |
default | Once per new game | Yes | Yes | Inventory, flags, affection, counters |
Worked example: starting items without cross-game leaks
Keep the item template in define, then copy it into a default list when a new game begins:
define STARTING_ITEMS = ['map', 'lantern']
default inventory = []
default trust = 0
label start:
"A new journey begins."
$ inventory = list(STARTING_ITEMS)
$ trust = 0
menu:
"Check your pack:":
"You have [inventory]."
"Talk to the guard:":
$ trust += 1
"The guard seems friendlier."
list(STARTING_ITEMS) creates a fresh copy. If you instead wrote $ inventory = STARTING_ITEMS, both names would point to the same list, and appending loot would permanently alter your constant.
On New Game, Ren'Py clears inventory and trust, then label start repopulates them. On load, Ren'Py restores the saved values and jumps to the saved label, so label start does not overwrite a player's progress.
Verification: prove the reset works
- Create a minimal Ren'Py project with the example above.
- Launch the project from the Ren'Py SDK launcher or project directory. No special permissions are required beyond write access to the project folder.
- Play to the guard, add an item to
inventory, and save. - Return to the main menu and choose New Game.
- Print both variables in a test label or use the developer console to inspect them.
inventoryshould show only the starting items;trustshould be 0. If either shows the previous session's values, the variable was likely declared withdefineor mutated in place. - Make a save after changing
trust, roll back before the change, then load the save. The loaded value should match the saved timeline, confirming rollback consistency.
Run in developer mode to see tracebacks and use the script reload command while iterating. If a screen changes state, prefer Ren'Py actions over bare $ assignments so rollback and save/load remain consistent.
Limitation: saved state has a cost
Because default variables participate in saves and rollback, large lists or dictionaries that change every frame can bloat save files and increase rollback memory. Do not keep per-frame animation data or temporary UI state in default. Copy constants on demand and keep hot data in local variables or screen-specific state instead.
Compare save size with a large default list versus a constant copied on demand if you target memory-constrained platforms. There is no universal threshold; measure against your actual script.
Closing
Treat define as the place for permanent furniture and default as the player's current backpack. Copy constants into default containers before changing them, verify with a New Game test, and keep large mutable collections out of saved state. Your next New Game will actually start empty.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.