diff --git a/changelog.txt b/changelog.txt index ff109f131..647ad7f85 100644 --- a/changelog.txt +++ b/changelog.txt @@ -33,6 +33,7 @@ Template for new versions: ## Fixes ## Misc Improvements +- `fix/stuck-worship`: reduced console output by default. ``--verbose`` option to print all affected units. ## Removed diff --git a/docs/fix/dry-buckets.rst b/docs/fix/dry-buckets.rst index 9d3a7d4e0..65740e309 100644 --- a/docs/fix/dry-buckets.rst +++ b/docs/fix/dry-buckets.rst @@ -19,6 +19,7 @@ manually. Usage ----- -:: - - fix/dry-buckets +``fix/dry-buckets`` + Empty water buckets not currently used in jobs. +``fix/dry-buckets -q``, ``fix/dry-buckets --quiet`` + Empty water buckets not currently used in jobs. Don't print to the console. diff --git a/docs/fix/stuck-worship.rst b/docs/fix/stuck-worship.rst index b0dbfe07f..c4bccc055 100644 --- a/docs/fix/stuck-worship.rst +++ b/docs/fix/stuck-worship.rst @@ -26,6 +26,7 @@ another task. Usage ----- -:: - - fix/stuck-worship +``fix/stuck-worship`` + Rebalance prayer needs of units in the fort. +``fix/stuck-worship -v``, ``fix/stuck-worship --verbose`` + Rebalance prayer needs of units in the fort. Print names of affected units. diff --git a/fix/stuck-worship.lua b/fix/stuck-worship.lua index 1531af139..0222dd6fe 100644 --- a/fix/stuck-worship.lua +++ b/fix/stuck-worship.lua @@ -1,4 +1,9 @@ -debug_print = false +local argparse = require('argparse') + +local verbose = false +argparse.processArgsGetopt({...}, { + {'v', 'verbose', handler=function() verbose = true end}, +}) local function for_pray_need(needs, fn) for idx, need in ipairs(needs) do @@ -81,15 +86,26 @@ local function get_prayer_targets(unit) end end +local function unit_name(unit) + return dfhack.df2console(dfhack.TranslateName(dfhack.units.getVisibleName(unit))) +end + +local count = 0 for _,unit in ipairs(dfhack.units.getCitizens(false, true)) do local prayer_targets = get_prayer_targets(unit) if not unit.status.current_soul or not prayer_targets then goto next_unit end local needs = unit.status.current_soul.personality.needs - if shuffle_prayer_needs(needs, prayer_targets) and debug_print then - print('rebalanced prayer needs for ' .. - dfhack.df2console(dfhack.TranslateName(dfhack.units.getVisibleName(unit)))) + if shuffle_prayer_needs(needs, prayer_targets) then + count = count + 1 + if verbose then + print('Shuffled prayer target for '..unit_name(unit)) + end end ::next_unit:: end + +if verbose or count > 0 then + print(('Rebalanced prayer needs for %d units.'):format(count)) +end