-
Notifications
You must be signed in to change notification settings - Fork 217
New tool: Multihaul #1484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LoireLab
wants to merge
139
commits into
DFHack:master
Choose a base branch
from
LoireLab:multihaul
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+382
−0
Open
New tool: Multihaul #1484
Changes from all commits
Commits
Show all changes
139 commits
Select commit
Hold shift + click to select a range
0ab4262
Add chronicle script to record fortress events
LoireLab 3657eba
Merge pull request #1 from LoireLab/codex/-chronicle.lua
LoireLab 2e675db
fix chronicle initialization and loading
LoireLab a508e66
Merge branch 'master' into 8pg7m7-codex/-chronicle.lua
LoireLab 75c597b
Merge pull request #3 from LoireLab/8pg7m7-codex/-chronicle.lua
LoireLab 8da32eb
Fix chronicle artifact log and hook handling
LoireLab b827167
Merge branch 'master' into cijxz4-codex/-chronicle.lua
LoireLab 3e91375
Merge pull request #4 from LoireLab/cijxz4-codex/-chronicle.lua
LoireLab 4ee1a21
fix chronicle artifact timestamp
LoireLab d912fc2
Merge pull request #6 from LoireLab/codex/fix-artifact_record.year_ti…
LoireLab 5a4b43a
disable heavy scanning in chronicle
LoireLab 7ae87b0
Merge pull request #7 from LoireLab/62ad62-codex
LoireLab bcbcc3d
Track artifacts and invasions
LoireLab c623822
Remove legacy scanning in chronicle
LoireLab 1d72e2a
Merge pull request #8 from LoireLab/dhff81-codex
LoireLab dba3c1a
Refine holy-war mod with deity spheres
LoireLab 5894d49
Merge pull request #9 from LoireLab/9hdvkm-codex
LoireLab 66bc94e
Enhance chronicle output and item tracking
LoireLab a381a24
Merge pull request #10 from LoireLab/codex/investigate-chronicle-prin…
LoireLab 55777ed
Ensure holy-war sets war on both sides
LoireLab 0bc3aa2
Merge pull request #11 from LoireLab/codex/-holy-war
LoireLab f79f046
Refine chronicle output
LoireLab d5e8333
Merge pull request #12 from LoireLab/codex/fix-incomplete-utf-8-seque…
LoireLab 5839e89
holy-war: display war reason
LoireLab 5a1278e
Merge pull request #13 from LoireLab/uyevve-codex
LoireLab 9a12910
Summarize non-artifact item creation
LoireLab d7b8668
Improve holy-war output
LoireLab fc848c8
Merge pull request #14 from LoireLab/3zaa1h-codex
LoireLab 348aa13
Merge pull request #15 from LoireLab/90u9lr-codex/-holy-war
LoireLab 1c8ab86
Need-aquire
LoireLab b541254
chronicle: capture artifact announcements
LoireLab c80fd0a
Merge pull request #16 from LoireLab/n6oxr7-codex
LoireLab 27f92b8
Improve need-acquire.lua with documentation and cleanup
LoireLab e11daff
Merge pull request #17 from LoireLab/codex/-need-acquire.lua
LoireLab 1271e42
chronicle: add export command
LoireLab aa7ec00
Merge pull request #19 from LoireLab/qgrtgu-codex
LoireLab a827df4
Sanitize chronicle output
LoireLab 64184e2
Merge pull request #20 from LoireLab/tgeoam-codex
LoireLab aa46986
sanitize chronicle entries
LoireLab 2a78abc
Merge branch 'master' into 7d9b1y-codex
LoireLab dd2afe3
Merge pull request #21 from LoireLab/7d9b1y-codex
LoireLab e187aed
Optimization of chronicle.lua
LoireLab c6cd65a
Refactor scripts and update docs
LoireLab f39879f
Merge pull request #22 from LoireLab/codex/-need-acquire,-holy-war,-c…
LoireLab bcd1d94
Chronicle.lua new events and text changes from notification style
LoireLab a811f4e
Ignore wildlife deaths in chronicle
LoireLab 3c1113f
Merge pull request #23 from LoireLab/codex/-wildlife-chronicle
LoireLab 5f3bea4
Add scrollable chronicle viewer
LoireLab a1754c3
Merge pull request #24 from LoireLab/codex/-chronicle
LoireLab 18d804b
Preserve trimmed chronicle entries
LoireLab ce57986
Add multihaul script
LoireLab 93f002f
Merge pull request #25 from LoireLab/fff979-codex/-chronicle
LoireLab 0828c9f
Merge pull request #26 from LoireLab/codex/-haul
LoireLab dd177e3
Refine death messages with faction-specific text
LoireLab 27e017f
Merge branch 'master' into arkt0w-codex
LoireLab 9abc0cc
Merge pull request #27 from LoireLab/arkt0w-codex
LoireLab c61e2c1
Add config options and debugging to multihaul
LoireLab 125b9b1
Merge pull request #28 from LoireLab/codex/-multihaul
LoireLab 969dc3b
chronicle: unified notification capture pattern
LoireLab bb30c35
Add wheelbarrow-multi script
LoireLab 120714f
Merge pull request #29 from LoireLab/xfayq7-codex
LoireLab 4918c25
fix chronicle typos and update help
LoireLab f661b82
Merge pull request #30 from LoireLab/codex/-chroncile
LoireLab dbcfc0a
Delete wheelbarrow-multi.lua
LoireLab e1d73ab
Delete multihaul.lua
LoireLab ef86f40
Add stack-bodyparts script
LoireLab 232ab56
Merge pull request #31 from LoireLab/cw2cix-codex
LoireLab c95408d
Revert "Add stack-bodyparts utility"
LoireLab 6d8f5e3
chronicle.lua: fixed multiple notification logging
LoireLab 3ee0432
chronicle.lua: more lines, separate lines for Bloodsuckers and Great …
LoireLab f5b19f3
chronicle.lua: ticks to detect events increased
LoireLab 112be4e
Merge pull request #33 from LoireLab/revert-31-cw2cix-codex
LoireLab d44dcc3
Restored multihaul.lua
LoireLab 996bec8
Fix multihaul unloading and limit by container size
LoireLab 84ad664
Merge pull request #34 from LoireLab/codex/fix-unloading-issue-in-mul…
LoireLab 989ae8d
multihaul.lua: reverted to item count since capacity is calculated by…
LoireLab 2d23d4f
Debugging multihaul.lua
LoireLab e4f035f
Debug multihaul.lua: I got it called
LoireLab f1566b2
multihaul.lua: clean version with working multi gathering and not wor…
LoireLab 5d1699e
multihaul.lua: fixed unneeded code copied from emptywheelbarrow
LoireLab 0b31ff1
fix multihaul script
LoireLab c41e43a
Merge pull request #35 from LoireLab/codex/fix-nil-value-error-in-mul…
LoireLab fef261b
multihaul.lua: WORKING VERSION HURRAY
LoireLab 37c55c5
Restrict multihaul to wheelbarrow jobs
LoireLab 9ee5928
Merge pull request #36 from LoireLab/codex/-multihaul-wheelbarrow
LoireLab 2572537
multihaul: restrict to identical items and verify wheelbarrow
LoireLab b84914f
Merge pull request #37 from LoireLab/codex/-wheelbarrow
LoireLab 81f3db2
multihaul: fix wheelbarrow role
LoireLab cf05936
Merge pull request #38 from LoireLab/codex/-pushhaulvehicle
LoireLab 58b3688
multihaul.lua: removed unnesessary checks and fixes
LoireLab cfb1e95
multihaul: filter items by stockpile settings
LoireLab 7134d53
Merge pull request #39 from LoireLab/lxvsq8-codex
LoireLab 986eeb5
multihaul: add matching modes
LoireLab f3e50c6
Merge pull request #40 from LoireLab/codex/-multihaul
LoireLab c2a4bd1
multihaul.lua: changed default mode and removed isItemAllowedInStockpile
LoireLab 48cd99a
multihaul.lua: splited type and subtype modes
LoireLab 8cbf4b3
refactor multihaul state and update docs
LoireLab 46d0f57
Merge pull request #41 from LoireLab/673mq6-codex/-multihaul
LoireLab bfa99d6
Delete changelog.txt
LoireLab 20dd70d
multihaul: docs updated
LoireLab 640ca99
multihaul: help updated
LoireLab 347d2a2
Delete gui/chronicle.lua
LoireLab b187046
Delete chronicle.lua
LoireLab acaa671
Delete holy-war.lua
LoireLab a9b48d1
Delete docs/need-acquire.rst
LoireLab 2e45d27
Delete docs/wheelbarrow-multi.rst
LoireLab 830de7a
Delete docs/chronicle.rst
LoireLab e1e3c65
Delete docs/holy-war.rst
LoireLab b96a5bf
Add files via upload
LoireLab a4845fd
Update changelog.txt
LoireLab e963afe
Delete need-acquire.lua
LoireLab 4b0f187
Update multihaul.lua
LoireLab bb0d045
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 40cd433
multihaul.lua: protection for already in stockpile items and autobrea…
LoireLab 64ac19e
Update multihaul.lua
LoireLab d31b536
Update multihaul.rst
LoireLab 8ae5572
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] e94232c
multihaul: assign wheelbarrows to any job!
LoireLab 3ccf8d0
multihaul: optimize wheelbarrow assignment
LoireLab 80501dd
multihaul: optimization
LoireLab 8f4c3e7
Update multihaul.rst
LoireLab ea5a859
multihaul wheelbarrow assign optimization
LoireLab 759332c
Update multihaul.lua
LoireLab f2886ae
multihaul: fix grabbing wheelbarrows and minecart logic
LoireLab f21982f
multihaul: optimizing item search
LoireLab d8eded8
refactor multihaul item search
LoireLab ae59c6d
Merge pull request #45 from LoireLab/i8l5e4-codex/standardize-item-se…
LoireLab 2b4f7b9
multihaul: added protection for returning wheelbarrow jobs
LoireLab a76460f
multihaul: removed magic number on wheelbarrow_search_radius_k
LoireLab bbead11
wheelbarrow_search_radius_k now is called correctly
LoireLab 9410045
multihaul: clear lost wheelbarrow jobs when emptying
LoireLab c799c3f
Merge pull request #46 from LoireLab/0aur88-codex/implement-finish_jo…
LoireLab d910921
fix multihaul forward declaration
LoireLab 3f31da2
Merge pull request #47 from LoireLab/x5agea-codex/fix-nil-value-error…
LoireLab 6049eae
autowheelbarrow option now works correctly
LoireLab a334119
Removed breaking wheelbarrow.flags.in_job
LoireLab b976bdf
finish_jobs_without_wheelbarrow function expanded
LoireLab 35f4800
Merge branch 'master' into multihaul
LoireLab f30d4b2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
multihaul | ||
========= | ||
|
||
.. dfhack-tool:: | ||
:summary: Haulers gather multiple nearby items when using wheelbarrows. | ||
:tags: fort productivity items stockpile | ||
|
||
This tool allows dwarves to collect several adjacent items at once when | ||
performing hauling jobs with a wheelbarrow. When enabled, new | ||
``StoreItemInStockpile`` jobs with wheelbarrows will automatically attach nearby items so | ||
they can be hauled in a single trip. Jobs without wheelbarrows would try to attach one if autowheelbarrows option is on. | ||
Items claimed by another jobs or already stored in stockpiles would be ignored. | ||
By default, up to ten additional items within 10 tiles of the original item are collected. | ||
Warning: Destination stockpile filters are currently ignored by the job (because of DF logic). Which items qualify can be controlled | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would be highly desirable for the tool to respect the stockpile settings. Can you elaborate on what the issue is? |
||
with the ``--mode`` option. | ||
Basic usage of wheelbarrows remains the same: dwarfs would use them only if hauling item is heavier than 75 | ||
|
||
Usage | ||
----- | ||
|
||
:: | ||
|
||
multihaul enable [<options>] | ||
multihaul disable | ||
multihaul status | ||
multihaul config [<options>] | ||
multihaul finish | ||
|
||
The script can also be enabled persistently with ``enable multihaul``. | ||
|
||
``multihaul finish`` cancels any ``StoreItemInStockpile`` jobs that have lost | ||
their wheelbarrows, freeing attached items. | ||
|
||
Options | ||
------- | ||
|
||
``--radius <tiles>`` | ||
Search this many tiles around the target item for additional items. Default | ||
is ``10``. | ||
``--max-items <count>`` | ||
Attach at most this many additional items to each hauling job. Default is | ||
``10``. | ||
``--mode <any|sametype|samesubtype|identical>`` | ||
Control which nearby items are attached. ``any`` collects any items nearby, even if they are not related to an original job item, | ||
``sametype`` only matches the item type (like STONE or WOOD), ``samesubtype`` requires type and | ||
subtype to match, and ``identical`` additionally matches material. The | ||
default is ``sametype``. | ||
``--autowheelbarrows <on|off|enable|disable>`` | ||
Automatically assign wheelbarrows to jobs that lack them. | ||
``--debug <on|off|enable|disable>`` | ||
Show debug messages via ``dfhack.gui.showAnnouncement`` when items are | ||
attached. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,329 @@ | ||
-- Allow haulers to pick up multiple nearby items when using wheelbarrows | ||
--@module = true | ||
--@enable = true | ||
|
||
local eventful = require('plugins.eventful') | ||
local utils = require('utils') | ||
local itemtools = reqscript('item') | ||
|
||
local GLOBAL_KEY = 'multihaul' | ||
|
||
local finish_jobs_without_wheelbarrow | ||
|
||
local function get_default_state() | ||
return { | ||
enabled=false, | ||
debug_enabled=false, | ||
radius=10, | ||
wheelbarrow_search_radius_k=5, | ||
max_items=10, | ||
mode='sametype', | ||
autowheelbarrows=true | ||
} | ||
end | ||
|
||
state = state or get_default_state() | ||
|
||
function isEnabled() | ||
return state.enabled | ||
end | ||
|
||
local function persist_state() | ||
dfhack.persistent.saveSiteData(GLOBAL_KEY, state) | ||
end | ||
|
||
local function load_state() | ||
state = get_default_state() | ||
utils.assign(state, dfhack.persistent.getSiteData(GLOBAL_KEY, state)) | ||
end | ||
|
||
local function for_each_item_in_radius(x, y, z, radius, fn) | ||
local xmin = math.max(0, x - radius) | ||
local xmax = math.min(df.global.world.map.x_count - 1, x + radius) | ||
local ymin = math.max(0, y - radius) | ||
local ymax = math.min(df.global.world.map.y_count - 1, y + radius) | ||
local bxmin, bxmax = math.floor(xmin/16), math.floor(xmax/16) | ||
local bymin, bymax = math.floor(ymin/16), math.floor(ymax/16) | ||
for by = bymin, bymax do | ||
for bx = bxmin, bxmax do | ||
local block = dfhack.maps.getTileBlock(bx*16, by*16, z) | ||
if block then | ||
for _, id in ipairs(block.items) do | ||
local item = df.item.find(id) | ||
if item and fn(item) then return end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
local function get_job_stockpile(job) | ||
local ref = dfhack.job.getGeneralRef(job, df.general_ref_type.BUILDING_HOLDER) | ||
return ref and df.building.find(ref.building_id) or nil | ||
end | ||
|
||
local function items_identical(a, b) | ||
return a:getType() == b:getType() and a:getSubtype() == b:getSubtype() and | ||
a.mat_type == b.mat_type and a.mat_index == b.mat_index | ||
end | ||
|
||
local function items_sametype(a, b) | ||
return a:getType() == b:getType() | ||
end | ||
|
||
local function items_samesubtype(a, b) | ||
return a:getType() == b:getType() and a:getSubtype() == b:getSubtype() | ||
end | ||
|
||
local match_fns = { | ||
any = function() return true end, | ||
identical = items_identical, | ||
sametype = items_sametype, | ||
samesubtype = items_samesubtype, | ||
} | ||
|
||
local function items_match(a, b) | ||
local fn = match_fns[state.mode] or match_fns.sametype | ||
return fn(a, b) | ||
end | ||
|
||
local function emptyContainedItems(wheelbarrow) | ||
local items = dfhack.items.getContainedItems(wheelbarrow) | ||
if #items == 0 then return end | ||
|
||
if state.debug_enabled then | ||
dfhack.gui.showAnnouncement('multihaul: emptying wheelbarrow', COLOR_CYAN) | ||
end | ||
|
||
for _, item in ipairs(items) do | ||
if item.flags.in_job then | ||
local job_ref = dfhack.items.getSpecificRef(item, df.specific_ref_type.JOB) | ||
if job_ref then | ||
dfhack.job.removeJob(job_ref.data.job) | ||
end | ||
end | ||
dfhack.items.moveToGround(item, wheelbarrow.pos) | ||
end | ||
finish_jobs_without_wheelbarrow() | ||
end | ||
|
||
local function add_nearby_items(job) | ||
if #job.items == 0 then return end | ||
|
||
local target = job.items[0].item | ||
if not target then return end | ||
local stockpile = get_job_stockpile(job) | ||
if not stockpile then return end | ||
local x,y,z = dfhack.items.getPosition(target) | ||
if not x then return end | ||
|
||
local cond = {} | ||
itemtools.condition_stockpiled(cond) | ||
local is_stockpiled = cond[1] | ||
|
||
local function matches(it) | ||
return items_match(it, target) | ||
end | ||
|
||
local count = 0 | ||
for_each_item_in_radius(x, y, z, state.radius, function(it) | ||
if it ~= target and not it.flags.in_job and it.flags.on_ground and | ||
not it:isWheelbarrow() and not dfhack.items.isRouteVehicle(it) and | ||
not is_stockpiled(it) and matches(it) then | ||
dfhack.job.attachJobItem(job, it, df.job_role_type.Hauled, -1, -1) | ||
count = count + 1 | ||
if state.debug_enabled then | ||
dfhack.gui.showAnnouncement( | ||
('multihaul: added %s to hauling job of %s'):format( | ||
dfhack.items.getDescription(it, 0), dfhack.items.getDescription(target, 0)), | ||
COLOR_CYAN) | ||
end | ||
if count >= state.max_items then return true end | ||
end | ||
end) | ||
end | ||
|
||
local function find_attached_wheelbarrow(job) | ||
for _, jitem in ipairs(job.items) do | ||
local item = jitem.item | ||
if item and item:isWheelbarrow() then | ||
if jitem.role ~= df.job_role_type.PushHaulVehicle then | ||
return 'badrole' | ||
end | ||
local ref = dfhack.items.getSpecificRef(item, df.specific_ref_type.JOB) | ||
if ref and ref.data.job == job then | ||
return item | ||
end | ||
end | ||
end | ||
return nil | ||
end | ||
|
||
local function find_free_wheelbarrow(stockpile) | ||
if not df.building_stockpilest:is_instance(stockpile) then return nil end | ||
local sx, sy, sz = stockpile.centerx, stockpile.centery, stockpile.z | ||
local found | ||
for_each_item_in_radius(sx, sy, sz, state.radius*state.wheelbarrow_search_radius_k or 10*state.wheelbarrow_search_radius_k, function(it) | ||
if it:isWheelbarrow() and not it.flags.in_job then | ||
found = it | ||
return true | ||
end | ||
end) | ||
return found | ||
end | ||
|
||
|
||
local function attach_free_wheelbarrow(job) | ||
local stockpile = get_job_stockpile(job) | ||
if not stockpile then return nil end | ||
local wheelbarrow = find_free_wheelbarrow(stockpile) | ||
if not wheelbarrow then return nil end | ||
if dfhack.job.attachJobItem(job, wheelbarrow, | ||
df.job_role_type.PushHaulVehicle, -1, -1) then | ||
if state.debug_enabled then | ||
dfhack.gui.showAnnouncement('multihaul: adding wheelbarrow to a job', COLOR_CYAN) | ||
end | ||
return wheelbarrow | ||
end | ||
end | ||
|
||
function finish_jobs_without_wheelbarrow() | ||
local count = 0 | ||
for _, job in utils.listpairs(df.global.world.jobs.list) do | ||
if job.job_type == df.job_type.StoreItemInStockpile and #job.items > 1 and not find_attached_wheelbarrow(job) then | ||
for _, jobitem in ipairs(job.items) do | ||
local item = jobitem.item | ||
if item and item.flags.in_job then | ||
local ref = dfhack.items.getSpecificRef(item, df.specific_ref_type.JOB) | ||
if ref and ref.data.job == job then | ||
dfhack.job.removeJob(job) | ||
end | ||
end | ||
end | ||
job.items:resize(0) | ||
job.completion_timer = 0 | ||
count = count + 1 | ||
end | ||
end | ||
if count > 0 then | ||
dfhack.gui.showAnnouncement('multihaul: clearing stuck hauling job', COLOR_CYAN) | ||
end | ||
end | ||
|
||
local function on_new_job(job) | ||
if job.job_type ~= df.job_type.StoreItemInStockpile then return end | ||
local wheelbarrow = find_attached_wheelbarrow(job) | ||
if wheelbarrow == 'badrole' then return | ||
end | ||
if not wheelbarrow and state.autowheelbarrows then | ||
wheelbarrow = attach_free_wheelbarrow(job) | ||
end | ||
if not wheelbarrow then return end | ||
add_nearby_items(job) | ||
emptyContainedItems(wheelbarrow) | ||
end | ||
|
||
local function enable(val) | ||
state.enabled = val | ||
if state.enabled then | ||
eventful.onJobInitiated[GLOBAL_KEY] = on_new_job | ||
else | ||
eventful.onJobInitiated[GLOBAL_KEY] = nil | ||
end | ||
persist_state() | ||
end | ||
|
||
if dfhack.internal.IN_TEST then | ||
unit_test_hooks = {on_new_job=on_new_job, enable=enable, | ||
load_state=load_state} | ||
end | ||
|
||
-- state change handler | ||
|
||
dfhack.onStateChange[GLOBAL_KEY] = function(sc) | ||
if sc == SC_MAP_UNLOADED then | ||
state.enabled = false | ||
eventful.onJobInitiated[GLOBAL_KEY] = nil | ||
return | ||
end | ||
if sc == SC_MAP_LOADED then | ||
load_state() | ||
end | ||
end | ||
|
||
if dfhack_flags.module then | ||
return | ||
end | ||
|
||
local args = {...} | ||
if dfhack_flags.enable then | ||
if dfhack_flags.enable_state then | ||
enable(true) | ||
else | ||
enable(false) | ||
end | ||
return | ||
end | ||
|
||
local function parse_options(start_idx) | ||
local i = start_idx | ||
while i <= #args do | ||
local a = args[i] | ||
if a == '--debug' then | ||
local m = args[i + 1] | ||
if m == 'off' or m == 'disable' then | ||
state.debug_enabled = false | ||
i = i + 1 | ||
else | ||
state.debug_enabled = true | ||
end | ||
elseif a == '--autowheelbarrows' then | ||
local m = args[i + 1] | ||
if m == 'on' or m == 'enable' then | ||
state.autowheelbarrows = true | ||
i = i + 1 | ||
elseif m == 'off' or m == 'disable' then | ||
state.autowheelbarrows = false | ||
i = i + 1 | ||
else | ||
qerror('invalid autowheelbarrows option: ' .. tostring(m)) | ||
end | ||
elseif a == '--radius' then | ||
i = i + 1 | ||
state.radius = tonumber(args[i]) or state.radius | ||
elseif a == '--max-items' then | ||
i = i + 1 | ||
state.max_items = tonumber(args[i]) or state.max_items | ||
elseif a == '--mode' then | ||
i = i + 1 | ||
local m = args[i] | ||
if m == 'any' or m == 'sametype' or m == 'samesubtype' or m == 'identical' then | ||
state.mode = m | ||
else | ||
qerror('invalid mode: ' .. tostring(m)) | ||
end | ||
end | ||
i = i + 1 | ||
end | ||
end | ||
|
||
local cmd = args[1] | ||
if cmd == 'enable' then | ||
parse_options(2) | ||
enable(true) | ||
elseif cmd == 'disable' then | ||
enable(false) | ||
elseif cmd == 'status' or not cmd then | ||
print((state.enabled and 'multihaul is enabled' or 'multihaul is disabled')) | ||
print(('radius=%d max-items=%d mode=%s autowheelbarrows=%s debug=%s') | ||
:format(state.radius, state.max_items, state.mode, state.autowheelbarrows and 'on' or 'off', state.debug_enabled and 'on' or 'off')) | ||
elseif cmd == 'config' then | ||
parse_options(2) | ||
persist_state() | ||
print(('multihaul config: radius=%d max-items=%d mode=%s autowheelbarrows=%s debug=%s') | ||
:format(state.radius, state.max_items, state.mode, state.autowheelbarrows and 'on' or 'off', state.debug_enabled and 'on' or 'off')) | ||
elseif cmd == 'unstuckjobs' then | ||
finish_jobs_without_wheelbarrow() | ||
else | ||
qerror('Usage: multihaul [enable|disable|status|config|unstuckjobs] [--radius N] [--max-items N] [--mode MODE] [--autowheelbarrows on|off] [--debug on|off]') | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this actually changes gameplay mechanics rather than just automating existing mechanics, I think this should be
gameplay
rather thanproductivity
.