Normalise width & height to avoid issues
This commit is contained in:
parent
aa4ce5591d
commit
90f7819e09
2 changed files with 20 additions and 0 deletions
10
main.lua
10
main.lua
|
@ -1,5 +1,6 @@
|
||||||
local strings = require("./utils/strings")
|
local strings = require("./utils/strings")
|
||||||
local debug = require("./utils/print_r")
|
local debug = require("./utils/print_r")
|
||||||
|
local calculations = require("./utils/calculations")
|
||||||
local maze2d = require("./maze")
|
local maze2d = require("./maze")
|
||||||
local maze3d = require("./maze3d")
|
local maze3d = require("./maze3d")
|
||||||
local openscad = require("./openscad")
|
local openscad = require("./openscad")
|
||||||
|
@ -58,6 +59,15 @@ if #settings.extras > 0 then
|
||||||
settings.mode = table.remove(settings.extras, 1)
|
settings.mode = table.remove(settings.extras, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local new_width = calculations.normalise_dimension(settings.width, settings.path_length, settings.path_width)
|
||||||
|
print("[normalise] width "..settings.width.." → "..new_width)
|
||||||
|
settings.width = new_width
|
||||||
|
|
||||||
|
local new_height = calculations.normalise_dimension(settings.height, settings.path_length, settings.path_width)
|
||||||
|
print("[normalise] height "..settings.height.." → "..new_height)
|
||||||
|
settings.height = new_height
|
||||||
|
|
||||||
local function help()
|
local function help()
|
||||||
print([[
|
print([[
|
||||||
multimaze: Multidimensional maze generator
|
multimaze: Multidimensional maze generator
|
||||||
|
|
10
utils/calculations.lua
Normal file
10
utils/calculations.lua
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
function M.normalise_dimension(value, path_length, path_width)
|
||||||
|
local cells = (value - (path_width*2)) / path_length
|
||||||
|
cells = math.floor(cells)
|
||||||
|
local new_value = (cells*path_length)+(path_width*2)
|
||||||
|
return new_value
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
Loading…
Reference in a new issue