Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 1.39 KB

File metadata and controls

45 lines (31 loc) · 1.39 KB

Spring Map Parser

Parser for SpringRTS/RecoilEngine map files

Usage

npm i --save spring-map-parser

import { MapParser } from "spring-map-parser";

(async () => {
    const mapPath = "./working-files/maps/aberdeen3v3v3.sd7";

    const parser = new MapParser({ verbose: true, mipmapSize: 4, skipSmt: false });

    const map = await parser.parseMap(mapPath);

    console.log(map.info.startPositions[0].x);

    await map.textureMap!.writeAsync("working-files/texture.png");
    await map.heightMap!.resize(200, -1).writeAsync("working-files/height.png"); // -1 here means preserve aspect ratio
    await map.metalMap!.writeAsync("working-files/metal.png");
    await map.typeMap!.writeAsync("working-files/type.png");
    await map.miniMap!.writeAsync("working-files/mini.png");
    await map.textureMap!.scaleToFit(765, 300).quality(80).writeAsync("working-files/test.jpg");

    // If the map has a skybox defined in mapinfo.lua (atmosphere.skyBox)
    // it will be automatically converted from a DDS cubemap to an equirectangular (2:1) image
    if (map.skybox) {
        await map.skybox.writeAsync("working-files/skybox.png");
    }
})();

The different map images are Jimp instances, which provides some useful image processing functionality.

Development

Publish new version

npm version --sign-git-tag patch|minor|major
git push --follow-tags