Skip to content

Commit

Permalink
Merge pull request #4119 from myk002/myk_autochop
Browse files Browse the repository at this point in the history
[autochop] better error output on malformed command
  • Loading branch information
myk002 authored Dec 31, 2023
2 parents 2cefca4 + 648dc20 commit 1aa771f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion library/lua/argparse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion plugins/lua/autochop.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1aa771f

Please sign in to comment.