Skip to main content
Scripts often need to remember things — how many enemies the player has defeated, whether a secret door has been opened, or a score multiplier set in an earlier level. RollingQuest gives you two storage layers to cover both use cases: level-local data that lives for the duration of the current level session, and campaign-global data that persists across all levels in a campaign.

Storage Layers at a Glance

Both are accessed from any script in the level without importing anything.
These two storage types have different APIs. localData on entities and Level uses direct table indexing. campaignGlobalData uses typed method calls. Make sure to use the correct style for each.

Level-Local Data: localData

Level.localData and every entity’s localData (Block, Side, Item, Enemy, Ball, Decoration) are instances that behave like a Lua table. You read and write values using standard Lua bracket notation.
localData works like a table but does not support pairs() iteration. You can read/write individual keys, but you cannot loop over all keys.

Reading and Writing

Deleting Keys

Set a key to nil to remove it:

Cross-Script Sharing

Because Level.localData is shared across all scripts in the level, any script can read what another script wrote:
1

Script A writes a value

2

Script B reads the value

Saving and Restoring State

localData values are preserved across save/load within the same level session. If the player saves mid-level and loads later, all localData values remain intact.

Campaign-Global Data: campaignGlobalData

Level.campaignGlobalData persists for the lifetime of the entire campaign. Any value you write here in level 1 is still readable in level 5. Use it to track campaign-wide progress, unlock states, or accumulated scores.
Level.campaignGlobalData is only meaningful when the level is played inside a campaign. If the level runs standalone, the data still works but will not persist between separate play sessions.

Reading and Writing with Typed Methods

campaignGlobalData uses explicit typed methods — not table indexing.

Checking and Deleting Keys

Campaign Example


Quick Reference

localData (table indexing)

campaignGlobalData (method calls)

Prefix your keys with a unique identifier (like the entity name or script role) to avoid accidental collisions when multiple scripts use the same storage instance.