main.lua: add more short aliases

This commit is contained in:
Starbeamrainbowlabs 2020-09-06 02:09:47 +01:00
parent 5188ffe174
commit 1cb6bbf8bc
Signed by: sbrl
GPG Key ID: 1BE5172E637709C2
1 changed files with 51 additions and 43 deletions

View File

@ -31,45 +31,6 @@ local settings = {
path_depth = 1
}
for i=1,#arg do
if not strings.starts_with(arg[i], "-") then
table.insert(settings.extras, arg[i])
elseif arg[i] == "--width" or arg[i] == "-w" then
i = i + 1
settings.width = tonumber(arg[i])
elseif arg[i] == "--height" or arg[i] == "-h" then
i = i + 1
settings.height = tonumber(arg[i])
elseif arg[i] == "--depth" or arg[i] == "-d" then
i = i + 1
settings.depth = tonumber(arg[i])
elseif arg[i] == "--seed" or arg[i] == "-s" then
i = i + 1
settings.seed = tonumber(arg[i])
elseif arg[i] == "--filename" or arg[i] == "-f" then
i = i + 1
settings.filename = arg[i]
elseif arg[i] == "--scale" then
i = i + 1
settings.scale = tonumber(arg[i])
elseif arg[i] == "--no-invert" then
settings.inverted = false
elseif arg[i] == "--path-length" then
i = i + 1
settings.path_length = tonumber(arg[i])
elseif arg[i] == "--path-width" then
i = i + 1
settings.path_width = tonumber(arg[i])
elseif arg[i] == "--path-depth" then
i = i + 1
settings.path_depth = tonumber(arg[i])
end
end
if #settings.extras > 0 then
settings.mode = table.remove(settings.extras, 1)
end
local function help()
print([[
]]..a.fgreen(a.hicol("multimaze: "))..a.fyellow(a.hicol("Multidimensional maze generator"))..[[
@ -91,16 +52,17 @@ local function help()
]]..a.header("Options:")..[[
]]..a.item("--help")..[[ Shows this message
]]..a.item("-w --width")..a.value(" {int}")..[[ Sets the width of the maze
]]..a.item("-h --height")..a.value(" {int}")..[[ Sets the height of the maze
]]..a.item("-d --depth")..a.value(" {int}")..[[ Sets the depth of the maze [3d only]
]]..a.item("-s --seed")..a.value(" {string}")..[[ Sets the seed
]]..a.item("-f --filename")..a.value(" {string}")..[[ Sets the output filename
]]..a.item("--no-invert")..[[ Don't invert the output [openscad output only]
]]..a.item("--scale")..a.value(" {int}")..[[ Sets the scale of the output [openscad output only]
]]..a.item("--path-length")..a.value(" {int}")..[[ Sets the path length
]]..a.item("--path-width")..a.value(" {int}")..[[ Sets the path width
]]..a.item("--path-depth")..a.value(" {int}")..[[ Sets the path depth [3d only]
]]..a.item("-m --scale")..a.value(" {int}")..[[ Sets the scale of the output [openscad output only]
]]..a.item("-l --path-length")..a.value(" {int}")..[[ Sets the path length
]]..a.item("-y --path-width")..a.value(" {int}")..[[ Sets the path width
]]..a.item("-z --path-depth")..a.value(" {int}")..[[ Sets the path depth [3d only]
]]..a.header("Environment Variables:")..[[
@ -109,6 +71,52 @@ local function help()
]])
end
for i=1,#arg do
if not strings.starts_with(arg[i], "-") then
table.insert(settings.extras, arg[i])
elseif arg[i] == "--help" then
help()
os.exit()
elseif arg[i] == "--width" or arg[i] == "-w" then
i = i + 1
settings.width = tonumber(arg[i])
elseif arg[i] == "--height" or arg[i] == "-h" then
i = i + 1
settings.height = tonumber(arg[i])
elseif arg[i] == "--depth" or arg[i] == "-d" then
i = i + 1
settings.depth = tonumber(arg[i])
elseif arg[i] == "--seed" or arg[i] == "-s" then
i = i + 1
settings.seed = tonumber(arg[i])
elseif arg[i] == "--filename" or arg[i] == "-f" then
i = i + 1
settings.filename = arg[i]
elseif arg[i] == "--scale" or arg[i] == "-m" then
i = i + 1
settings.scale = tonumber(arg[i])
elseif arg[i] == "--no-invert" then
settings.inverted = false
elseif arg[i] == "--path-length" or arg[i] == "-l" then
i = i + 1
settings.path_length = tonumber(arg[i])
elseif arg[i] == "--path-width" or arg[i] == "-y" then
i = i + 1
settings.path_width = tonumber(arg[i])
elseif arg[i] == "--path-depth" or arg[i] == "-z" then
i = i + 1
settings.path_depth = tonumber(arg[i])
end
end
if #settings.extras > 0 then
settings.mode = table.remove(settings.extras, 1)
end
-------------------------------------------------------------------------------
local function maze_text()
local world, time = maze2d.generate_maze(
settings.seed,