Skip to content

Commit

Permalink
get assign-minecarts working
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed May 30, 2023
1 parent a26e72b commit 02c0031
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
27 changes: 4 additions & 23 deletions assign-minecarts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,12 @@
--@ module = true

local argparse = require('argparse')
local quickfort = reqscript('quickfort')

-- ensures the list of available minecarts has been calculated by the game
local function refresh_ui_hauling_vehicles()
local qfdata
if #df.global.plotinfo.hauling.routes > 0 then
-- if there is an existing route, move to the vehicle screen and back
-- out to force the game to scan for assignable minecarts
qfdata = 'hv^^'
else
-- if no current routes, create a route, move to the vehicle screen,
-- back out, and remove the route. The extra "px" is in the string in
-- case the user has the confirm plugin enabled. "p" pauses the plugin
-- and "x" retries the route deletion.
qfdata = 'hrv^xpx^'
end
quickfort.apply_blueprint{mode='config', data=qfdata}
end

function get_free_vehicles()
refresh_ui_hauling_vehicles()
local free_vehicles = {}
for _,minecart in ipairs(df.global.plotinfo.hauling.vehicles) do
if minecart and minecart.route_id == -1 then
table.insert(free_vehicles, minecart)
for _,vehicle in ipairs(df.global.world.vehicles.active) do
if vehicle and vehicle.route_id == -1 then
table.insert(free_vehicles, vehicle)
end
end
return free_vehicles
Expand Down Expand Up @@ -136,7 +117,7 @@ local function all(quiet)
end
end

local function do_help()
local function do_help(_)
print(dfhack.script_help())
end

Expand Down
7 changes: 4 additions & 3 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ that repo.

## New Scripts
- `diplomacy`: view or alter diplomatic relationships
- `exportlegends`: reinstated: export extended legends information for external browsing
- `modtools/create-item`: reinstated: commandline and API interface for creating items
- `light-aquifers-only`: reinstated: convert heavy aquifers to light
- `exportlegends`: (reinstated\) export extended legends information for external browsing
- `modtools/create-item`: (reinstated) commandline and API interface for creating items
- `light-aquifers-only`: (reinstated) convert heavy aquifers to light
- `necronomicon`: search fort for items containing the secrets of life and death
- `fix/stuck-instruments`: fix instruments that are attached to invalid jobs, making them unusable
- `gui/mod-manager`: automatically restore your list of active mods when generating new worlds
- `gui/autodump`: point and click item teleportation and destruction interface
- `gui/sandbox`: creation interface for units, trees, and items
- `assign-minecarts`: (reinstated) quickly assign minecarts to hauling routes

## Fixes
- `quickfort`: properly allow dwarves to smooth, engrave, and carve beneath passable tiles of buildings
Expand Down
6 changes: 3 additions & 3 deletions docs/assign-minecarts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ assign-minecarts

.. dfhack-tool::
:summary: Assign minecarts to hauling routes.
:tags: unavailable fort productivity
:tags: fort productivity

This script allows you to assign minecarts to hauling routes without having to
use the in-game interface.
This script allows you to quickly assign minecarts to hauling routes without
having to go through the in-game interface.

Note that a hauling route must have at least one stop defined before a minecart
can be assigned to it.
Expand Down

0 comments on commit 02c0031

Please sign in to comment.