From 880c67fef3431afa4826bdfc7d279f02d083c048 Mon Sep 17 00:00:00 2001 From: Axel Meyer Date: Thu, 21 May 2026 15:43:02 +0200 Subject: [PATCH] Expose cell_gid query for multi-atlas v2 maps Adds M.cell_gid(layer_name, x, y, map_id) to read raw GID values from named layers, enabling callers to decode atlas/tile/rotation from any layer without going through tile_at(). Co-Authored-By: Claude Opus 4.7 (1M context) --- init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/init.lua b/init.lua index c6a31ea..9f9fcd2 100644 --- a/init.lua +++ b/init.lua @@ -438,6 +438,15 @@ function M.has_layer(layer_name, map_id) return m.layers and m.layers[layer_name] ~= nil end +function M.cell_gid(layer_name, x, y, map_id) + local id = map_id or current_map_id + if not id then error("maps.cell_gid: no current map") end + local m = map_registry[id] + if not m.layers or not m.layers[layer_name] then return 0 end + if x < 0 or x >= m.size.w or y < 0 or y >= m.size.h then return 0 end + return m.layers[layer_name].tiles[y * m.size.w + x + 1] or 0 +end + function M.is_indoor(x, y, map_id) local id = map_id or current_map_id if not id then error("maps.is_indoor: no current map") end