diff --git a/ReadMe.md b/ReadMe.md index 762400a..e642460 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -30,6 +30,8 @@ Use transparency. 25% works well. width/height - (path relative to the JSON file? or relative to the executable?) +Images are only loaded if they will be displayed. + ## Example JSON ```json diff --git a/map_3.png b/images/map_3.png similarity index 100% rename from map_3.png rename to images/map_3.png diff --git a/map.json b/map.json index d8a8667..c1ac4bc 100644 --- a/map.json +++ b/map.json @@ -82,7 +82,7 @@ "Farm Region": [-235, 80, -100, true, {"radius": 230, "color": [0, 0.5, 0, 0.15], "offset": [-54, 0]}], "Mount Sharpe": [735, 110, 685, "mountainous region", {"radius": 165, "color": [1, 1, 1, 0.1], "offset": [-54, 4]}], "approximate area of extreme mountains": [-50, 100, 750, true, {"radius": [570, 525], "color": [1, 1, 1, 0.15]}], - "map_3": [448, 64, 448, false, {"image": "map_3.png", "size": [1024, 1024], "color": [1, 1, 1, 0.5]}], + "map_3": [448, 64, 448, false, {"image": "images/map_3.png", "size": [1024, 1024], "color": [1, 1, 1, 0.5]}], "unnamed hill": [400, 100, 235, true, {"radius": [110, 100], "offset": [-40, 0]}], "unnamed plains": [40, 100, 140, true, {"radius": [115, 85], "offset": [-50, 0]}], "original worldborder": [0, 87, 0, false, {"box": [1000, 1000], "mode": "line"}] diff --git a/src/main.lua b/src/main.lua index b92859a..6f4fc33 100644 --- a/src/main.lua +++ b/src/main.lua @@ -39,7 +39,7 @@ local function load_map(map_file_name) edges = map.edges or {} areas = map.areas or {} for _, area in pairs(map.areas) do - local image_file_name = area[5] and area[5].image + local image_file_name = (area[4] or area[4] == nil) and area[5] and area[5].image if image_file_name then local file = io.open(image_file_name, "rb") local data = file:read("*all") diff --git a/test map.json b/test map.json index 5d7361d..3a56336 100644 --- a/test map.json +++ b/test map.json @@ -5,5 +5,8 @@ "BottomLeft": [0, 0, 900, true], "BottomRight": [1600, 0, 900, true] }, - "edges": [] + "edges": [], + "areas": { + "test image": [100, 0, 100, true, {"image": "test image.png", "size": [200, 200], "color": [1, 1, 1, 1]}] + } }