Skip to content

Commit 50f3f8b

Browse files
authored
Add verbose option, update docs
* Update stuck-worship.lua * Update dry-buckets.rst * Update stuck-worship.rst * Update changelog.txt
1 parent 465213a commit 50f3f8b

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Template for new versions:
3333
## Fixes
3434

3535
## Misc Improvements
36+
- `fix/stuck-worship`: reduced console output by default. ``--verbose`` option to print all affected units.
3637

3738
## Removed
3839

docs/fix/dry-buckets.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ manually.
1919
Usage
2020
-----
2121

22-
::
23-
24-
fix/dry-buckets
22+
``fix/dry-buckets``
23+
Empty water buckets not currently used in jobs.
24+
``fix/dry-buckets -q``, ``fix/dry-buckets --quiet``
25+
Empty water buckets not currently used in jobs. Don't print to the console.

docs/fix/stuck-worship.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ another task.
2626
Usage
2727
-----
2828

29-
::
30-
31-
fix/stuck-worship
29+
``fix/stuck-worship``
30+
Rebalance prayer needs of units in the fort.
31+
``fix/stuck-worship -v``, ``fix/stuck-worship --verbose``
32+
Rebalance prayer needs of units in the fort. Print names of affected units.

fix/stuck-worship.lua

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
debug_print = false
1+
local argparse = require('argparse')
2+
3+
local verbose = false
4+
argparse.processArgsGetopt({...}, {
5+
{'v', 'verbose', handler=function() verbose = true end},
6+
})
27

38
local function for_pray_need(needs, fn)
49
for idx, need in ipairs(needs) do
@@ -81,15 +86,26 @@ local function get_prayer_targets(unit)
8186
end
8287
end
8388

89+
local function unit_name(unit)
90+
return dfhack.df2console(dfhack.TranslateName(dfhack.units.getVisibleName(unit)))
91+
end
92+
93+
local count = 0
8494
for _,unit in ipairs(dfhack.units.getCitizens(false, true)) do
8595
local prayer_targets = get_prayer_targets(unit)
8696
if not unit.status.current_soul or not prayer_targets then
8797
goto next_unit
8898
end
8999
local needs = unit.status.current_soul.personality.needs
90-
if shuffle_prayer_needs(needs, prayer_targets) and debug_print then
91-
print('rebalanced prayer needs for ' ..
92-
dfhack.df2console(dfhack.TranslateName(dfhack.units.getVisibleName(unit))))
100+
if shuffle_prayer_needs(needs, prayer_targets) then
101+
count = count + 1
102+
if verbose then
103+
print('Shuffled prayer target for '..unit_name(unit))
104+
end
93105
end
94106
::next_unit::
95107
end
108+
109+
if verbose or count > 0 then
110+
print(('Rebalanced prayer needs for %d units.'):format(count))
111+
end

0 commit comments

Comments
 (0)