diff --git a/CHANGELOG.md b/CHANGELOG.md index 214881a..1413700 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,9 @@ Note to self: See the bottom of this file for the release template text. - Cloud wand: Improve chat message text - Fix `bonemeal` mod detection to look for the global `bonemeal`, not whether the `bonemeal` mod name has been loaded - `//walls`: Prevent crash if not parameters are specified by defaulting to `dirt` as the replace_node - - `//maze`, `//maze3d`: Fix crash if no arguments are specified + - `//maze`, `//maze3d`: + - Fix generated maze not reaching the very edge of the defined region + - Fix crash if no arguments are specified ## v1.12: The selection tools update (26th June 2021) diff --git a/worldeditadditions/lib/maze2d.lua b/worldeditadditions/lib/maze2d.lua index 8fc95ea..cf4dab8 100644 --- a/worldeditadditions/lib/maze2d.lua +++ b/worldeditadditions/lib/maze2d.lua @@ -27,7 +27,7 @@ local function generate_maze(seed, width, height, path_length, path_width) width = width - 1 height = height - 1 - + local world = {} for y = 0, height, 1 do world[y] = {} @@ -48,13 +48,13 @@ local function generate_maze(seed, width, height, path_length, path_width) if cy - path_length > 0 and world[cy - path_length][cx] == "#" then directions = directions .. "u" end - if cy + path_length < height-path_width and world[cy + path_length][cx] == "#" then + if cy + path_length < height-path_width+1 and world[cy + path_length][cx] == "#" then directions = directions .. "d" end if cx - path_length > 0 and world[cy][cx - path_length] == "#" then directions = directions .. "l" end - if cx + path_length < width-path_width and world[cy][cx + path_length] == "#" then + if cx + path_length < width-path_width+1 and world[cy][cx + path_length] == "#" then directions = directions .. "r" end @@ -148,7 +148,7 @@ function worldeditadditions.maze2d(pos1, pos2, target_node, seed, path_length, p -- print("path_width: "..path_width..", path_length: "..path_length) local maze = generate_maze(seed, extent.z, extent.x, path_length, path_width) -- x & need to be the opposite way around to how we index it - -- printspace(maze, extent.z, extent.x) + printspace(maze, extent.z, extent.x) -- z y x is the preferred loop order, but that isn't really possible here