Merge pull request #4119 from myk002/myk_autochop

[autochop] better error output on malformed command
develop
Myk 2023-12-31 11:34:20 -08:00 committed by GitHub
commit 1aa771fee8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

@ -62,6 +62,7 @@ Template for new versions:
- `misery`: fix error when changing the misery factor - `misery`: fix error when changing the misery factor
## Misc Improvements ## 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 - 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 - `work-now`: now saves its enabled status with the fort

@ -130,7 +130,7 @@ end
function stringList(arg, arg_name, list_length) function stringList(arg, arg_name, list_length)
if not list_length then list_length = 0 end 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 if list_length > 0 and #list ~= list_length then
arg_error(arg_name, arg_error(arg_name,
'expected %d elements; found %d', list_length, #list) 'expected %d elements; found %d', list_length, #list)

@ -32,7 +32,11 @@ function setTargets(max, min)
end end
local function do_set_burrow_config(var_name, val, burrows) 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) local config = autochop_getBurrowConfig(bspec)
config[var_name] = val config[var_name] = val
autochop_setBurrowConfig(config.id, config.chop, config.clearcut, autochop_setBurrowConfig(config.id, config.chop, config.clearcut,