Bay 12 Games Forum

Dwarf Fortress => DF Modding => Utilities and 3rd Party Applications => Topic started by: PatrikLundell on May 15, 2017, 08:31:23 am

Title: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on May 15, 2017, 08:31:23 am
This tool allows you to manipulate 3 region level features pre embark:
- Elevation (change region tile elevation)
- Biome (change region tile biome to any of the neighboring 9, including the local one)
- Change river course, elevation, and width. Elevation allows creation of aqueducts, gorges, and water falls.
- Change whether a river is a brook or a stream.
- Control the amount of water in the caverns. Only tested to a limited extent. This functionality also depends on other parameters
  having compatible values elsewhere, plus the RNG.
- Manipulation of Features (Adamantine Spires, Volcanoes, Magma Pools, Passages, and Pits). The set of manipulations is limited to what the author finds reasonable. Limited testing has shown that adding Passages and Pits can result in cave-ins and draining of cavern lakes.

Note: all of these manipulations, except the brook/river one, are temporary. They are lost when another region is brought into focus, and they are likewise lost when embarking again in the same region as a previous fortress. However, the manipulations in effect when a fortress is created get "frozen" onto the fortress. This presumably can cause issues for adventure mode.
Also, changing river courses is messy, and only vaguely understood by the author, but some spectacular things can be generated.
https://www.dropbox.com/s/lap5tapg8if9p62/regionmanipulator.lua?dl=0 Version 0.15 2020-02-15.
The script can also be found here:https://github.com/PatrikLundell/scripts/tree/own_scripts (https://github.com/PatrikLundell/scripts/tree/own_scripts)

The tool is a Lua script that's intended to be stored in <DF folder>\hack\scripts and then invoked from the DFHack console by typing "regionmanipulator" into the console.

Change log:
0.15: Updated for 0.47.01 changes. Should be backwards compatible.
0.14: Fixed bug in river editing.
0.13: Reworked the UI and added manipulation of Features.
0.12: Added printing of help screen to DFHack console.
0.11: Added display of river entry/exit directions.
0.10: Replaced control scheme with command keys instead of tabbing through edit fields. Added mask to help screen to mask DF UI.
0.9: Added cursor starting on embark rectangle and "see through" view of the native DF region underneath the UI.
0.8: Added control of cavern water. This functionality is tested to a very limited extent.
0.7: Added description of the Biome reference coding DF uses to the help screen.
0.6: Fixed edit fields being one character too small.
0.5: Added ability to change a brook to a stream and vice versa.
0.4: No functionality change, just a better widget implementation internally.
0.3: Changed the UI to resemble a form with fields.
0.2: Allowed elevations to be negative down to -999.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Amostubal on May 19, 2017, 12:08:04 pm
ptw. I downloaded it... because I wanted to play with it... lol aqueducts and gorges.... I like DEEP gorges... but I wanted to see what a natural aqueduct would look like... than mess it up.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on May 19, 2017, 01:23:58 pm
There aren't any natural aqueducts: you'll have to change the parameters to get those...
I would recommend messing around with the tool on a copy of your save first. Once you think you have something interesting, embark, look at it to seem how it didn't measure up to the expectations, delete the save (or just retire and try elsewhere) until you've gotten something you like. Then you bring in the save (keeping a copy so you can try when thing go south).

By the way: a really silly experiment:
I changed the center tile of a 3*3 embark to an elevation of 1. I ended up with a hole in the ground that went a bit down into the SMR (I'm not sure if the bottom was at the level of the bottom of the magma sea or one below that. There was even grass at the bottom...). All 3 caverns were exposed, with their floors forming bridges across the hole. The embark wagon was deposited at the floor of the first cavern...
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Amostubal on May 19, 2017, 01:39:29 pm
Yeah see crazy sites like that.... I'd like something insane line that... The question is, after playing around for a bit and saving, if you say return to the side in adventure mode, or re embark at the site... does all the changes of this script get reverted?
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on May 19, 2017, 02:29:39 pm
When it comes to adventure mode I can only guess.
My understanding of how DF handles regions and the embark level is that the region is generated based on some seed that hasn't been mapped yet whenever the region is loaded, which happens when you bring the pre embark cursor to a region or when an adventurer enters any of the 8 neighboring regions (I believe DF keeps 9 regions loaded, with fewer on edges and corners). When a region is generated, it's based on the seed, so it turns out the same every time (which is why the tool's changes have no lasting effect on the region).
The detailed (fortress or adventure) level is generated from seeds that are part of the region data (which I think are in turn generated from a seed, as per the above), together with the region data in effect at the time of generation (which can be modified by the tool prior to embark) provided the detailed level hasn't already been generated and saved (i.e. already been embarked upon or, I assume somehow been modified by an adventurer). For a fortress, returning to that fortress in fortress mode should return to the saved state. Similarly, an adventurer ought to visit the fortress in the state is was saved. However, I suspect performing region manipulation can have odd effects on an adventurer, such as e.g. flattening the region to say 3 lower than the region tile elevation was at the embark originally may result in an adventurer coming up on sheer drop for 3 levels at the embark boundary.

Embarking again at a different site within the same region as a previous fortress that did manipulate the region before embark starts with the region in the original state, only the effects on the detailed levels are frozen into the previous embark. If, for instance, you rerouted rivers, that won't be visible, as the region map shows the region as generated, and doesn't carry anything back up from the detailed level (if, in a vanilla game, you strip mined the center tile of a 3*3 embark down to the magma sea, the region would still show the level a generated for the region, not the one modified by the player).

I'm not quite sure if the rambling above makes complete sense...
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Amostubal on May 19, 2017, 02:39:29 pm
Understandable enough that I'm going to play with it sometime today or tomorrow.  I'll post the results!
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Greiger on May 19, 2017, 02:56:02 pm
Posting to watch, also downloading to try it out.  I miss the old style surface level pits that went down into the bottom of the map and this could crudely recreate something like that. 

And just to be a pedant, natural aqueducts and gorges did happen at one point. :D  It was a very short lived quickly fixed bug. Rivers could generate with vastly different elevations than the surrounding terrain causing something akin to aqueducts, thin strips of hollow elevated river.  I recall reports of supercanyons too, but I only saw the elevated rivers myself.  I assume this tool just recreates that behavior for the local tiles.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on May 21, 2017, 02:46:31 am
I wasn't aware of aqueducts having existed: it might have been before my time.
I can think of one way to easily get canyons and aqueducts through a bug, and that is to have rivers take their elevation from the world map elevation, rather than the region tile elevation.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Greiger on May 21, 2017, 03:06:31 am
It may have been, I sadly don't recall the exact year or version it happened with.  The bugs all kinda run together after a few years :)

Anyway just throwing out a 'it works great' for ya here.   

Just for information for folks around, it does not really do sheer cliffs when messing with elevations without rivers involved. It makes big mountains or big pits show up, and they are ramped and somewhat gradual like you see with steep hillsides in the normal game.  Though unlike the normal game make a pit deep enough (about 10 or 20 below surface level in my experience) it will indeed puncture and expose cavern layers.  Which is neat.  Though be warned that you might get some low fps for a bit after map loading doing that if you ended up digging out an underground pool or something, as the water will need to flow for a bit all at once to resettle.  Just so y'all know exactly what to expect after modifying terrain with the tool.  Still immensely useful for making the perfect embark.

Rivers will indeed create sheer canyons and old style bugged aqueducts though, and that's also neat.  Excellent work sir!

I wasn't aware of aqueducts having existed: it might have been before my time.
I can think of one way to easily get canyons and aqueducts through a bug, and that is to have rivers take their elevation from the world map elevation, rather than the region tile elevation.
Memory is foggy but I think the old bug was indeed caused by rivers using the wrong elevation info when generating.  That was probably it.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on May 21, 2017, 04:08:30 am
Thanks, Greiger. Getting feedback is always good.

Your caution as to what to expect is useful advice.

The tool doesn't really add anything that wasn't there, but provides a UI on top of the data DFHack has exposed. Since waterfalls and cliffs are oft requested features in the cookbook threads, it made sense to make it easier to make those yourself rather than asking someone else and/or pray to the RNG gods. It should also be mentioned that I've been influenced by the Dwarf Fortress Geological Survey http://www.bay12forums.com/smf/index.php?topic=164090.0 (http://www.bay12forums.com/smf/index.php?topic=164090.0) thread, stealing Japa's ideas (it's OK if they haven't been touched for a couple of months? ;) ). Japa is perfectly allowed to take them back when there's some spare time on that end...
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Amostubal on May 21, 2017, 11:44:02 am
I played with this a minute.  I was interested in your decision to block it from dropping a region below 0,  0 is generally 5 to 10 above the magma sea...  Nother interesting thing is that if a region drops through a ramp zone.... those ramps disappear completely, causing cavern 1 to crash apart.... also water is not guaranteed to stay inside of rivers or cavern layers.... they could very easily start flowing out of the zone all over the lowered zone... FPS 1 real fast, while an underground sea dumps into pit 50zs below.  interestingly I tested on an ocean tile... dropped it to 0, loaded, and the entire tile was already full of water and it leached through cavern layers until they was full... really low FPS but that was okay.  anyways... I wish the ramp issue could be fixed.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on May 21, 2017, 01:17:17 pm
The reason for not allowing elevations below 1 is that I thought they wouldn't work in one way or another, so if that assumption is incorrect it should be changed.

Unfortunatley, I can do nothing about ramps, as their removal or whatever is the result of DF applying the whacky elevation parameter entered into the RNG based embark generation. Those ramps don't exist until DF should generate them (and either removes them or fails to produce them at all) at the time of embark, so the tool knows nothing about their future existence state (it would require reverse engineering DF the embark generation logic, complete with RNG seed usage, to predict if you'd get such a problem).

I guess combining a river with an extremely low embark tile elevation might cause DF to fail to generate aqueduct walls where cavern floors get in the way.

Cutting away the walls of cavern lakes will of course cause them to empty into the shaft generated. Again, the tool does nothing to the generation itself, but only changes a few starting parameters for DF's embark generation. Silly parameters can lead to silly results.

Edit: Changed to version 0.2 and allowed elevations down to -999.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: krisslanza on May 23, 2017, 10:59:05 am
I'm gonna give this a try, since if I'm reading it right, I could flatten out some volcano embarks... messing with surface magma is fun, but the insane elevation levels for them 99% of the time, makes settling on a volcano a pretty unlikely affair.

Since I like aboveground settlements. I need my flat level ground to build on!
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Altaree on May 23, 2017, 03:17:07 pm
Wow! You really like messing around with the region lua.  I have been adding comments like this when I save your files so that if I ever add them to a personal github repo you are given credit.
Code: [Select]
--http://www.bay12forums.com/smf/index.php?topic=164136.0
--PatrikLundell
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: krisslanza on May 25, 2017, 12:15:27 am
This is probably a bad question to ask by this point but uh, how do I actually get this to run? I figure its using DFHack's console to run it, but I can't figure out how to add it to get DFHack to read it or anything....
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on May 25, 2017, 03:11:30 am
It's a Lua script that's meant to be saved in <DF folder>\hack\scripts (and if you're using e.g. the LNP the DF folder is inside the LNP folder). Once the file is in the scripts folder, the DFHack console can find it when you type "regionmanipulator" in the console window.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: krisslanza on May 25, 2017, 09:48:47 am
It's a Lua script that's meant to be saved in <DF folder>\hack\scripts (and if you're using e.g. the LNP the DF folder is inside the LNP folder). Once the file is in the scripts folder, the DFHack console can find it when you type "regionmanipulator" in the console window.

Ah thanks! I had the right idea, but I was looking up things and I thought I had to input, like, "lua -file "regionmanipulator" or something... when it was just having to type in regionmanipulator on its own.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on May 25, 2017, 09:57:24 am
I made the mistake of assuming everyone has been playing DF and using hack scripts for years... Thanks to your question I've updated the first page to provide some instructions.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on June 20, 2017, 02:57:09 pm
I've update the version to 0.3. There is no new functionality, but the UI has been reworked almost completely to use the widgets in ways that more resemble how they're supposed to be used (or at least how I think they're supposed to be used), using fields in a "form" rather than hot keys to bring up change dialogs.

Edit:
Updated to 0.4, which just is a better widget implementation internally, and no functionality changes.
Edit 2: Modified the script to contain a working version of the unused Grid:pan widget function (without updating the version number).

Edit 2:
Updated to 0.5, adding the ability to switch between brook and stream.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Fleeting Frames on June 27, 2017, 11:31:15 am
Hm, aqueducts are new to me.

(https://i.imgur.com/RE7oUD8.png)

Of note:
- Aqueducts will have their walls extend up, but this is only on the sides - the surface of River tiles will be at z-level above, though. Both override native trees. Also: The tree area is (https://i.imgur.com/qXGI3Jm.png), contrary to the green grass.

If you start with entire river being an aqueduct, it will be unrevealed as well, and that area will not have wild animals (probably due aboveground biomes not having any underground creatures) or visitors enter the map, even after you block all map edges elsewhere and discover the caverns and wall that off too, though it will become eligible area for cavern plants.

- The river elevation is determined at embark tile level, here.

- The aqueduct wall material is picked based on biome. While lower levels have sand and fire clay, this upper air biome of tundra (poor alligators (https://i.imgur.com/Ld1bu5r.png))has clay loam. No vegetation on these edge tiles, which is kind of odd, but could provide access to plants otherwise not present.
Surface stone pebbles extend into aqueducts as natural stone walls of that material, but such randomness is not given to air biomes. Still, could be your only source of flux on map.

- Impractical, but pretty(large image (https://i.imgur.com/oBrOBs4.png)). However, the hole was supposed to be at where rivers join, not in the corners of 4 tiles. Well, that's DF.

- Even with just aqueducts, layout of trees and and pools will change (minerals will remain the same, though).

Toying a pit more,
- with cavern-level pits the reverse of first occurs - fungiwood growing on "aboveground surfaces". Looking at deeeep river, first time seeing this symbol and colour being used: (https://i.imgur.com/u8gGYji.png)
(2z above Semi-molten rock wall with no floor above)

- It apparently can mess with minerals - lost magnetite on a tile that previously had it by increasing region elevation.

- First time seeing tunnel tube roots.
(https://i.imgur.com/NC49uL5.png)

The tunnel tube is entirely inside/dark/subterranean, but the Sandy Loam area spread from adjacent biome.

- it seems it picks the width of south/east entrance of river by the north/west width of river.

- If you create a gorge ending right above caverns, the lack of floor beneath tree trunks may reveal them - without even cutting them down. Doesn't seem to apply to all trees, though.

I imagine many of these things were discovered by others when testing, but didn't see anybody posting them.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on June 27, 2017, 02:34:11 pm
I haven't seen anything odd with aqueducts, but haven't looked at it extensively.

Interesting observation that pebbles can "grow" into full blocks.

Geo biomes are tied to world tiles, not region biomes. However, the application of a geo biome shears away "excess" soil layers based on elevation. At an elevation of 100, 10 levels of soil is allowed, and that is decreased by increasing elevation. This shearing "erodes" the soil levels from the top (learned that from "prospect" as I wrote the geo manipulator). This shouldn't affect magnetite, as it's a rock material, but shearing away soil may scramble the RNG used for geo generation. There's an "abundance" parameter in the geo structure that's only vaguely understood, but it's certainly the case that if the geo biome specifies e.g. 5 vein materials for a single Z rock layer that only has room for two veins, it's random which ones you get. I don't know if each level of the same layer is rolled independently or if there is some weighting that increases the likelihood for a vein that exists on a higher level to "extend" into a lower one, but I think there may be. 

I think you may over estimate the amount of interest there is in these tools: it's quite likely you and I together have made up 90% of the testing/playing around with them...
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Fleeting Frames on June 29, 2017, 07:46:15 pm
Neat. That elevation-soil erasing behaviour explains why I find less aquifers on higher z-levels.

Maybe - or maybe they're just relatively unknown. Vanilla purism aside, they vastly simplify getting some more difficult worldgen requests like flat volcano+river. (Btw, iirc there's a single parameter accessible from gui/gm-editor that turns a magma pipe into a volcano or vice-versa.)
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on June 30, 2017, 01:49:59 am
I've tried looking at "features", but it's a rather messy and tangled web. If I remember correctly, there are parameters that specify where features start and stop, and I speculate that there should be a parameter that controls the magma top level of pipes and volcanoes alike (finding it might allow the generation of somewhat erupting volcanoes...).
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Greiger on June 30, 2017, 02:21:15 am
I think you may over estimate the amount of interest there is in these tools: it's quite likely you and I together have made up 90% of the testing/playing around with them...
Just want to throw out there that I do like the tool quite a bit, but probably the biggest diffrence is that I don't really do anything extreme with it.  I primarily use it now to convert close embarks into perfect embarks with it's ability to add a river or mess with elevation.  Outside of my first few tests to see how it works, I don't really make big chasms or huge mountains or anything.

Most extreme thing I've done with it outside of the first few quick experiments was build a hilltop fortress with a deep river canyon in the middle of a forest.  It is still a valuable tool, because one would be very hard pressed to find that kind of terrain naturally.  I'm not certain it's even possible.

DDownside is that with relatively minor edits like mine there is little to report.  Everything either acts as expected, or is too subtle to notice.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on June 30, 2017, 03:01:39 am
Thanks Greiger,

Your type of usage is the targeted/intended one, with the extreme outlier cases just being things possible to do.
It's hard to know if a dearth of posts is caused by a lack of interest or a lack of problems and no enhancement suggestions.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Max™ on June 30, 2017, 07:07:53 am
I hate dropbox, it doesn't want to play nicely with my overkill combo of ublock and umatrix, despite allowing it enough freedom that any other site would work, it does not, mind tossing the script in code tags here?
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on June 30, 2017, 08:02:07 am
I don't mind, but the site does... It's too large (and it's the same with all my tools that are dropbox:ed. When things are small enough to fit directly on the site I prefer that option). I can zip it up and mail it to you if you want (provided you give me the address, of course).
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Max™ on June 30, 2017, 03:29:35 pm
Wait the lua is? Do you have a github?
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Fleeting Frames on June 30, 2017, 03:56:31 pm
It's not too large for pastebin, though (https://pastebin.com/kqJMfhxa).

My larger world gens go over post limit with the pre-set values as well.

@Greiger: As a high hill-large river - low area for fortress wall with a moat? Neat idea.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Max™ on June 30, 2017, 05:09:02 pm
Ahhh, thank you, and yeah that is a lot of lines for a post huh, is that the region manipulator though? It says biomemanipulator at the top.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Fleeting Frames on June 30, 2017, 10:40:24 pm
It is. Old one, 0.1 version, at that.

Can't hold all these manipulators/I'm such a derp.

Here you go. (https://pastebin.com/S4MCRhsN)
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Max™ on June 30, 2017, 11:53:18 pm
Ahhh, thank you, and here's to pastebin!
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on July 01, 2017, 02:25:50 pm
A minor update to 0.6. The bug fixed (incorrectly looking edit fields) only manifests itself with a potential future DFHack release where a bug in gui.lua is fixed (the bugs in this script are all my doing, though: the fields were actually one character too narrow as the prompt needs a character as well).
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Fleeting Frames on July 03, 2017, 11:01:42 am
More experiments:
Had a thought a bit ago: Cliffs are pretty common request. Could you use super-wide river for sheer one on one side + massive elevation differences on other side to prevent the cliff on other side?

Probs. (https://i.imgur.com/mVLZdIS.png). Set center and westward biome height tiles to 150, the one on left side is sheer cliff up to 150z for both NW and SW, the other one completely flat on NE 48x48 and slice of sloping mountain on SE 48x48.

Sharp-walled pits are obvious next sheer drop step (as, say, a way to simulate empty volcanoes on worlds without magma layer while still getting hfs), however a single point of river will generate river source in next tile over if it doesn't have a river in that direction. Circular rivers are pretty neat use that can also be used for moat-surrounded towers too (https://i.imgur.com/JvnXm3P.png), though needs luck combining them with low elevation on other side of river - 3x3 with high center might be workable.

This led to question of "what animals spawn on cavern that is aboveground on embark?" Aboveground ones, apparently (https://i.imgur.com/AM8udlc.png), though this cavern-low surface doesn't seem to qualify for caravan/visitor/not-attracted-migrants-this-season access
(Albeit visitors might be barred due having two more than half of map edge covered with water).
(https://i.imgur.com/rcuPJ6P.png)
(Though it is not completely non-weird. Can also get pond grabbers under the tentacles that reach to edges, which may be unsupported, potentially due tree growth, and cavein. Also, in this case the rivers fills in from side edges, though this loses out to drainage in case of wide rivers at least.)
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on July 03, 2017, 02:19:55 pm
Nice circular river!

When I've made a moat I've made it square (basically a bifurcating river on one side of the embark and joining branches on the other), so I've had a proper map entry and map exit.

Edit:
Updated to 0.7 2017-07-24. The only change is that the help now describes the Biome encoding.

Edit 2:
Updated to 0.8 2017-09-10. Added some control over the amount of water in the three caverns.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on November 19, 2017, 11:58:36 am
Updated to version 0.9, 2017-11-19:
- Starts the cursor at the "center" of the DF embark rectangle (rounded down), rather than at (0, 0). This does NOT mean the DF embark rectangle is moved when the tool is used, though: the next time the script is started it will again "center" at the rectangle.
- Added an "invisible" map mode that shows the native DF region underneath. This required reshuffling of the UI to align.

I've never been too happy with the edit field implementation, and I'm probably going to replace it with command keys that bring up edit boxes instead, unless there are loud protests. Anyway, making a separate release for this means there's an easy fallback point if I end up reverting the functionality.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Fleeting Frames on November 19, 2017, 09:28:38 pm
That's nice feature...PS: is it supposed to display the native df underneath on help?

(Albeit it says something that the interface is intuitive enough that I only now pressed it to seek the "display underneath" Alt-i & Alt-e key pairs.)
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on November 20, 2017, 04:12:33 am
Hm, no, that's a bug. I'll fix that as I switch to command keys.

Edit:
Updated to version 0.10, 2017-11-20:
- Added mask to help screen (thanks Fleeting Frames).
- Replaced the control scheme with command keys instead of tabbing through edit fields.

Edit 2:
Updated to version 0.11, 2017-12-14:
- Added display of river entry/exit directions.

Edit 3:
Updated to version 0.12 2017-12-14:
- Added ability to print help screen to the console window.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Jazz Cat on March 24, 2018, 04:19:39 pm
I don't know if this is helpful, but I just used Region Manipulator to add a river to my embark and it dried up pretty much instantly (although the tiles still showed up as "river" upon examination). I filled it back up with DFHack's "liquids" command and now there's pond turtles and stuff hanging out in it again.

Fantastic tool, by the way. This plus your biome manipulator are going to save me so many hours of headache, I'm sure.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on March 25, 2018, 03:58:55 am
When I've tested doing stupid things with rivers I've added rivers to the tiles outside the intended embark at the inlet and outlet to make sure there' somewhere water would come from and flow to, but I haven't actually played it, so I don't know if that prevents drying up.
The "proper" way to add a river to the future embark is to use Biome Manipulator to reroute a river into the region tile and then use Region Manipulator to shift the river to flow where you want it.
It's nice to hear pond turtles showed up, as I didn't know if "vermin" "fish" would show up.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Jazz Cat on March 25, 2018, 01:05:51 pm
Yeah, I figured that would be the way to do it - but the embark is right at the edge of the map, so there wasn't room to start it in the square outside the area, and the actual river was too far away.

By the way, how exactly does the river system work? Does the "east or west" key refer to the direction the water is flowing, or the direction the water is coming from? I somehow ended up with a river with three different "starts," one of which wasn't even on a tile I'd specified with a river, at some point in the process.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on March 25, 2018, 03:59:55 pm
How does the river stuff work... Well, I don't quite know. For the global info it's fairly straight forward: it follows the course of the river from the source to the sink. The region stuff is odd, however, as it doesn't seem to deal with the flow, but rather with connections. I have to fiddle with it a fair bit to get it to do what I want. In some instances you can create a bend in a river by specifying e.g. the tiles to the east to go to the west and the one to the south to go to the north and then nothing on the tile they join.
Basically, I do it with trial and error. Try something (starting with something sensible), look what I got, change things until it joins up the way I want it to, move on to the next segment...

It's possible to create an island by getting the river to bifurcate (i.e. split) with one leg going straight ahead and one going south, east, north to join up again, and it's also possible to get it to go in a loop such that the entry and exit touch, leaving an island in the middle with only a single break in the edge (i.e. two regions, rather than three).

The world map river sink can be outside of the map, by the way, but not the source, so you could create a new river that starts in the world map of your intended embark and then flows off the edge, and then have the source being off at the other end of the local map with your embark flush up to the world edge. You don't HAVE to do it that way, of course, but you can.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on August 01, 2018, 10:54:33 am
Update to version 0.13.
This is a rather substantial rework of existing functionality, plus the addition of Feature manipulation.
- The UI has been split over multiple pages, where each page provides a "graphics" display plus the associated functions, rather than having all functions crammed onto the page with the "graphics" being shifted.
- Made sure the UI can be used at 80 * 24, but some redundant display key info is provided for those who have the screen real estate for it.
- Split the Help over multiple pages.
- Changed a couple of key bindings (Flatten is now a "normal" key, while all cavern water changes share the same key (as the page provides a context for the key).
- Added limited manipulation of Features, allowing you to:
  -  lengthen/shrink Adamantine Spires and Magma Pools (to reach caverns further up down)
  - Move Adamantine Spires to the other DF legal tiles
  - Create (and delete) Volcanoes (I've tried to place two in an embark, and both showed up when embarking).
  - Create and delete Magma Pools, Passages, and Pits.
- As a side effect of Features, Sites are displayed, as they can block the placement of Features (a Volcano under a necro tower is probably not a good idea [for the necros]).

Note that some Feature manipulation can result in cave-ins and flooding (Pits and Passages), as this heavy handed manipulation doesn't know how to "prepare the ground" for features. Also, the testing has been quite limited: Performing manipulations, embarking, "reveal" to verify the expected changes have taken place, "die".
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: fonzacus on August 02, 2018, 10:17:45 pm
ah, thanks for pointing me in the right direction from the biomemanipulator thread. both tools are very nice to have for setting up ideal embarks, kudos.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: SpeardwarfErith on August 20, 2018, 04:56:38 pm
Messing around with this is really fun. Though it's probably not a secret, I'm really amused by the fact that lowering terrain elevation without messing around with the river results in a massive aqueduct fit for Armok himself.

(https://imgur.com/AiPAeQM.png)
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Jazz Cat on January 29, 2019, 12:19:20 am
I don't know if you're taking bug reports, but if you are, I'm getting some errors trying to edit the "river y max"  (as well as x and min).

Spoiler (click to show/hide)
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on January 29, 2019, 03:21:14 am
Thanks, yes, it turns out to be a bug. At a guess, the fields were named and I didn't test the changed fields everywhere when adapting to it.
I've fixed it and uploaded a new version ("river_vertical" and "river_horizontal" should be "rivers_vertical" and "rivers_horizontal", respectively).
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Jazz Cat on January 29, 2019, 02:49:06 pm
Awesome, thanks.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: DerMeister on September 16, 2019, 10:48:05 am
How make clown spires visible?
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on September 16, 2019, 01:12:37 pm
How make clown spires visible?
Sigh...
- See the first post of this thread to find out how to save the script in your DF copy.
- Type regionmanipulator in the DFHack console widow
- ? to bring up the help
- <TAB> to shift through the help screeens
- When you've read the "features" tab, escape out.
- alt-f to bring up the feature display. The cyan characters display candy spires. Read the label to understand the differences between the different characters.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: DerMeister on September 16, 2019, 01:55:59 pm
How make clown spires visible?
Sigh...
- See the first post of this thread to find out how to save the script in your DF copy.
- Type regionmanipulator in the DFHack console widow
- ? to bring up the help
- <TAB> to shift through the help screeens
- When you've read the "features" tab, escape out.
- alt-f to bring up the feature display. The cyan characters display candy spires. Read the label to understand the differences between the different characters.
hat about spire that is beneath dark fortress?
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on September 16, 2019, 02:21:05 pm
The overlay doesn't care whether there's a dark fortress on top of features or not. It shows the spires. It's your responsibility to make sure you look where you want to look, i.e. at a dark fortress and then bring up the overlay on top of that.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: DerMeister on September 16, 2019, 02:27:40 pm
The overlay doesn't care whether there's a dark fortress on top of features or not. It shows the spires. It's your responsibility to make sure you look where you want to look, i.e. at a dark fortress and then bring up the overlay on top of that.
I talk about underworld portal.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on September 16, 2019, 02:47:48 pm
The overlay doesn't care whether there's a dark fortress on top of features or not. It shows the spires. It's your responsibility to make sure you look where you want to look, i.e. at a dark fortress and then bring up the overlay on top of that.
I talk about underworld portal.
If you'd said that from the beginning this whole silly discussion could have been dealt with immediately. I'm not aware of any way to distinguish the portal spire from other spires apart from sending an adventurer to locate it in a copy of the world or embark with a 16*16 embark and use "reveal all" to show everything, locate the correct spire, and then embark again in a copy of the world at the desired place.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on February 15, 2020, 10:06:39 am
Updated to 0.15 to deal with minor 0.47.01 changes involving site display (under "features"). The changes should be backwards compatible.
Note that testing has been very limited.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Rekov on January 14, 2021, 01:01:48 pm
Is it possible with this tool, or with Biome Manipulator, to control where aquifers appear on an embark?
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on January 14, 2021, 02:34:52 pm
The Biome Manipulator allows you to change the geo biomes, allowing you to switch between non/aquifer bearing layers. I don't think it will have any effect if done after embarking, though.

The Region Manipulator allows you to change which World Tile each Mid Level Tile has as its geo biome reference, so by first changing the geo biome (if needed) and then changing the tile reference you can influence if you've got an aquifer or not (again, pre embark, but this tool has to be run immediately prior to embarking, without change of focus, or the changes will be reverted).

It's also possible to change the Drainage for a World Tile to determine whether the aquifers (if there are any) will be heavy or light (Drainage = 7, 27, 47, 67, and 87 result in heavy aquifers, with all others being light).

Post embark it's possible to hack individual tiles using gui/gm-editor, or use a script to perform the same actions.

Thus, you can get a coarse control over the aquifers with these tools, but need to write a script or use gui/gm-editor directly for fine control.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: A_Curious_Cat on January 14, 2021, 06:02:51 pm
This is a nice plugin.  The last time I used it, I used it to increase the number of soil layers (I did this by expanding one of the soil layers while contracting each of the less useful rock layers one at a time) and give me a sand layer.  Unfortunately, I think I may have forgotten to adjust something about the caverns because I hit the first cavern when I dug down into the first or second rock layer...
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on January 15, 2021, 05:09:00 am
You must have used the Biome Manipulator, not the Region Manipulator (this script [it's not a plugin]), as that's the one that allows you to manipulate the geo biome. However, that does not change the location of caverns, as far as I know.

The first cavern can be generated at a very shallow location, which is why I change the world gen parameters to give me more room above the first cavern in which to make my fortress (sometimes defeated by much of that space being taken up by aquifer containing rock layers).
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: A_Curious_Cat on January 17, 2021, 02:00:51 am
You must have used the Biome Manipulator, not the Region Manipulator (this script [it's not a plugin]), as that's the one that allows you to manipulate the geo biome. However, that does not change the location of caverns, as far as I know.

The first cavern can be generated at a very shallow location, which is why I change the world gen parameters to give me more room above the first cavern in which to make my fortress (sometimes defeated by much of that space being taken up by aquifer containing rock layers).

Biome Manipulator...
Region Manipulator...
Dwarf Manipulator...

Same thing!  :P
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on January 17, 2021, 04:55:50 am
If that the case, I think I'll give you some money by requesting you to transfer some to me :P
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Rekov on August 20, 2021, 10:45:58 am
Now in the correct thread...

I believe I have figured out exactly how water in caverns works. The tool tip is correct in that it has to do with the bits, but incorrect in its guess.

(https://i.imgur.com/b2bNQHQ.png)

Each bit corresponds with a cardinal orientation, with the '1' bit representing north, the '2' bit representing south, the '4' bit representing west, and the '8' bit representing east. When a bit is set to 1, there will be water at the corresponding border of the tile. When a bit is set to 0, there will be land.

I think (but haven't extensively tested) that the values generated by the base game always match up across tile borders. So if a tile has its '2'/south bit set to 1, the tile to the south of it will have its '1'/north bit set to 1 as well. Using Biome Manipulator, it is of course possible to create non-matching tiles, which results in a straight line between land and water at the tile boundary.

Here is a handy reference chart:
(https://i.imgur.com/PVahlHb.png)
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on August 20, 2021, 12:15:46 pm
Thanks Rekov, it now makes sense. You had me scratching my head quite a bit here... Addition of the image to provide the context helps a lot to understand what you refer to. Thanks for that!

That's some research that would be useful to document in the XML files, and I can see it could be useful as an embark search feature as well (I'm sure vjek, at least, would look for embarks without cavern water for challenges).

An interesting question then is to what extent existing tools can be carried over to DF after the Premium release...
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Rekov on August 20, 2021, 03:49:59 pm
I mostly wanted to figure this out because I like using region manipulator to add magma pools to the caverns sometimes. If you add a pool and there's water, it will often immediately start flowing over the magma, causing constant cave-in announcements and pauses.

Now I know how to manually edit the water away from and around magma pools. It could theoretically be done automatically by the script, too. Set the water on the tile with the pool to '0', and then edit the appropriate bits of the surrounding tiles so that they don't have water facing toward the pool either.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on August 20, 2021, 04:30:43 pm
It's always good to increase the knowledge about the underlying structure.

I don't like to add automatic work arounds for issues generated by manipulation, but I'm in favor of warning of issues, so the player can decide for itself if it wants it or not.
Since magma pipes are in the center if their tiles there's no need technically to modify surrounding tiles to get rid of the water influx, but you'd get straight edges. However, I would have thought magma/water conflicts would resolve themselves fairly quickly through the formation of obsidian fused to the magma pipe sheath, and depending on the depth, it would either block further contact between water and magma, or gradually get the pool to obsidianize over.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: Rekov on August 20, 2021, 05:27:22 pm
That makes sense. Part of the magic of these scripts is they let you do things that can't occur naturally in the game.

And you're right, it does resolve itself fairly quickly. The water covers the pool with obsidian and then the cave-ins stop.
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: ghostofferretpast on January 23, 2023, 07:36:43 pm
Does anyone know if this and the Biome Manipulator tools will be updated for DFhack .50?
Title: Re: Region Manipulator, a pre embark region manipulator
Post by: PatrikLundell on January 24, 2023, 03:47:54 am
The answer is essentially the same as the corresponding one for the Biome Manipulator:

http://www.bay12forums.com/smf/index.php?topic=164658.msg8449368#msg8449368 (http://www.bay12forums.com/smf/index.php?topic=164658.msg8449368#msg8449368)