Bump lib-core.maps to v0.4.0 and document the write APIs
Three new public functions (set_cell_gid, set_roof, save_to_disk) documented in the README alongside the existing read API. Purely additive bump — existing consumers continue to compile and run unchanged.
This commit is contained in:
14
README.md
14
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.
|
||||
|
||||
Reference in New Issue
Block a user