Skip to content
AEOWUN
Docs Menu

Maps

Store values by key.

Add and read values

const values = {}
values["name"] = "Ghost"
values[1] = "First"
debug.log(values["name"])

String and numeric keys are different. values[1] and values["1"] are separate entries.

Missing keys

Reading a missing key returns nil.

if values["health"] == nil {
    values["health"] = 100
}

Remove a key

Assign nil to remove an entry.

values["name"] = nil

Maps use indexing and assignment. There is no separate map namespace.

Shared state

Keep game state in a map when it needs named fields. To save supported values between game sessions, see Save data.

[BETA] marks features newer than the current public release. Current release: 0.8.0.