diff --git a/README.md b/README.md index 5aaf4f1..70b30ea 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,20 @@ maps.draw_map_post_entities() **Description:** Draws all post-entity layers of the current map (`lower_wall` through `canopy`). Must be called after entity rendering when using the split draw model. No-op if no current map. +### Write APIs (v0.4.0+) + +#### `maps.set_cell_gid(layer_name, x, y, gid, map_id?)` + +Writes a single cell into the named layer of the current (or named) map. The layer must be one of `VALID_LAYER_NAMES`; bounds are checked against `map.size`. If the layer does not yet exist on the map it is allocated and initialised to all-zero before the write. Sets an internal `_dirty` flag so callers (e.g. the map-editor) can track unsaved changes. + +#### `maps.set_roof(x, y, value, map_id?)` + +Writes a single roof flag (`0` or `1`) at the named cell. Allocates the roof array on demand if the map did not previously have one. Same bounds-check as `set_cell_gid`. Throws on values other than 0 or 1. + +#### `maps.save_to_disk(map_id, path)` + +Serialises the in-memory map to v2 JSON and writes it to `path`. Output is pretty-printed with 2-space indent and is byte-deterministic for the same map state (sorted object keys, fixed array order). Reverses the internal atlas-resolution back to atlas-ID strings on disk. Resets the `_dirty` flag on success. + ## Conventions - Pixel-coords + tile-coords kept distinct: `size`/`tiles` index in tile-units; `tile_size` is the conversion to pixels. diff --git a/manifest.lib b/manifest.lib index d3e18d7..5036e36 100644 --- a/manifest.lib +++ b/manifest.lib @@ -1 +1 @@ -{"id":"lib-core.maps","version":"0.3.0","api_min":"0.1"} +{"id":"lib-core.maps","version":"0.4.0","api_min":"0.1"}