From 8fb456313fe9ec78b36e892c21c66c6b3c508db7 Mon Sep 17 00:00:00 2001 From: myk002 Date: Fri, 9 Jul 2021 22:16:30 -0700 Subject: [PATCH] allow only one positional param to be specified --- docs/Plugins.rst | 5 +++-- plugins/lua/dig-now.lua | 18 +++++++++++------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/Plugins.rst b/docs/Plugins.rst index 254060efa..eb1ca6f1b 100644 --- a/docs/Plugins.rst +++ b/docs/Plugins.rst @@ -2855,11 +2855,12 @@ smoothing and track carving) are handled. Usage:: - dig-now [ ] [] + dig-now [ []] [] Where the optional ```` pair can be used to specify the coordinate bounds within which ``dig-now`` will operate. If they are not specified, ``dig-now`` -will scan the entire map. +will scan the entire map. If only one ```` is specified, only the tile at +that coordinate is processed. Any ```` parameters can either be an ``,,`` triple (e.g. ``35,12,150``) or the string ``here``, which means the position of the active diff --git a/plugins/lua/dig-now.lua b/plugins/lua/dig-now.lua index 5bd270833..2d7ae40d7 100644 --- a/plugins/lua/dig-now.lua +++ b/plugins/lua/dig-now.lua @@ -16,12 +16,12 @@ standard game rules, but the behavior is configurable. Usage: - dig-now [ ] [] + dig-now [ []] [] Examples: dig-now - Dig designated tiles according to standard game rules. + Dig all designated tiles according to standard game rules. dig-now --clean Dig designated tiles, but don't generate any boulders, ores, or gems. @@ -85,12 +85,16 @@ function parse_commandline(opts, ...) df.global.window_z parse_coords(opts, 'start', ('0,0,%d'):format(z)) parse_coords(opts, 'end', ('%d,%d,%d'):format(x, y, z)) - elseif #positionals >= 2 then + elseif #positionals >= 1 then parse_coords(opts, 'start', positionals[1]) - parse_coords(opts, 'end', positionals[2]) - opts.start.x, opts['end'].x = min_to_max(opts.start.x, opts['end'].x) - opts.start.y, opts['end'].y = min_to_max(opts.start.y, opts['end'].y) - opts.start.z, opts['end'].z = min_to_max(opts.start.z, opts['end'].z) + if #positionals >= 2 then + parse_coords(opts, 'end', positionals[2]) + opts.start.x, opts['end'].x = min_to_max(opts.start.x,opts['end'].x) + opts.start.y, opts['end'].y = min_to_max(opts.start.y,opts['end'].y) + opts.start.z, opts['end'].z = min_to_max(opts.start.z,opts['end'].z) + else + utils.assign(opts['end'], opts.start) + end end end