Solarus solarus-0.9.1
Map syntax specification

A map is composed of the following information:

  • a size in pixels,
  • a tileset (the graphical skin used to draw its tiles),
  • a background music,
  • the world it belongs to (outside world, inside world or a dungeon),
  • the floor it belongs to (if any),
  • its location relative to the outside world (or relative to the floor for a dungeon),
  • the savegame variable that stores the number of small keys for this map (small keys of different dungeons are not compatible),
  • all entities of the map (tiles, enemies, chests, pots, switches, etc.).

All of this is stored in a file maps/mapXXXX.dat where XXXX is the id of the map (an integer on four digits). This page describes the syntax of this file. Another file maps/mapXXXX.lua contains the script of the map, i.e. the dynamic events that occur on the map. See the Lua scripting API specification to know how a map script can interact with the game.

Most of the information listed above is given in the first line of maps/mapXXXX.dat. The first line has the following syntax:

width	height	world	floor	x	y	small_keys_variable	tileset_id	music_id

width and height give the size of the map in pixels.

world indicates the world the map belongs to:

  • 0: the map is in the outside world
  • -1: the map is in the inside world, but not a dungeon
  • 1 to 20: the map is in the dungeon whose number is specified When the player shows the minimap screen, this world property is used to determine what map is shown and how the hero's position on the minimap is calculated.

floor indicates in what floor the map is located, between -16 and 15. The floor is displayed on the screen during a few seconds when the player gets in it. If the map is not on a floor (like all maps of the outside world and most of non-dungeon maps), the value is -100. There is also a special value, -99, that corresponds to an unknown floor: the '?' symbol will be displayed instead of the floor when arriving there.

x and y are the coordinates of the map in pixels, relative to its context. If the map is in a dungeon, they are the coordinates of the top-left corner of the map relative to the whole floor (in big dungeons, a floor can have several maps). If the map is in the outside world, they are the coordinates of the top-left corner of the map relative to the whole outside world. If the map is in the inside world (but not a dungeon), they are the coordinates of the place on the outside world (this allows to show the hero's location on the outside world minimap when the player shows the minimap screen).

small_keys_variable is the index of the variable that stores in the savegame the number of small keys of this map. This value is the same for all the map of the same dungeon. A value of -1 means that there is no small key counter in this map (this is the case most of the time for non-dungeon maps).

tileset_id is the index of the tileset used to draw the map.

music_id is the file name of the background music to play (relative to the musics directory) or none to play no music on the map, or same to let the previous music continue.

Then, each line of the file describes an entity of the map. Here is the general syntax of the line of en entity (elements in square brackets are present only for some types of entities):

entity_type	layer	x	y	[width]	[height]	[entity_name]	[direction]	[subtype]	[specific_info…]

entity_type indicates what type of entity it is (according to the enumeration EntityType): a tile, an enemy, a chest, a teletransporter, etc.

The following three values are common to all types of entities:

layer is the layer where the entity is placed:

  • 0 (low layer): the entity is always displayed below the hero (like most of the tiles)
  • 1 (intermediate layer): the hero may be above or below the entity (e.g. a platform)
  • 2 (high layer): the entity is always above the hero (e.g. a tree or the upper part of doors)

x and y are the coordinates in pixels where the entity is placed relative to the map. More precisely, its origin point is placed on this point.

Then, width and height are the size of the entity in pixels (only for entities with variable size). The width and height are always multiples of 8 pixels.

If the entity can be identified, entity_name is its name. Some types of entities have a name which allows to identify uniquely an instance (an enemy, a switch) at runtime, typically by the script of the map. For instance, is you want to make a switch open a door, your script needs to refer to this particular switch and this particular door. The name is chosen by the creator of the map and cannot start with the character '_' or have whitespaces.

If the entity has a direction property, it is given in the value direction, which is an integer number. Some types of entities have a direction property (enemies, NPCs, conveyor belts…) while other do not (tiles, pots, teletransporters, chests…).

Then, subtype indicates the subtype of this entity (only for some types of entity).

The remaining part of the line (specific_info) may contain specific information depending on the type of entity.

For now, the following types of entities are available when creating a map:

  • tile (0): a tile of the map, with a pattern picked from the tileset
  • destination point (1): a possible destination for teletransporters
  • teletransporter (2): when walking there, the hero is transported to a destination point (possibly on another map)
  • pickable item (3): an treasure placed on the ground and that the hero can pick up: a rupee, a heart, etc.
  • destructible item (4): an item the hero may cut or lift: a pot, a bush, a stone, some grass, etc, and that may hide a treasure
  • chest (5): a chest (small or big) with a treasure inside
  • jump sensor (6): a sensor that makes the hero jump into a direction
  • enemy (7): an enemy (that may carry a treasure)
  • NPC (8): an entity that the hero can interact with by pressing the action key or using an inventory item in front of it (not necessarily a person)
  • block (9): a block or a statue that the hero can push or pull
  • dynamic tile (10): a special tile with the ability to be enabled or disabled (usual tiles cannot be disabled)
  • switch (11): a switch that the hero may enable
  • custom obstacle (12): an invisible obstacle to stop make sure some kinds or entities cannot pass
  • sensor (13): an invisible sensor that triggers something when the hero walks on it
  • crystal (14): a switch that lowers or raises some blocks in the ground
  • crystal block (15): the blocks controlled by crystals
  • shop item (16): a treasure that the hero can buy in a shop
  • conveyor belt (17): when walking there, the hero is moved into a direction
  • door (18): a door to open with a key or another action
  • stairs (19): stairs between two maps or towards a platform inside a single map

We detail below the exact syntax of each entity type.

Tile (0)

A tile has no direction and no name. This means that you cannot modify, add or remove a tile at runtime: use dynamic tiles if you need to. A tile has a size: you can indeed repeat its pattern several times instead of placing many times the same tile on the map.

Syntax of a tile:

0	layer	x	y	width	height	tile_pattern_id

tile_pattern_id is the index of the tile pattern in the tileset, as defined by the tileset file.

Note that tiles in the same layer can overlap. They are placed on the map in the same order as they appear in the map file. In other words, if two tiles overlap, the one that appears last in the file is placed above.

Destination point (1)

A destination point is a point of the map which is used as the destination of a teletransporter. A destination point has a direction between 0 and 3: this is the direction that the hero takes when he comes on the destination point. A value of -1 means that his direction should not change. A destination point also has a name (used by the teletransporters). Its size is fixed (16*16 which is the size of the hero).

Syntax of a destination point:

1	layer	x	y	entity_name	direction	subtype

Subtypes of destination points:

  • 0: usual, non-visible destination point
  • 1: visible destination point, displayed with an image of teletransporter destination

Teletransporter (2)

A teletransporter is a sensor that sends the hero to a destination point on the same map or on another map. You can specify its size and a name.

Syntax of a teletransporter:

2	layer	x	y	width	height	entity_name	subtype	transition	destination_map	destination_point

Subtypes of teletransporters:

  • 0: invisible teletransporter (for usual changes of maps)
  • 1: visible teletransporter (that displays a sprite of teletransporter)

transition is a number that indicates the type of transition played when taking the teletransporter, according to the enumeration Transition.

destination_map is the id of the map where the player is sent (possibly the same one).

destination_point is the name of the destination point where the player is placed on the destination map. Two special values are also supported: _side and _same. _side can be used for a teletransporter placed on the side of the original map, and that sends the hero on the corresponding side of the destination map. The new coordinates are automatically calculated. _same means that the coordinates of the hero remain the same as in the previous map. This can be used when falling into a hole. No destination point entity is needed when the value is _side or _same.

Pickable item (3)

A pickable item is a treasure directly placed on the floor. The hero can pick it.

Syntax of a pickable item:

3	layer	x	y	treasure_name	treasure_variant	treasure_savegame_variable

treasure_name, treasure_variant and treasure_savegame_variable define the treasure to give to the player when he picks the item. treasure_name must be an item declared in the file items.dat and treasure_variant is an integer that must be a valid variant for this item.

treasure_savegame_variable is used for items that can be obtained only once and need to be saved (e.g. a key). It is the index of the variable that stores the pickable item's state in the savegame. A value of -1 indicates that the item is not saved.

Destructible item (4)

Destructible items are the ones that can hide pickable items and that the hero can lift or cut (or both).

4	layer	x	y	subtype	treasure_name	treasure_variant	treasure_savegame_variable

Subtypes of destructible items:

  • 0: a pot
  • 1: a skull
  • 2: a bush
  • 3: white stone
  • 4: black stone
  • 5: grass
  • 6: bomb flower

treasure_name, treasure_variant and treasure_savegame_variable define the pickable item hidden under the destructible item. See the previous section for their meaning. treasure_name can be "_random" or "_none".

Chest (5)

A chest contains a treasure. The hero can open it to obtain the treasure.

Syntax of a chest:

5	layer	x	y	entity_name	is_big_chest	treasure_name	treasure_variant	treasure_savegame_variable

is_big_chest is a boolean (0 ou 1) that indicates whether this is a big chest (1) or a normal chest (0).

treasure_name is a string identifying the item placed in the chest, according to the file items.dat. A value of "_none" means that the chest is empty or controlled by the script of the map.

treasure_variant is an integer that corresponds to the possession state of the item. Most items have only one variant and for them, this value is set to 1.

treasure_savegame_variable is the index of the savegame variable that stores the state of this chest. A value of -1 means that the chest is not saved.

Jumper (6)

A jumper is an invisible sensor that makes the hero jump a number of pixels into a direction, with a direction that depends on the shape of the sensor. During the jump, the hero cannot be controlled by the player and he can traverse obstacles.

Syntax of a jumper:

6	layer	x	y	width	height	entity_name	direction	jump_length

The direction property of the jumper (0 to 7) determines both the shape of the sensor and the direction of the jump.

The size is cutomizable in order to allow jumps from different places along the cliff. For diagonal jumpers, the size of the bounding box is always square.

jump_length is the length of the jump in pixels. Make sure the length cannot send the hero into a wall.

Enemy (7)

Syntax of an enemy:

7	layer	x	y	entity_name	direction	breed	rank	savegame_variable	treasure_name	treasure_variant	treasure_savegame_variable

There are various kind of enemies. A kind of enemy is called its breed. Each breed is implemented as a Lua script.

breed is the name of the breed of the enemy. It must correspond to a Lua script located in the enemies directory.

rank indicates whether the enemy is considered as a normal enemy (0), a miniboss (1) or a boss (2). It has an influence on the minimap of dungeons (the boss of a dungeon is represented on the minimap) and on the dying animation of the enemy.

savegame_variable is used for enemies that can be killed only once in the game. It indicates the index of the boolean variable that stores the state of the enemy in the savegame. A value of -1 means that the enemy is not saved.

treasure_name, treasure_variant and treasure_savegame_variable define the pickable item dropped by this enemy when it is killed, (see the section about pickable items above). treasure_name can be "_random" or "_none".

NPC (8)

An NPC is an entity that the hero can interact with by pressing the action key or using an inventory item just in front of it. The NPC is not necessarily a person, it can be a more general, solid interactive entity. The hero may talk to it, read what it shows or do another action. Most of the time, the action consists in starting a dialog, but you can define a custom action with a script.

8	layer	x	y	entity_name	direction	subtype	sprite_name	behavior

Subtypes of NPCs:

  • 0: generalized NPC (a solid interactive entity)
  • 1: a usual NPC (a sprite is required, with four directions and the animations "stopped" and possibly "walking")

direction has a different meaning depending on the subtype of NPC. For a usual NPC, it indicates the initial direction of its sprite (0 to 4) For a generalized NPC, it indicates the direction where the interaction is possible (0 to 4, or -1 to allow the interaction in any direction). For example, if the direction is 3, the interaction will be started only if the hero touches the south face of the entity.

sprite_name is the name of the animation set of the sprite to display with this entity (or _none to make the entity invisible)

behavior describes what happens when the player presses the action key near this entity. There are three possible options:

  • dialog::XXX: starts the dialog with id XXX
  • map: calls the map script (event_hero_interaction)
  • item::XXX calls the script of the item XXX (event_hero_interaction)

Block (9)

Syntax of a block:

9	layer	x	y	entity_name	direction	sprite_name	pushable	pullable	maximum_moves

sprite_name is the animation set id of the sprite to display for this block.

pushable (0 or 1) indicates whether the block can be pushed.

pullable (0 or 1) indicates whether the block can be pulled.

maximum_moves indicates what happens when the hero tries to push or pull the block:

  • 0: cannot be moved
  • 1: can be moved only once
  • 2: can be moved without limit

The direction of the block indicates in which direction (0 to 3) it can be pushed or pulled. A value of -1 means that it can be pushed or pulled in any direction.

Dynamic tile (10)

A dynamic tile is a tile with the specialy ability to be enabled or disabled by the script of the map. Dynamic tiles need to be separated from normal tiles because normal tiles are optimized for the detection of collisions.

Syntax of a dynamic tile:

10	layer	x	y	width	height	entity_name	tile_pattern_id	enabled_at_start

tile_id is the id of the tile pattern from the tileset, like in the case of normal tiles. enabled_at_start is a boolean value (0 ou 1) that indictaes whether the tile is enabled when the map starts. When the tile is disabled, it is invisible and can be traversed.

Switch (11)

When the hero triggers a switch, the map script is called. Some switches can only be activated by a block. Some switches are inactivated when the hero leaves them. The size of a switch is always 16*16 pixels. Its sprite depends on its subtype.

Syntax of a switch:

11	layer	x	y	entity_name	subtype	needs_block	inactivate_when_leaving

Subtypes of switches:

  • 0: pressure plate, invisible
  • 1: pressure plate, visible
  • 2: target for an arrow
  • 3: solid switch to activate with the sword or other weapons

needs_block is a boolean value indicating that a switch of subtype pressure plate needs a block to be activated (nothing happens when the hero walks on it).

inactivate_when_leaving is a boolean value indicating that when the hero (or the block) leaves the switch, the switch is inactivated.

Custom obstacle (12)

A custom obstacle is an invisible entity of variable size where some types of moving entities cannot pass.

Syntax of a custom obstacle:

12	layer	x	y	width	height	entity_name	stops_hero    stops_enemies	stops_npcs	stops_blocks

The last four values are boolean values that indicate whether this custom obstacle is an obstacle for the hero, the enemies, the non-playing characters and the blocks, respectively.

Sensor (13)

A sensor is an invisible place of variable size that triggers something when the player walks on it. Unlike a switch, a sensor cannot be avoided by a jump. If you want the hero to be detected for sure when he enters somewhere, use a sensor rather than an invisible switch.

Syntax of a sensor:

13	layer	x	y	width	height	entity_name	subtype

Subtypes of sensors:

  • 0: custom (the script is called)
  • 1: change the layer (the hero takes the layer of the sensor)
  • 2: place to get back when the hero falls into a hole or some other bad ground

Crystal (14)

When a crystal is activated, some colored blocks in the ground are lowered or raised.

Syntax of a crystal:

14	layer	x	y

Crystal block (15)

These are the blocks controlled by a crystal. Such blocks can have two colors. When they are lowered in the ground, they can be traversed. When they are raised, they are obstacle. Activating a crystal inverts their configuration.

15	layer	x	y	width	height	subtype

Subtypes of crystal blocks:

  • 0: orange blocks (initially lowered)
  • 1: blue blocks (initially raised)

Shop item (16)

A shop item is a treasure one can buy in a shop in exchange for money.

Syntax of a shop item:

16	layer	x	y	entity_name	treasure_name	treasure_variant	treasure_savegame_variable	price	dialog_id

treasure_name, treasure_variant and treasure_savegame_variable define the treasure to give to the player when he buys the item (see Treasure.h). The behavior of these values is identical to the case of chests. When loading the map, is the savegame indicates that the player has already bought the item, then the item is not created. When the player buys the item, it is removed from the map. If the treasure is not saved, the item can be bought several times and is not removed from the map.

price is the number of rupees to pay to buy the item.

dialog_id is the id of the dialog to show when the player looks at the item. The dialog describes the item. It is automatically followed by a dialog that asks to the player if he wants to buy the item.

Conveyor belt (17)

When the hero walks on a conveyor belt, he is moved automatically in the direction of the conveyor belt. The player does not control his movements anymore.

17	layer	x	y	width	height	direction

direction is one of the 8 directions (0 to 7).

Door (18)

Syntax of a door:

18	layer	x	y	entity_name	direction	subtype	savegame_variable

Subtypes of doors:

  • 0 (closed): usual closed door
  • 1 (small key): a small key is required to open the door
  • 2 (small key block): a block to open with a small key (this does not look like a door)
  • 3 (big key): the big key is required to open the door (only in a dungeon)
  • 4 (boss key): the boss key is required to open the door (only in a dungeon)
  • 5 (weak): a weak wall, to blow with an explosion
  • 6 (very weak): same as weak but more visible
  • 7: obsolete, illegal subtype
  • 8 (weak block): a block to blast with an explosion

The sprite of a door depends on its subtype and the tileset of the map. If the door is called doorname, hen the door is closed, all dynamic tiles with the prefix doorname_closed are enabled and the ones with the prefix doorname_open are disabled. When the door is open, this is the opposite.

savegame_variable indicates the index of the boolean value that stores this door's state in the savegame. For usual closed doors (i.e. if the subtype is 0), the value may be -1: this means that the door is not saved.

Stairs (19)

Stairs allow the hero to change his floor, or to get on a platform inside the same floor.

Syntax of a stairs entity:

19	layer	x	y	entity_name	direction	subtype

Subtypes of stairs:

  • 0 (spiral, upstairs): go upstairs with a spiral staircase
  • 1 (spiral, downstars): go downstairs with a spiral staircase
  • 2 (straight, upstairs): go upstairs with a straight staircase
  • 3 (straight, downstairs): go downstairs with a straight staircase
  • 4 (inside a single floor): small stairs that change the hero's layer inside a single floor

The direction is one of the four main directions (0 to 3). However, for stairs that go to another floor, the only possible directions are north (1) and south (3).