Persistent Storage
Saves small amounts of information on your device, so the Lens remembers it next time you open it. Use it for your settings, your progress or your own best score.
Asset stores, saved data, and the core building blocks behind bigger experiences.
Made with this blockInputs
storagePrefixstringPrefix prepended to all storage keys to avoid collisions between blocks in the same lens. Leave empty for no prefix.
Events
onStorageFullFired when persistent storage capacity is exceeded. Storage is automatically cleared when this happens.
onValueChangedFired after any value is written to storage via a put function.
Functions
getBoolbooleanGet a boolean value from persistent storage. Returns false if key does not exist.
putBoolvoidStore a boolean value persistently.
getIntintGet an integer value from persistent storage. Returns 0 if key does not exist.
putIntvoidStore an integer value persistently.
getFloatfloatGet a float value from persistent storage. Returns 0.0 if key does not exist.
putFloatvoidStore a float value persistently.
getStringstringGet a string value from persistent storage. Returns empty string if key does not exist. Use with JSON.stringify/JSON.parse for small objects only.
putStringvoidStore a string value persistently. Use JSON.stringify for small objects only; do not store large blobs, logs, images, or histories.
getColorObjectGet a vec4 color value from persistent storage. Returns vec4(0,0,0,0) if key does not exist.
putColorvoidStore a vec4 color value persistently.
hasKeybooleanCheck if a key exists in persistent storage.
removeKeyvoidRemove a specific key from persistent storage.
clearAllvoidRemove all stored data within this block's prefix namespace. If no prefix is set, clears all persistent storage.
getAllKeysObjectGet an array of all keys currently stored within this block's prefix namespace (keys returned without the prefix).
getStorageInfostringGet storage usage as a string in the format 'usedBytes/maxBytes'.
More in Utilities & Storage
- Canvas APIDraws the 2D graphics a game needs, such as a game board, a health bar or puzzle pieces. Ask for a 2D game or a sliding puzzle.
- Core3DBuilds the 3D scene for a game, with objects that move, collide and fall. Ask for a 3D game, for example bowling or a maze you roll a ball through.
- Model StoreHolds up to ten 3D models under names you pick, so other parts of the Lens can find each one. It shows nothing on the screen by itself.
- SortingAdds a game where you drag your friends into roles, for example BFF or Nemesis. Name two to six roles, or sort up to six pictures of your own instead.
- Sprite StoreHolds up to ten pictures that a 2D game uses, such as characters, cars or enemies. It also holds a photo or video you add yourself.
- Texture StoreHolds up to ten pictures under names you pick, so other parts of the Lens can find each one. It shows nothing on the screen by itself.
