Violet

Map

On this page

The Map object represents the current map. Provides access to entities such as mobs, NPCs, drops, portals, and map terrain data.

Always Validate

Call map:is_valid() before using any other methods. Map objects can become invalid at any time.

Functions

Validation & Basic Info

map:is_valid() -> boolean

Available on GMS and CW

Validates the object exists in the game world. Always call this first.

map:get_id() -> number

Available on GMS and CW

Returns the map ID.

Common Map IDs
Map IDName
100000000Henesys
101000000Ellinia
102000000Perion
103000000Kerning City
211000000El Nath
220000000Ludibrium

map:is_town() -> boolean

Available on GMS and CW

Returns true if the map is a town (safe zone).

map:get_burning_stage() -> number | nil

Available on GMS and CW

Returns the burning XP stage (0-10) or nil if unavailable.


Drops & Portals

Drop Object Structure

PropertyTypeDescription
idnumberDrop item ID (the item, shared by every drop of it)
unique_idnumberID of this one drop on the ground — stable for its lifetime, so use it to follow one exact drop across ticks
positiontableTable with x and y coordinates
typenumberType identifier
own_typenumberWhy it is yours: 0 = personal, 1 or 4 = your party's, anything else = free-for-all
owner_idnumberYour character ID or your party ID, per own_type
source_idnumbermob:get_unique_id() of the mob that dropped it

map:get_drops() -> table<drop>

Available on GMS and CW

Returns all drops available to the player (shared and personal).

The list is already filtered to drops you may loot, so own_type tells you why one is yours rather than whether it is — use it to skip free-for-all drops you would rather leave, or to take only your personal ones. source_id matches mob:get_unique_id(), so you can confirm a specific kill produced a drop before walking over to it.


Portal Object Structure

PropertyTypeDescription
namestringPortal name (e.g. "in00", "out00")
positiontableTable with x and y coordinates
typenumberPortal type identifier
target_map_idnumberDestination map ID
target_namestringName of the matching portal on the destination map

map:get_portals() -> table<portal>

Available on GMS and CW

Returns all portals on the map.


Entities

map:get_mobs() -> table<Mob>

Available on GMS and CW

Returns all mobs on the map. See Mob.

map:get_bosses() -> table<Mob>

Available on GMS and CW

Returns all boss mobs on the map. See Mob.

map:get_mob_count() -> number

Available on GMS and CW

Returns the number of alive mobs. More efficient than iterating get_mobs().

map:get_npcs() -> table<NPC>

Available on GMS and CW

Returns all NPCs on the map. See NPC.


Reactor Object Structure

Reactors (interactive map objects — switches, boxes, gathering nodes) currently in the field. Each entry is a plain table — not a bound object, so it has no methods.

PropertyTypeDescription
idnumberRuntime object ID, unique per spawn
template_idnumberWZ reactor template ID (Reactor.wz/<template_id>.img)
namestringReactor name
statenumberCurrent state index; advances as the reactor is hit/triggered
previous_statenumberState before the latest change
pendingbooleanAn interaction was sent and the game hasn't answered yet
eventnumber or nilIndex of the event behind the latest state change; nil while pending
flippedbooleanWhether the reactor is horizontally flipped
positiontableTable with x and y coordinates

map:get_reactors() -> table<reactor>

Available on GMS and CW

Returns all reactors currently in the field.

map:interact_reactor(id: number) -> boolean

Available on GMS and CW

Interacts with the reactor whose runtime id is given, as the interaction key does, such as the Afterlands' Solar Pulley. In GMS, a reactor that reacts to being clicked, such as the objects that summon the Root Abyss bosses, is clicked instead. The character must be close to it, and some quest objects only respond to the character they belong to. A reactor that reacts only to being touched, to a key press or to chat may not respond. Quest objects that are NPCs are talked to with npc:talk().

Returns: true when the interaction was sent. false when no reactor with that id is in the field, or when a reactor that is clicked can't be clicked yet: your character is dead or stands outside the area it can be clicked from. To see whether it worked, read the reactor again a moment later: its state changes (with previous_state set) or it disappears when the game accepts; it drops back or stays put when the game refuses.

lua
local map = core.object_manager.get_current_map()
for _, r in ipairs(map:get_reactors()) do
    if r.template_id == 8659064 then
        map:interact_reactor(r.id)
    end
end

map:get_clock() -> number | nil

Available on GMS and CW

Returns the seconds left on the map's countdown clock, or nil when the map has none.


Rune Object Structure

The active runestone on the field. Maps only ever have one rune at a time, so this is a single plain table (or nil) rather than a list — not a bound object, so it has no methods.

PropertyTypeDescription
positiontableTable with x and y coordinates
solvablebooleanfalse while the rune-solved cooldown is active (a rune was solved recently); true when it can be solved

map:get_rune() -> rune?

Available on GMS

Returns the active rune on the map, or nil if there is none.


Key Prompt Object Structure

Your character's timed key prompt, as in Tengu's fight in Mushroom Shrine. A plain table (or nil), not a bound object.

PropertyTypeDescription
openbooleantrue while the prompt is on screen waiting for your key; false while it is armed and has not appeared yet, and in on_key_prompt calls for an answered prompt
keystringThe key it expects: "space", "left", "right", "up" or "down"
key_codenumberThe same key as a virtual-key code, for core.input.press_key()
time_leftnumber or nilMilliseconds left to press the key, only while open
stepnumber0 for the prompt that starts an attack, then 1 and up for each key of that attack
mob_idnumberThe monster the prompt belongs to, such as 9400080 for Tengu

map:get_key_prompt() -> key_prompt?

Available on GMS

Returns your character's timed key prompt on this map, or nil when none is pending.

The prompt that starts an attack is armed first (open is false, step is 0). It appears partway through the monster's attack, but only if at that moment you are within 400 pixels of it, left or right, and able to move. A prompt takes the first of its five keys you press: the expected key passes it, any of the other four fails it, and so does running out of time. on_key_prompt reports each change.


Player Object Structure

Other players (remote characters) currently in the field. Each entry is a plain table — not a bound object, so it has no methods.

PropertyTypeDescription
idnumberCharacter ID
namestringCharacter name
positiontableTable with x and y coordinates

map:get_players() -> table<player>

Available on GMS and CW

Returns all other players currently in the field. Excludes your own character — see Local Player.


Terrain Data

Bounds Object Structure

PropertyTypeDescription
leftnumberLeft edge X coordinate
topnumberTop edge Y coordinate
rightnumberRight edge X coordinate
bottomnumberBottom edge Y coordinate
widthnumberright - left
heightnumberbottom - top
centertableTable with x and y coordinates

map:get_bounds() -> bounds?

Available on GMS and CW

Returns the map's boundary rectangle, or nil if the map's terrain isn't loaded yet (during a map transition, for example).

These are the same bounds that core.input.teleport_safe clamps against, so a position inside this rect is guaranteed not to be clamped.

center is the rect's midpoint — the position Kami teleports to when no mobs are alive. Note this is the boundary midpoint, which includes empty airspace: on tall maps it can sit well above the floor. Cross-reference map:get_footholds() if you need a point that's actually standing on ground.

lua
local map = core.object_manager.get_current_map()
local bounds = map and map:get_bounds()
if bounds then
    core.log(`map spans ${bounds.width} x ${bounds.height}`)
    core.input.teleport_safe(bounds.center.x, bounds.center.y, 0, 0)
end

Foothold Object Structure

PropertyTypeDescription
x1numberStarting X coordinate
y1numberStarting Y coordinate
x2numberEnding X coordinate
y2numberEnding Y coordinate

map:get_footholds() -> table<foothold>

Available on GMS and CW

Returns all footholds (platforms) on the map.


Ladder Object Structure

PropertyTypeDescription
xnumberX coordinate
y1numberTop Y coordinate
y2numberBottom Y coordinate

map:get_ladders() -> table<ladder>

Available on GMS and CW

Returns all ladders and ropes on the map.

Example

lua
-- Map and mob monitoring
function on_tick(stage)
    if stage ~= core.stage.FIELD then return end

    local map = core.object_manager.get_current_map()
    if not map or not map:is_valid() then return end

    -- Check map type
    if map:is_town() then
        core.log("In town - safe zone")
        return
    end

    -- Check burning field
    local burning = map:get_burning_stage()
    if burning and burning > 0 then
        core.log("Burning field stage: " .. burning)
    end

    -- Monitor mob count
    local mob_count = map:get_mob_count()
    if mob_count < 5 then
        core.log_warning("Low mob count: " .. mob_count)
    end

    -- List reactors in the field
    for _, reactor in ipairs(map:get_reactors()) do
        core.log(string.format(
            "reactor %d (%s) state=%d at (%d, %d)",
            reactor.template_id, reactor.name, reactor.state,
            reactor.position.x, reactor.position.y))
    end

    -- Check for a solvable rune
    local rune = map:get_rune()
    if rune and rune.solvable then
        core.log(string.format(
            "solvable rune at (%d, %d)",
            rune.position.x, rune.position.y))
    end
end