diff --git a/init.lua b/init.lua index e864a3f..8c6001b 100644 --- a/init.lua +++ b/init.lua @@ -595,13 +595,7 @@ end -- Operates on the current map's tilemap; call after maps.set_current. -- asset_aliases: { [alias-key] = asset-lib-id } from module's manifest. -- ==================================================================== -function M.load_textures(asset_aliases) - local map_id = M.current() - if map_id == nil then - error("maps.load_textures: no current map; call maps.set_current first") - end - local m = map_registry[map_id] - local tm = m.tilemap +local function load_textures_for_tilemap(tm, asset_aliases) if tm.asset_pack == nil then return end -- color-only tilemap, no textures local lib_id = asset_aliases[tm.asset_pack] if lib_id == nil then @@ -627,6 +621,23 @@ function M.load_textures(asset_aliases) end end +function M.load_textures(asset_aliases) + local map_id = M.current() + if map_id == nil then + error("maps.load_textures: no current map; call maps.set_current first") + end + local m = map_registry[map_id] + + if m.schema_version == 2 then + for _, tm in ipairs(m.atlases) do + load_textures_for_tilemap(tm, asset_aliases) + end + return + end + -- v1 legacy: kept for M.create with manual v1 table + load_textures_for_tilemap(m.tilemap, asset_aliases) +end + function M.iterate_layers_pre_entities(fn, map_id) local id = map_id or current_map_id if not id then error("maps.iterate_layers_pre_entities: no current map") end