Skip to content
Grant edited this page Jul 29, 2025 · 3 revisions

Welcome to the LDtkParser wiki! I started writing this wiki as a more in-depth instructions on how to utilise the parser.

Getting Started

Setting Up

  1. Import the LDtkParser project template into Gamemaker.
  2. Place the oLDtk object within a room.
  3. Save your LDtk file within the datafiles (Included Files) folder of your project.
  4. Alter global.ldtk.config to your liking.
  5. Call ldtk_load_file() to async load the level into the session.
  6. Use either ldtk_generate_world or ldtk_generate_room to finish importing from LDTK.
  7. Have fun!

Configuring

LDtkConfig

Call ldtk_config() with your custom configuration struct to overwrite their default values found in global.__ldtk_config within the 'LDtkParser' script.

Syntax:
LDtkConfig(struct);

Note:
Check global.__ldtk_config in the 'LDtkParser' script for an updated list of configuration options.

The following options are what you'll most likely require for basic usage.

Key Description
file The LDtk file.
level_name The level to initially load, and will attempt to load a level in this order: (LDtkLoad -> config.level_name -> current room level name)
room_prefix The Room prefix that you use in Gamemaker. (Default: "r")
tileset_prefix The Tileset prefix that you use in Gamemaker. (Default: "")
object_prefix The Object prefix that you use in Gamemaker. (Default: "o")

Example:

// live reload config
LDtkConfig({
	file: project_directory + "datafiles\\LDtkTest.ldtk",
	level_name: "LDtkTest1"
})

LDtkMappings

Finally you'll need to map the sources from LDtk to their target assets and definitions in Gamemaker.

Syntax:
LDtkMappings(struct);

Note:
Check global.__ldtk_config.mappings in the 'LDtkParser' script for a full list of mappings that can be configured.

The key defines the LDtk source variable being imported with the value being the target in Gamemaker. The following options are what you'll most likely require for basic usage.

Key Description
levels ldtk_level_name -> gm_room_name
layers ldtk_layer_name -> gm_room_layer_name
enums ldtk_enum_name -> { ldtk_enum_value -> gml_value }
tilesets ldtk_tileset_name -> gm_tileset_name
intgrids ldtk_intgrid_layer_name -> global.ldtk_intgrids' key

Example:

LDtkMappings({
	layers: {
		Tiles: "PlaceholderTiles", // now "Tiles" layer in LDtk = "PlaceholderTiles" layer in GM
	},
	enums: {
		TestEnum: {
			//First: "First", // first is undefined, should just return the name
			Second: "This is second",
			Third: 3
		}
	},
	tilesets: {
		PlaceholderTiles: "tTiles",
	}
});

Clone this wiki locally