Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Template for new versions:
- `gui/confirm`: in the delete manager order confirmation dialog, show a description of which order you have selected to delete
- `position`: display both adventurer and site pos simultaneously. Display map block pos+offset of selected tile.
- `gui/sitemap`: shift click to start following the selected unit or artifact
- `prioritize`: when prioritizing jobs of a specified type, also output how many of those jobs were already prioritized before you ran the command
- `prioritize`: don't include already-prioritized jobs in the output of ``prioritize -j``

## Removed

Expand Down
10 changes: 5 additions & 5 deletions docs/prioritize.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ prioritize

This tool encourages specified types of jobs to get assigned and completed as
soon as possible. Finally, you can be sure your food will be hauled before
rotting, your hides will be tanned before going bad, and the corpses of your
it rots, your hides will be tanned before they go bad, and the corpses of your
enemies will be cleared expediently from your entranceway.

You can prioritize a bunch of active jobs that you need done *right now*, or you
Expand Down Expand Up @@ -40,7 +40,8 @@ Examples
Watch for and prioritize the default set of job types that the community has
suggested and playtested (see below for details).
``prioritize -j``
Print out the list of active jobs that you can prioritize right now.
Print out the list of not-yet prioritized jobs that you can prioritize
right now.
``prioritize ConstructBuilding DestroyBuilding``
Prioritize all current building construction and destruction jobs.
``prioritize -a --haul-labor=Food,Body StoreItemInStockpile``
Expand All @@ -56,8 +57,7 @@ Options
``-d``, ``--delete``
Stop automatically prioritizing new jobs of the specified job types.
``-j``, ``--jobs``
Print out how many current jobs of each type there are. This is useful for
discovering the types of the jobs that you can prioritize right now. If any
Print out how many current unprioritized jobs of each type there are. If any
job types are specified, only jobs of those types are listed.
``-l``, ``--haul-labor <labor>[,<labor>...]``
For StoreItemInStockpile jobs, match only the specified hauling labor(s).
Expand Down Expand Up @@ -97,7 +97,7 @@ staring at the screen in annoyance for too long.
You may be tempted to automatically prioritize ``ConstructBuilding`` jobs, but
beware that if you engage in megaprojects where many constructions must be
built, these jobs can consume your entire fortress if prioritized. It is often
better to run ``prioritize ConstructBuilding`` by itself (i.e. without the
better to run ``prioritize ConstructBuilding`` by itself (that is, without the
``-a`` parameter) as needed to just prioritize the construction jobs that you
have ready at the time if you need to "clear the queue".

Expand Down
15 changes: 12 additions & 3 deletions prioritize.lua
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,23 @@ local function for_all_jobs(cb)
end

local function boost(job_matchers, opts)
local count = 0
local count, already_prioritized = 0, 0
for_all_jobs(
function(job)
if not job.flags.do_now and boost_job_if_matches(job, job_matchers) then
count = count + 1
local was_prioritized = job.flags.do_now
if boost_job_if_matches(job, job_matchers) then
if was_prioritized then
already_prioritized = already_prioritized + 1
else
count = count + 1
end
end
end)
if not opts.quiet then
print(('Prioritized %d job%s.'):format(count, count == 1 and '' or 's'))
if already_prioritized > 0 then
print(('%d job%s already prioritized.'):format(already_prioritized, already_prioritized == 1 and '' or 's'))
end
end
end

Expand Down Expand Up @@ -440,6 +448,7 @@ local function print_current_jobs(job_matchers, opts)
local filtered = next(job_matchers)
local function count_job(jobs, job)
if filtered and not job_matchers[job.job_type] then return end
if job.flags.do_now then return end
local job_type = get_job_type_str(job)
jobs[job_type] = (jobs[job_type] or 0) + 1
end
Expand Down