Skip to content

Storage

jjppof edited this page Jul 17, 2023 · 4 revisions

Database file for engine global variables. See an example. This json file contains an object that contains user-defined variables that control the state of the game. Location: assets\dbs\storage_db.json.

Storage values (engine global variables) is a feature that allows controlling the states of your game. Whenever a map is changed, all the things that happened or were done in this map are reset, unless you hold some information that you want to be persistent. For example, if you open a chest and get an item, you want that chest to never be closed anymore, it means you want it to be opened and empty even if the hero change maps. For this, you need a storage value for holding this info. Let's suppose you have a chest in Madra, then you create a storage value called, for example, chest_in_madra of string type with value closed. Then you tie the chest sprite key to this variable, so whenever the map is mounted, the engine will look for the value of chest_in_madra to choose the corresponding sprite of the chest. So when you first interact with the chest, you set the value of chest_in_madra to open after getting the item, then every time you reach this map again, you'll see the chest open.

This file must contain an object. Example:

{
  "value_1_key_name": 123,
  "value_2_key_name": "abcd",
  "value_3_key_name": true,
  "value_4_key_name": {"x": 21, "y": 44},
}

Storage values can only be one of the types: string, boolean, number, or an object designating a position like this: {"x": 10, "y": 22.5}.

When using storage keys to build maps and events, you can reference a boolean variable prepending a not: on its name in order to retrieve the inverted value of it. Example: not:value_3_key_name.

Clone this wiki locally