Library
@scm-js/core: the editor's map code as an npm package — open a map, read and change its triggers, strings, units and settings, run Check Map, write it back.
@scm-js/core is the editor's map code as an npm package: open a .scm, .scx or
.chk, read and change its triggers, strings, units, locations and settings, run Check
Map, and write the map back. It is the same code scmJS runs, built from the same source,
so a map reads and writes through the library exactly as it does in the editor of the same
version. It runs in Node.js and in the browser, and needs no game data.
Use it when the editor and the command line do not do the thing you want: a script that changes forty maps the same way, a build step that generates triggers, a check of your own in CI, a tool of your own on top of the format.
npm install @scm-js/core
Node.js 22.12 or newer. The package is ES modules with TypeScript declarations, and its one dependency is mopaq, the MPQ library the editor reads archives with.
- A first scriptOpen a map, say what is in it, run Check Map, change the name and write it out:
- What is in itThe Scenario object is the map: width, height, era (the tileset), strings, units, locations, triggers, briefing, the player tables, the settings tables, the terrain.
- How an edit worksReading is a plain call.
- Triggers as texttriggersToText gives the triggers in the text form the editor's trigger window and the TrigEdit plugin use, and triggersFromText reads it back, so triggers can live in a text file, be dif…
- What it does not doon), building counts, map pictures and the terrain tools need the tilesets and unit tables that only the editor has.
- VersionsThe library's version is the editor's: @scm-js/core 0.9.0 reads and writes what scmJS 0.9.0 does, and the two are published together.
- In the browserThe package has no Node.js dependency, so it bundles into a page as it is.
- In the sourceFor developers.