Files of a map
While you work, a map is a folder. When you export it, it becomes one encrypted .a4m file that the engine plays directly. Keep the folder as your source: the editor opens folders, not .a4m files.
The folder is plain files, so it works with git. A new map comes with a .gitignore that keeps the editor's backups and temporary files out.
The map folder
| Path | What |
|---|---|
map.toml |
The name, size, first tile, sun, playable area, fog and players. Also a [w4] table with the map format and the editor version that saved it. |
terrain/terrain.w4t |
The ground type and cliff level of every tile. |
terrain/tileset.toml |
The list of ground tiles the map holds. |
terrain/tiles/ |
The pictures of those tiles. |
objects/definitions.toml |
Your definitions: units, heroes, buildings and decorations. |
objects/placements.toml |
What stands on the map: which definition, where, owner and facing. |
assets/ |
Imported models, textures and sounds. |
sounds.toml |
The gain of each sound, set with Normalise in Imports. |
scripts/ |
Your .go files, go.mod, a go.work that is local to your computer, and map.wasm after a build. |
shaders/ |
unit.wesl and terrain.wesl, when the map has its own. |
.gitignore |
Keeps *.bak, *.tmp, *.corrupt and .history/ out of git. |
Next to the data files you may also see <name>.bak (a backup of a file, refreshed at most every five minutes) and <name>.corrupt (a damaged file the editor set aside). Saving and safety explains both.
You can edit most of these files by hand while the editor is closed. .toml files are plain text. Do not edit while the map is open in the editor, since the editor would overwrite your change on its next save.
The exported .a4m
Maps exported before the rename are .w4m files. They still open: the engine and the editor read both, and a map saved again is written as .a4m.
Export in the top bar writes <name>.a4m. It is one file, encrypted from the first byte to the last, and it is what the engine opens. Players only need this file.
It contains what the map uses:
map.toml, the terrain, the tile set and its pictures- the object definitions and placements
- the model of each definition, with the textures that model names
- the compiled
scripts/map.wasm - the map's own shaders
Everything else stays out: imported models that no definition uses, loose textures, sounds, your .go source, and the editor's own files. The toast after exporting tells you how many unused files were left out. (Sounds are not packed yet, because the engine does not play map sounds yet.)
Export does not build your scripts. Play does. Build first if you have changed a script since the last build, or the file will carry the old map.wasm. See Triggers.
How to share the result with other people is in Export and share.
Map format and migration
A map records a format number and the version of the editor that last saved it. Whenever the files of a map change in a way that an older W4 would misread, the format number goes up and the editor learns a step that brings an old map forward.
- An older map opens normally. The editor migrates it, saves it in the current format, and a toast says what was filled in. Anything a map from that age lacks, like the sun, the playable area, fog or players, gets its default. The Activity panel has the list.
- A newer map is refused, with the version that made it. Opening it in an older editor would risk losing parts of it.
The engine also migrates an older map in memory when it starts a game, and never writes the file.
The editor data folder
The editor keeps a few files of its own. They belong to your computer and not to any map.
| System | Folder |
|---|---|
| Windows | %APPDATA%\W4 Editor |
| macOS | ~/Library/Application Support/W4 Editor |
| Linux and others | ~/.config/w4-editor |
| File | What |
|---|---|
recent.toml |
The list of recent maps. |
settings.toml |
The editor settings, the tool panel width, and where the floating panels sit. |
terrain_panel.toml |
Your last tool, tile, brush and tile category in Terrain. |
activity.log |
Everything the Activity panel showed, with activity.log.old when it rolled over. |
crash.txt |
Written if the editor crashes. See Saving and safety. |
engine.log |
The error output of the last game you started with Play. |
The Go API that scripts use is kept apart, in %LOCALAPPDATA%\W4\go-sdk on Windows, ~/Library/Application Support/W4/go-sdk on macOS, and ~/.local/share/W4/go-sdk elsewhere. See Triggers.