Skip to main content

Maps

Maps are another type of Variable that allow you to map names (keys) to items (values). Just like Lists, these items can be anything: text, objects like NPCs or Items, Lists, and even other Maps.

You can view and learn more about all Map actions here.

tip

A common use of Maps is to store data used in your script such as NPC information (names, locations, ids, etc.).

This type of data can easily be stored as JSON and loaded into a Map using one of the JSON Map actions.

Usage

Adding Values

You can add simple values to a Map using the Set key to a value action.

Adding values to a map

As shown in the Variable Panel after those actions add the key value pairs, the "Map" variable now has two keys (Some Number and Some Text) with their respective values.

Using Values

Once your Map has key value pairs, you can retrieve those values with either an action like Set variable to key's value or the map(Map.Key) Field Command.

If you added a Log action and logged 'Some Text' in our map is: map(Map.Some Text), it would replace map(Map.Some Text) with the value we put in the Map above (Hello, World! in this case).

Accessing Maps inside of Maps

You can easily add and use values from Maps that are stored inside of other Maps by adding a . between the map names.

For example, if you have a map called Data which contained another Map for the key Inner Map, you could use Data.Inner Map as the Map name in any action or Field Command that asks for a Map name.