Skip to content

Commit

Permalink
Merge pull request #1186 from myk002/myk_logistics
Browse files Browse the repository at this point in the history
[quickfort] support autoforbid and autoclaim
  • Loading branch information
myk002 authored Jun 15, 2024
2 parents e339572 + f3070c8 commit 33eb4df
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 26 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Template for new versions:
- `gui/unit-info-viewer`: add precise unit size in cc (cubic centimeters) for comparison against the wiki values. you can set your preferred number format for large numbers like this in the preferences of `control-panel` or `gui/control-panel`
- `gui/quickfort`: delete blueprints from the blueprint load dialog
- `quickfort`: new ``delete`` command for deleting player-owned blueprints (library and mod-added blueprints cannot be deleted)
- `quickfort`: support enabling `logistics` features for autoforbid and autoclaim on stockpiles
- `gui/quickfort`: allow farm plots, dirt roads, and paved roads to be designated around partial obstructions without callling it an error, matching vanilla behavior
- `gui/launcher`: refresh default tag filter when mortal mode is toggled in `gui/control-panel` so changes to which tools autocomplete take effect immediately
- `gui/civ-alert`: you can now register multiple burrows as civilian alert safe spaces
Expand Down
42 changes: 16 additions & 26 deletions internal/quickfort/place.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ local function make_db_entry(keys)
return db_entry
end

local logistics_props = {
'automelt',
'autotrade',
'autodump',
'autotrain',
'autoforbid',
'autoclaim',
}

local function custom_stockpile(_, keys)
local token_and_label, props, adjustments = parse_keys(keys)
local db_entry = make_db_entry(token_and_label.token)
Expand All @@ -176,21 +185,11 @@ local function custom_stockpile(_, keys)
end

-- logistics properties
if props.automelt == 'true' then
db_entry.logistics.automelt = true
props.automelt = nil
end
if props.autotrade == 'true' then
db_entry.logistics.autotrade = true
props.autotrade = nil
end
if props.autodump == 'true' then
db_entry.logistics.autodump = true
props.autodump = nil
end
if props.autotrain == 'true' then
db_entry.logistics.autotrain = true
props.autotrain = nil
for _, logistics_prop in ipairs(logistics_props) do
if props[logistics_prop] == 'true' then
db_entry.logistics[logistics_prop] = true
props[logistics_prop] = nil
end
end

-- convert from older parsing style to properties
Expand Down Expand Up @@ -324,17 +323,8 @@ local function create_stockpile(s, link_data, dry_run)
end
if next(db_entry.logistics) then
local logistics_command = {'logistics', 'add', '-s', tostring(bld.stockpile_number)}
if db_entry.logistics.automelt then
table.insert(logistics_command, 'melt')
end
if db_entry.logistics.autotrade then
table.insert(logistics_command, 'trade')
end
if db_entry.logistics.autodump then
table.insert(logistics_command, 'dump')
end
if db_entry.logistics.autotrain then
table.insert(logistics_command, 'train')
for logistics_prop in pairs(db_entry.logistics) do
table.insert(logistics_command, logistics_prop:sub(5))
end
log('running logistics command: "%s"', table.concat(logistics_command, ' '))
dfhack.run_command(logistics_command)
Expand Down

0 comments on commit 33eb4df

Please sign in to comment.