Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Lua implementation of manipulator (DFHack script) [v0.7.4]  (Read 27415 times)

lethosor

  • Bay Watcher
    • View Profile
Lua implementation of manipulator (DFHack script) [v0.7.4]
« on: April 06, 2015, 07:26:05 pm »

Following some suggestions for the manipulator plugin that proved difficult to implement in C++, I've been working on a replacement script written in Lua. It currently implements most basic functionality of the manipulator plugin, although some (particularly more recent features like batch editing and custom professions) are not yet implemented:
Spoiler (click to show/hide)
Performance has improved recently - although this script isn't quite as fast as the plugin, performance shouldn't be a noticeable issue (see "Notes" below). There will usually be a small delay when the script starts, but CPU usage in general should be reasonable.

Usage:
* Download the latest release from GitHub
* Copy the "manipulator" folder from the archive to "hack/scripts/manipulator" in your DF folder.
* (Optional) Add a keybinding to dfhack.init (if you've already started DF, running this command in the DFHack console works as well):
Code: [Select]
keybinding add Alt-L@unitlist manipulator/main
(Alt-L can be changed to another key if you prefer.)
* On the unit list screen (u), press the key you bound to manipulator/main above or run manipulator/main in the DFHack console.

New features:
* Customizable columns: Columns can be added and edited in manipulator/columns.lua. (In fact, this is where the default columns are defined as well.) Columns can be reordered by pressing "C" in the main manipulator screen - their order persists until DF quits.
* The Shift key performs some additional functions in combination with the mouse - for example, reversing the skill sort order when clicking on grid headers and toggling an entire group of labors in the labor grid.

Manipulator plugin features already implemented:
* Basics (scrolling, labor modification) and most grid keybindings
* Viewing and zooming to units
* Sorting by skills
* Stable sort
* Batch edits

Manipulator plugin features not yet implemented:
* Sorting by column values
* Format options when editing unit names (e.g. including units' ages, professions, list positions)
* Custom professions

Possible features:
* Searching
* Saveable column layouts
* Allow columns to be defined in multiple scripts (for example, on a per-save basis or by dropping additional scripts into the hack/scripts/gui folder instead of editing manipulator-columns.lua)

Notes:
* This script requires DFHack 0.40.24-r2 or above.
* Bugs and feature requests can be reported in this thread or on the Github issue tracker
* This script makes use of a new C++ drawing API that isn't included in DFHack 0.40.24-r3 or earlier. If it is unavailable, this script will fall back to an alternative, slower implementation written in Lua. I've only noticed a 20% difference in speed on my machine, but performance should be better in future DFHack releases.
« Last Edit: February 25, 2016, 10:26:33 am by lethosor »
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.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Lua implementation of manipulator (DFHack script)
« Reply #1 on: April 08, 2015, 12:47:35 am »

Very neat, this is definitely one of my favorite plugins, I stopped bothering with therapist actually once I got used to manipulator.

Having more control with the script sounds cool, though I'm not sure fully where I'd apply it much beyond just sorting labors I rarely use to the right... hmmm, actually I wonder now if it would be possible to say... have one of the toggle sorting options move the labors with the most/highest skilled dorfs to the left?
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: Lua implementation of manipulator (DFHack script)
« Reply #2 on: April 08, 2015, 09:28:08 am »

Hm, I hadn't considered reordering the labor columns. The main issue with that is that the way the grid is cached assumes that the columns stay in a specific order, but there shouldn't be too much of a performance hit due to reordering columns if you don't do it constantly (for example, customizing the column layout externally shouldn't be a problem, but reordering columns in manipulator could be slow).
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.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: Lua implementation of manipulator (DFHack script)
« Reply #3 on: April 08, 2015, 09:52:22 pm »

Makes sense, I thought you meant reordering them actually but now I see you meant the ones like adding kills (neat!) to the display.
Logged

expwnent

  • Bay Watcher
    • View Profile
Re: Lua implementation of manipulator (DFHack script)
« Reply #4 on: April 09, 2015, 03:44:15 pm »

Posting to watch.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: Lua implementation of manipulator (DFHack script)
« Reply #5 on: April 16, 2015, 06:47:46 pm »

I grew a little tired of using the keyboard to edit column layouts, so columns can now be inserted, reordered, and removed with the mouse (in the "C" screen). I hope to make this possible in the main screen instead at some point, as well as making columns resizeable.
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.

lethosor

  • Bay Watcher
    • View Profile
Re: Lua implementation of manipulator (DFHack script)
« Reply #6 on: May 04, 2015, 03:59:41 pm »

I recently split this script into multiple files, so there is now a zip file available on GitHub containing all of the necessary files to be copied into hack/scripts (see the first post for details, if necessary).
Some recent changes:
* Units that are on fire are colored appropriately. (Note that changes made while manipulator is open, e.g. with gui/gm-editor, will not be reflected for the time being.)
* The cursor in the labor grid can be moved diagonally (1/3/7/9+Shift)
* < and > jump to the previous and next labor groups (like the manipulator plugin)
* Tooltips (of a sort) are displayed when hovering over grid headers:

« Last Edit: May 04, 2015, 04:07:32 pm by lethosor »
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.

lethosor

  • Bay Watcher
    • View Profile
Re: Lua implementation of manipulator (DFHack script) [v0.6]
« Reply #7 on: May 15, 2015, 06:43:37 pm »

I've bumped the version of this to v0.6 and posted a new archive on the GitHub releases page. There are a number of improvements in this version, including several performance-related improvements:
* Initializing the grid (which accounts for much of the script's load time) is now 60-75% faster due to using native functions provided by DFHack
* Code has been split into more files, some of which are loaded on demand instead of on startup, which should decrease load time as well
* Unit selections with the mouse can be extended, either with Shift+Left-click or right-click
* A basic (single or multiple-unit) menu has been added that allows editing units' names and enabling/disabling all labors. This does not yet support the formatting options from the manipulator plugin, unfortunately (e.g. including a unit's profession, age, etc. in their nickname)
* Clicking in the stress column next to a unit will open their thoughts and preferences screen
* A few display issues have been fixed (legendary animals no longer flash, professions/races of units without names should be placed properly)
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.

lethosor

  • Bay Watcher
    • View Profile
Re: Lua implementation of manipulator (DFHack script) [v0.6.1]
« Reply #8 on: May 21, 2015, 04:02:34 pm »

Version 0.6.1 is up with a few new features:
* Labor changes made in the current manipulator session can be displayed with "d" - newly-enabled labors are shown with a green background, and newly-disabled labors are shown with a red background:

  * These changes can be reverted (for one or more units) in the "edit" menu
* The "edit" menu now recognizes mouse input
* Load time has been improved again. (This involved removing a caching system that had become slower than not using a cache at all due to previous speed improvements.)

Edit: 0.6.2 contains a few minor changes:
* Units with skills greater than Legendary+5 should no longer cause issues
* gui/manipulator can now be invoked from the main fortress mode screen
« Last Edit: May 21, 2015, 07:09:13 pm by lethosor »
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.

lethosor

  • Bay Watcher
    • View Profile
Re: Lua implementation of manipulator (DFHack script) [v0.7.1]
« Reply #9 on: July 01, 2015, 09:25:44 am »

Tagged v0.7.1 - military dwarf rows are now colored in magenta (similar to the vanilla v-p-l menu), and a performance issue in large fortresses has been fixed.
This script is now in a separate repo for organizational purposes - new releases are available here.

v0.7.2 fixes a bug where renaming units wasn't updating the name column.
« Last Edit: July 01, 2015, 10:32:45 am by lethosor »
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.

lethosor

  • Bay Watcher
    • View Profile
Re: Lua implementation of manipulator (DFHack script) [v0.7.2]
« Reply #10 on: July 13, 2015, 10:29:11 pm »

I've started working on formatting options for custom nicknames/profession names. There aren't nearly as many options as the plugin yet, but adding more is fairly easy. One improvement over the plugin is that format options are colored differently in the input field:

Incidentally, all of those options can also be used as regular columns in the main manipulator screen. There are a few things that can still be improved with this - for example, the "short profession name" column header is far longer than the two-letter contents of that column.
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.

lethosor

  • Bay Watcher
    • View Profile
Re: Lua implementation of manipulator (DFHack script) [v0.7.3]
« Reply #11 on: February 24, 2016, 07:56:03 pm »

Bumped to 0.7.3 since v0.42 support is mostly complete. It should still work with 0.40.24, although I haven't tested it as extensively.

Based on sv-esk's recent changes to the manipulator plugin, this now supports editing labors of permanent residents/citizens of other races (whose labors can be edited in DF, anyway). There are also a lot of new columns and other changes that would have warranted a bump to v0.8.0 or above, if I had bothered to look at the complete logs before choosing a version number (oops).
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.

lethosor

  • Bay Watcher
    • View Profile
Re: Lua implementation of manipulator (DFHack script) [v0.7.4]
« Reply #12 on: February 25, 2016, 10:26:53 am »

v0.7.4 fixes an issue with the "view unit" key not working correctly.
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.

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: Lua implementation of manipulator (DFHack script) [v0.7.4]
« Reply #13 on: February 27, 2016, 02:18:56 am »

Is there an indicator of how many dwarves each labor has? I know DT has this feature, but it's been a year or so since I last used manipulator.
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

lethosor

  • Bay Watcher
    • View Profile
Re: Lua implementation of manipulator (DFHack script) [v0.7.4]
« Reply #14 on: February 27, 2016, 08:11:05 am »

The plugin doesn't have one, but I could add it to this script easily enough. Would adding the indicator to the text you see when hovering over a labor header be enough, or is there a better place to add it?
(Also, should it be the number of dwarves with the labor enabled, or the number with the corresponding skill?)
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.
Pages: [1] 2