diff --git a/docs/changelog.txt b/docs/changelog.txt index 985c7ffa2..b7a08788e 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -62,6 +62,7 @@ Template for new versions: - `misery`: fix error when changing the misery factor ## Misc Improvements +- `autochop`: better error output when target burrows are not specified on the commandline - wherever units are listed in DFHack tools, properties like "agitated" or (-trained-) are now shown - `work-now`: now saves its enabled status with the fort diff --git a/library/lua/argparse.lua b/library/lua/argparse.lua index 0a652f428..79c257a9d 100644 --- a/library/lua/argparse.lua +++ b/library/lua/argparse.lua @@ -130,7 +130,7 @@ end function stringList(arg, arg_name, list_length) if not list_length then list_length = 0 end - local list = arg:split(',') + local list = arg and (arg):split(',') or {} if list_length > 0 and #list ~= list_length then arg_error(arg_name, 'expected %d elements; found %d', list_length, #list) diff --git a/plugins/lua/autochop.lua b/plugins/lua/autochop.lua index 239db9ec8..a1a736882 100644 --- a/plugins/lua/autochop.lua +++ b/plugins/lua/autochop.lua @@ -32,7 +32,11 @@ function setTargets(max, min) end local function do_set_burrow_config(var_name, val, burrows) - for _,bspec in ipairs(argparse.stringList(burrows)) do + burrows = argparse.stringList(burrows) + if #burrows == 0 then + qerror('no target burrows specified') + end + for _,bspec in ipairs(burrows) do local config = autochop_getBurrowConfig(bspec) config[var_name] = val autochop_setBurrowConfig(config.id, config.chop, config.clearcut,