Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Construct multiple z-levels [DFHack lua script] 1.33  (Read 10512 times)

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Construct multiple z-levels [DFHack lua script] 1.33
« on: September 23, 2017, 04:34:53 pm »

In last month Once, there was a 5x5 tower challenge idea. I mostly liked it, but got annoyed at how one-by-one building stairs and such is and never succeeded.

Thus, constructmultiz.lua

Save the code into /hack/scripts/constructmultiz.lua text file. If you want the indicator on lower right and proper designation detection after moving cursor in build menu, also get gui/indiator-screen. Then, add constructmultiz bind into onMapLoad_extra.init file to add keybinds to call it automatically.

What can you do with this?

You can take these materials, order 7 sets of furnishings, and then adjust how many you will build above

||

By either clicking to increment/decrement or by using Ctrl-A to set wholesale:

||

Then you can build 7 z-levels of tower in one go:

||

Remember to designate corners last so they'll get built first, and to leave a space for door:

||

And the tower is designated 7z in one go:

||

If you have things ordered and done in right order, it can also get built in one go:

||

Then you can simply do the same on first z-level with ordering the placement of furniture, add a door...

||

and remove the first hatch.

This, too, gets extended:

||

Overall result, lot quicker than doing it by default:

||



There are few caveats, imperfections, and probably undiscovered problems I didn't find though testing. As such, for now I consider this in BETA: Cover your ass with backups and pre-saves, just in case.

Some caveats/quirks:

1) While individual items can be made semi-easily made possible to pick in latest version, for ease of coding in 43.03 it currently uses same item type and material for building, in a way like workshops job work rather than construction ones do.
2) The exception to above would be cases of bucket, barrel, chain, mechanism, screw, pipe, anvil (but not weapon), where material is not checked (it could be, but it isn't).
3) As such, dwarves will pick the items closest to them at the moment they take the job.
4) As such, dwarves will pick items to build one-by-one and it's possible to have all 5 designated 10x upright spears to fail when you have only 20 spears in stock.

5) For pumps, the direction is rotated 180° on every z-level for ease of designating pump stacks.

||

Still have to have power connections, granted, so it's pretty eh.

6) Helptext isn't quite so verbose as this post:
Spoiler: constructmultiz help/? (click to show/hide)

7) It accomplishes on the fly calling with keybinds, and popup boxes with gui.dialogs

8) As you might surmise from the above, by default the keybinds don't work with falconne's automaterial's auto-mat select. In fact, in material choosing and construction menus, the indicator-screen hides itself in 2 seconds to allow those options to show.

I'd like if it could work together with that, but I'm not even sure where I can find if the auto-mat select is going to skip the material choices screen.

9) You might try to call constructmultiz 1 0 on a stockpile, civzone, etc. abstract. But this does not work at present and throws an error.

Calling "on" in this context means calling on the last building or construction section done, such as by default.

10) There's little safety checking before building.
If you designate something into a wall, nothing happens.
If you designate a building unapproachably into air, nobody will come and build it.
If you designate a stair on constructed floor, you build a stair on constructed floor.
If you designate a 1x7 farm plot with workshop in the middle, you get disconnected farm plot.

11) Have only tested in DFHack 43.03-r1, 43.05-r2 and 42.06-r1 and 44.09

12) It seems old/offloaded designation detection isn't quite perfect.

13) In expanded item menu while the screen is still yet up scrolling down will change cursor location; potentially placing it on another building.

Potential ideas for the future:

A) For all but 43.03, could use individual items.

B) Utilizing "Planning Mode" plugin to place/curate for quality.

C) Allow control over how specific the matching of things is.

 - - - 

D) Checking for minimap presence when rendering

E) Constructing in a line in any abritrary direction, working with cursor visually

F) Drawing buildings from burrows or selection; only building within a burrow.

G) Saving and loading settings.

H) Floodfill mode for building on designations

============

Changelog
Spoiler: 1.33 24.05.2020 (click to show/hide)
Spoiler: 1.3 30.03.2020 (click to show/hide)
Spoiler: 1.01 28.07.2018 (click to show/hide)
« Last Edit: May 23, 2020, 08:22:50 pm by Fleeting Frames »
Logged

Bearskie

  • Bay Watcher
  • Nyam nyam
    • View Profile
Re: Construct multiple z-levels [DFHack lua script] 1.0 beta
« Reply #1 on: September 23, 2017, 11:46:37 pm »

This will definitely be useful.

Golbolco

  • Bay Watcher
    • View Profile
Re: Construct multiple z-levels [DFHack lua script] 1.0 beta
« Reply #2 on: September 24, 2017, 12:05:52 am »

You are a hero.
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Construct multiple z-levels [DFHack lua script] 1.01 beta
« Reply #3 on: March 30, 2020, 07:38:43 am »

So I decided that while full 2.0 is a while away, I at the very least want script to work off designations when placed on one:

||

New version added to OP with old one put in wiki history - not on bay12, as the OP post length goes over 40000 character limit. The new one needs gui/indicator-screen for detecting designations after moving z-levels from entering build screen.

This is still fraction of the changes I want to do for proper versatility, but I don't know when I'll be writing that and there's been some interest, so posting this now.

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Construct multiple z-levels [DFHack lua script] 1.3
« Reply #4 on: March 30, 2020, 01:28:53 pm »

<3 script wizardry...

Not sure how i missed the indicator screen...

Also somewhat related to indicator screen (don't want to necro there) i've had "realtime adventurer" (which is just screen that is continuously pressing wait button) and an overlay that replaces the workshop when it's selected the class for that and example use case also an old image of another idea
« Last Edit: March 30, 2020, 01:39:31 pm by Warmist »
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Construct multiple z-levels [DFHack lua script] 1.3
« Reply #5 on: March 30, 2020, 02:46:15 pm »

The indicator screen is bit more advanced in home copy (1.64 instead of 1.21, mainly working towards abandoning the hotkey model but I'd understand and see it support other gui stuff than just framedscreen too), though mainly held back by not completely updating stuff I have floating around that use it.

Working backwards the links: at that image, I see I'm not the only one who noticed workshop jobs placing the items in last-placed building on tile of the job.

For the example use case, looks like you set up a trash-to-blocks workshop (hm no invalid materials, is that even possible) and very precise catapult/shotgun ...that throws all free items in nearby, say, trade depot 0,5s after being built? Well, the elegance of the first's setup is phenomenal, and I can definitely see the similarity to indicator-screen in it. Second is far more involved (and a little baffling), and seems make_frames is missing.

All three together suggest a possible novel way to transport goods, though leans into modding - on that note, ability to put them into existing save is major boon to attaching interest.

I've looked at the local dwarfmode.lua (seems the linked one covers few more movement keys) copy few times before, most recently when making this yet half-useless thing - no actual workshops, though; mainly making use of the utility functions and demonstrations with gui/mechanisms.
« Last Edit: March 30, 2020, 02:49:26 pm by Fleeting Frames »
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Construct multiple z-levels [DFHack lua script] 1.3
« Reply #6 on: March 31, 2020, 12:19:24 am »

The indicator screen is bit more advanced in home copy (1.64 instead of 1.21, mainly working towards abandoning the hotkey model but I'd understand and see it support other gui stuff than just framedscreen too), though mainly held back by not completely updating stuff I have floating around that use it.

Working backwards the links: at that image, I see I'm not the only one who noticed workshop jobs placing the items in last-placed building on tile of the job.

For the example use case, looks like you set up a trash-to-blocks workshop (hm no invalid materials, is that even possible) and very precise catapult/shotgun ...that throws all free items in nearby, say, trade depot 0,5s after being built? Well, the elegance of the first's setup is phenomenal, and I can definitely see the similarity to indicator-screen in it. Second is far more involved (and a little baffling), and seems make_frames is missing.

All three together suggest a possible novel way to transport goods, though leans into modding - on that note, ability to put them into existing save is major boon to attaching interest.

I've looked at the local dwarfmode.lua (seems the linked one covers few more movement keys) copy few times before, most recently when making this yet half-useless thing - no actual workshops, though; mainly making use of the utility functions and demonstrations with gui/mechanisms.

I'm a bit embarrassed by most of those as they are in various stages of incompleteness (and by commit dates - ancient). However e.g. the thing that flings stuff was an idea that (AFAIK) worked and was factorio like conveyor, but more dwarfy and idea was to make a full automated factory (with huge mechanical energy costs).

The make-frames is probably in either building-hacks or eventful and it just makes the building animate it's gear icon. General idea is if machine is powered, it add items into itself (just because later we'll use them) and then does something with them. The most annoying thing is RAWS modding and restarting each time after changes, it took most of the time.

Also with overlays I've had some corner cases where it almost behaves as normal but not quite. But i guess it's mostly with the sidebar overlay as it needs to disappear when not on the modded building.

Btw how do you track the time in that timeout interface?
« Last Edit: March 31, 2020, 12:21:23 am by Warmist »
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: Construct multiple z-levels [DFHack lua script] 1.3
« Reply #7 on: March 31, 2020, 05:50:52 am »

The one in CMZ that hides screen when selecting items? math.floor(df.global.enabler.fps) for 1 second. Wouldn't be entirely accurate unpaused, but this is paused. Then just checks every 10 frames after removing the screen from top to see if it is ok to place back. (Ultimately that interface should better permit other plugins in some other way such as pathching dwarfmonitor instead but that's for another day.)

Yeah like half the length of indicator-screen is corner cases; though I've evidently failed to cover quite all of them as the last issue notes in OP (I think I'll see about adding those additional "new" keys in gui/dwarfmode). Tbh, I'd have put in far less effort if I had known about dwarfmonitor having lua front I could put indicators in....Though there are several upsides to this approach, even outside of code itself what's with data-sharing and all functions being available.

You've worked on display cases before; at the very least that's now in - I wonder if those others will also get put in? Maybe not quite in that form, but still.

Yeah I gathered they were incomplete, but I grok the intruging ideas (and that elegance in smasher hnnng):

Flinger, factory-wise, it'd be great for mass-collecting stuff(maybe include stockpile check so one could quickly transport 1000 items in 1 tile without needing 1000 jobs), but that somewhat runs into the issue that we really only need mass workshops for needs, or to set up specific meals/boozes with stockpile links; it's a solution for a missing problem.

Hm, now that gives an idea: rotating hauling, when item is placed in Nth linked stockpile mod number of stockpiles for N items, as evenly distributing items is a pain normally. (Reverse of the flinger, where outputs from many, say, smelters would be placed onto 1 forge.)
« Last Edit: March 31, 2020, 05:52:23 am by Fleeting Frames »
Logged

Warmist

  • Bay Watcher
  • Master of unfinished jobs
    • View Profile
Re: Construct multiple z-levels [DFHack lua script] 1.3
« Reply #8 on: March 31, 2020, 06:05:16 am »

Yeah most of my "solutions" are for problems that do not exist or just an alternative (e.g. need massive amount of X to make Y simple stuff, then you would automate X and Y would just be simple workshop...)