Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: DFHack Plugin: Do Task Now for hauling and construction  (Read 545 times)

palenerd

  • Bay Watcher
    • View Profile
DFHack Plugin: Do Task Now for hauling and construction
« on: June 16, 2020, 03:02:15 pm »

I have written a small DFHack plugin that adds a "Do Task Now!" toggle to the jobs screen. This allows the user to designate any queued job as high priority, including hauling and construction jobs. No more waiting months for graves and slabs to be built while your fortress goes slowly insane! As long as a job is sitting in the jobs list, you can tell your dwarves to do it NOW, dammit!

The prompt will appear below the "j: View Job" option, as shown in the spoiler-ed image:

Spoiler (click to show/hide)

I originally wrote this as part of a larger plugin that would partially automate and prioritize corpse hauling, to combat the stress spiral sentient dead cause. While that project is a long way from publication-ready at present, I decided to release this as a stand-alone plugin since it is conceptually separate from the rest of the project, and I found I missed the feature when playing my non-development saves.

The plugin source and a 64-bit Linux and Windows binaries for DFHack 0.47.04-r1 can be found on my Github HERE
« Last Edit: June 19, 2020, 01:56:35 pm by palenerd »
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: DFHack Plugin: Do Task Now for hauling and construction
« Reply #1 on: June 16, 2020, 04:54:11 pm »

Nice to see someone new getting interested in hacking DF, and plugins at that!

Unfortunately, the rest I offer might depend on one's point of view.

A: I greatly like this concept - so much, that I wrote private lua copy myself some time ago >>. It's not really ready for its own thread...Because, "that project is a long way from publication-ready at present". Stuff like prioritizelast in this post (great for high-priority low-use stuff like architecture!), or setting flag periodically in an area for 1 to all types of job, or setting it for particular dwarves for particular jobs, or do-after-do-now flags, and so on....

B: Speaking of which, prioritizing corpse hauling can as simple as repeat -time 1 -timeUnits days -command [ priority -DumpItem ] -name DumpFast

PS: A picture in OP can be nice; even if I know it already looks something like this:

Spoiler (click to show/hide)

palenerd

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Do Task Now for hauling and construction
« Reply #2 on: June 16, 2020, 07:59:19 pm »

I realize it's a little silly to have a whole plugin for something this small, but I didn't see anything exactly like it posted here already (unless I seriously missed something, which is possible), so I figured I'd post it here while separating it out of my other project. I chose the plugin format over a script initially simply because I've never written a lua script before and I'm more comfortable working in C.

That script looks like it prioritizes dumping, but neither differentiates between item types nor suspends jobs with the wrong item type in order to free up space in the queue. Without those features the hauling dwarves will end up stressing themselves to insanity stumbling over sentient corpses while they haul off all the teeth first. It's even worse when they try to do it in a reanimating biome. I originally started the project because micromanaging the battlefield cleanup in a reanimating biome by hand was seriously aggravating my carpal tunnel syndrome.

You're right, a picture would have been good. I'll try to get one up a little bit later.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Do Task Now for hauling and construction
« Reply #3 on: June 16, 2020, 10:55:58 pm »

Sounds cool! By the way, I would recommend adding the plugin to the repository itself (rather than just attaching it as a file in a release). That allows people to browse the code without needing to download it, and would make it easier for people to clone your fork+branch and build it (since adding a plugin requires modifying plugins/CMakeLists.txt, and people would currently need to figure out how to do that themselves).

One other (very minor) thing that I noticed from the screenshot above: uicommon.h has some utilities for drawing "key: text"-style strings in a consistent way that might be useful.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

palenerd

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Do Task Now for hauling and construction
« Reply #4 on: June 17, 2020, 12:22:00 am »

It is in the repository itself; I just attached the source file for ease of access. Cloning and compiling should work just fine as long as you're in the right tag.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Do Task Now for hauling and construction
« Reply #5 on: June 17, 2020, 12:45:32 am »

Sure enough, apparently I forgot to look for recently-changed branches. Disregard.

One advantage of making this a plugin is that adding text to existing DF screens is a lot cleaner (there are more complicated ways that scripts can do that, e.g. the "extended-status" script, but they don't work on all screens). If we added this to DFHack, I'd probably make it a subcommand of the "tweak" plugin, since it fits pretty well with other minor UI tweaks there, although a standalone plugin is certainly easier to distribute.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

palenerd

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Do Task Now for hauling and construction
« Reply #6 on: June 18, 2020, 01:58:58 pm »

Awesome! I can put in the work to integrate it into the tweaks plugin sometime soon. Just in case, though, I give the dfhack developers the permission to integrate it in themselves (although I think that's already covered by the license?).

I just noticed your comment about the image and "key: text"-strings. Fleeting Frames's image is of his own script, not my plugin. I've added an image of my plugin to the op. Sorry for the confusion!
Logged

Broms

  • Bay Watcher
    • View Profile
Re: DFHack Plugin: Do Task Now for hauling and construction
« Reply #7 on: July 01, 2020, 09:21:09 am »

This plugin is amazing! I hope Toady implements this during the QOL changes.
Logged