mwg API
    Preparing search index...

    Function parseMapFile

    • Reads a Wesnoth-shaped .map file: key=value header lines (border_size=1, usage=map, and anything else the file carries), then one comma-separated row of terrain codes per line. The header is split off and kept, and the grid goes through the same parseTerrain an inline [map] terrain= string does, so a cell is base^overlay exactly as it is there and a <side> <code> token still marks that side's start.

      A file with no header is a bare grid, and the header keys are not interpreted here: what usage or border_size means to a game is the game's business, the same way this framework leaves [terrain_graphics] rules to content.

      Parameters

      • text: string

      Returns MwlMapFile

      import { parseMapFile } from '@datamoc/mw_games/mwl';

      const map = parseMapFile('border_size=1\nusage=map\n\nGg, Gg, Gg\nGg, Gg^Vh, Gg\n');
      map.header.usage; // 'map'
      map.width; // 3
      map.height; // 2
      map.codes; // ['Gg', 'Gg', 'Gg', 'Gg', 'Gg^Vh', 'Gg'] - overlays kept as written