diff --git a/Changelog.md b/Changelog.md index 29fbb25..ecc6e8b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,6 @@ +## 0.2.1 +Catch when no Levels tiles are present under the ruler position, so that Levels floor labels do not appear unnecessarily. + ## 0.2.0 Add levels measurement function - When over a levels tile, default to the bottom elevation of that tile. diff --git a/scripts/segments.js b/scripts/segments.js index debf848..0b69e8a 100644 --- a/scripts/segments.js +++ b/scripts/segments.js @@ -68,7 +68,10 @@ UX goals: } if(game.settings.get(MODULE_ID, "enable-levels-floor-label")) { - this.setFlag(MODULE_ID, "elevation_level_name", LevelNameAtPoint(this.ray.B, ending_elevation)); + const level_name = LevelNameAtPoint(this.ray.B, ending_elevation); + log(`Level name for segment ${this.segment_num} is ${level_name}`); + + this.setFlag(MODULE_ID, "elevation_level_name", level_name); } this.setFlag(MODULE_ID, "starting_elevation", starting_elevation); this.setFlag(MODULE_ID, "ending_elevation", ending_elevation); @@ -198,6 +201,8 @@ export function elevationRulerGetText(wrapped, ...args) { let elevation_label = segmentElevationLabel(ending_elevation - starting_elevation, ending_elevation); if(game.settings.get(MODULE_ID, "enable-levels-floor-label")) { const level_name = this.getFlag(MODULE_ID, "elevation_level_name"); + log(`elevationRulerGetText: Level name is ${level_name}`); + if(level_name) { elevation_label += `\n${level_name}`; } @@ -343,7 +348,7 @@ function LevelNameAtPoint(p, zz) { } const floors = _levels.getFloorsForPoint(p); - if(!floors) { return undefined; } + if(!floors || floors.length < 1) { return undefined; } const levels_data = canvas.scene.getFlag("levels", "sceneLevels") // array with [0]: bottom; [1]: top; [2]: name for(let l of levels_data) {