Bay 12 Games Forum

Please login or register.

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

Author Topic: DFWall - a mass rewall/refloor utility  (Read 5908 times)

LordZabujca

  • Bay Watcher
    • View Profile
DFWall - a mass rewall/refloor utility
« on: April 11, 2008, 08:38:00 pm »

DFWall 0.916a

DFWall demos on DFMA:
1.  http://mkv25.net/dfma/movie-495-dfwalldemo  - the old rectangle rewalling demo (this function works quicker now), watch at the "Rate: 300" setting
2.  http://mkv25.net/dfma/movie-520-dfwalldemo2  - the new template construction demo, watch at the
"Rate: 200" setting

1. What is it?
A little script written in AHK (with a little side program in C used for creating a tile map) that automates construction.

2. How does it work?
By scanning certain pixels from the DF window and then using a map to make sense of the data.

3. How do I use it?
First lets assume that you've set everything up correctly - or are playing Dwarf Fortress in a window with all settings at default (under windows XP, with the default look of the windows). If you didn't (or aren't), the setup process is described later.

DFWall has two main functions:
I. Rectangle rewalling/reflooring
II. Pattern construction

I.
=================
Rectangle rewalling instructions (by Fedor)
Usage:
1. Type 'b', then 'C' to go to the wall/floor construction interface. Choose any type of construction and location, then select (but do not choose) a material type. With the material highlighted, hold down either Ctrl key and type a digit from 0-9, using the keys at the top of the keyboard and not the number pad. The program will visibly load your preference.
2. Return to the wall/floor construction interface, choose the appropriate construction type, and get to the selection of a location. Move the cursor (selector) to one corner of the rectangle you wish to fill with constructions. Hold down either Ctrl key, and use the arrows or numbers on the main keypad (not the number pad) to navigate to the opposite corner. Release Ctrl.
3. Hold down the letter used to build the construction type (f (for floors), w (for walls), etc.), type the number you used to select the material type, then release the letter.

The utility will now automatically build the constructions, one by one, until the rectangle is filled.
=================

Notes:
1. You can also use the ".", "," and "/" keys instead of a material number to access the special construction functions. For the full explaination scroll down to the 0.915->0.916 changelog.
2. The first tile constructed will always be determined by the menu you are in when you start the construction. While DFWall only supports mass rectangle construction of walls/floors you can use that fact to quickly build a single tile of pretty much anything using a specific material.
EXAMPLE: Lets say you want to build green glass boxes in your dwarves quarters. Your "build container" menu is probably filled with all kinds of bags making the selection of the box pretty tedious. Here's where DFWall steps in - save the green glass box like you would save any construction material (using ctrl+9 for instance) and now whenever you want to build a green glass box just go into the container placement menu and tell DFWall to build a 1x1 floor tile using the saved box (f+9 in this case). DFWall will then find it and place it for you. Do not try to build more than one tile of non supported constructions at a time because that will probably lead to strange behaviour.
3. Potentially usefull: "`" (show current dX and dY for the rectangle building option) and "CTRL+`" - (reset dX and dY - done automatically after building a rectangle)
(note: ` - the button on the left of "1")

II.
The second function is a bit more complicated, but still pretty simple. By pressing CTRL+q while in the "select where to build a floor" menu you tell DFWall to build according to a template contained in "template.dft" using the currently selected tile as the upper left corner. After that DFWall will carry out the instructions using whatever materials you have saved under the appropriate numbers. For example:

Template file contents:
3
3
_
111
121
11.
_
fff
fwf
fff

This will build one wall tile surrounded by floor tiles potentially made from something different than the wall. For instance, if you save "crystal glass block" under 1 and 2 everything will be built from crystal glass when you press CTRL+q. If you save "gold bars" under 2 and "granite" under 1 the floor will be made from granite while the wall will be made from gold. The lower right floor has "." instead of a number - that means using the first available material on the list.

Template file format:
The first line tells the width of the template (X)
The second line tells the height of the template (Y)
The first "_" has to be in the third line
X*Y map of which numbers will be chosen for the materials when building the (x,y) tile. "." can be used as "the first one available".
The second "_" has to be directly under the last line of the map
X*Y map of the actual constructions and their places

The whole thing is actually rather straightforward if you look at the example provided above and the one included in the zip.
The full list of available symbols for the construction map:

. - nothing

t - table (will not be built outdoors)
c - chair (will not be built outdoors)

s - statue
j - cage
v - restraint

f - floor
w - wall
R - ramp
U - up stairs
D - down stairs
X - up/down stairs
F - fortification

4. Okay, so - how do I set this thing up?

------------------------------------SETUP------------------------------------

To work DFWall needs a pregenerated map file for the tileset used by DF. The map file allows very quick identification of tiles, so you'll need to generate one for yourself, unless you still play in 640x300 windowed mode using the default curses tileset in which case you're in luck! I've included the map file for that. Otherwise here are the step by step instructions:

Step I: Run DFWall_MapMaker.exe.
Step II: Fire up your favorite image viewer and load the tileset file.
Step III: Find the coordinates for the upper leftmost pixel of the tileset being shown and the background colour (it'll probably be 0xFF00FF). Use your mouse pointer and the CTRL+m command to do it.
Step IV: Make appropriate changes to the DFWall_MapMaker.ini file and restart DFWall_MapMaker. You can get the correct values of TileWidth and TileHeight pretty easily using one of those methods:
- If the minimal intended resolution for the tileset is AxB, then TileWidth = A/80 and TileHeight = B/50
- TileWidth = (width of the tileset)/16, TileHeight = (height of the tileset)/16
- If the tileset has a full rectangle tile just count how wide and high it is (in pixels)
Step V: Select your favorite image viewer window with the tileset loaded. Press CTRL+1 ONCE - it WILL work, even if it won't notify you about it. Wait until the mapmaker tells you it's finished. Check the generated .dfm file for accuracy of the image to text processing.
Step VI: If unsatisfactory go back to Step IV. Otherwise select your favorite image viewer window again and press CTRL+2. Wait for the notification.

Congratulations! You've probably just generated a .dfm file for your tileset!

Important note: This map doesn't scale, so you will only be able to use it if you play in the TileWidth*80xTileHeight*50 resolution.

Now just edit the DFWall.ini and you're set. Most of the things inside are pretty self explainatory. Notes:
- XStart and YStart are the coordinates for the upper leftmost pixel of the actual game in the window. How to get them:
1. Open Dwarf Fortress
2. Press alt+prt scr
3. Open MS Paint
4. Paste
5. XStart and YStart are the coordinates of the pixel coloured red in this picture:
                   
- You may want to change PageDownButton (move the material selection screen by a whole page) and ScrollDownButton (scroll down the selection by one item) to what you actually use. Use this page for guidance.
- As long as you use the correct resolution it should be possible to use this utility in full screen, though I didn't try
- The colours are important. If you use a custom tileset there's a good chance that you have to change them. Use the ctrl+m tool of the mapmaker to find them. Here's an explaination of what each colour is:
1. SeparatorColour - the dominant colour of that vertical bar that separates the menus from the game view
2. BackgroundColour - the colour of the background in the construction menu
3. SelectedColour - if the material is selected all it's tiles have at least one pixel of this colour
4. NotSelectedColour - if the material isn't selected all it's tiles have at least one pixel of this colour

0.915 -> 0.916 changes:
1. A significant bug in the "local colours" feature in the mapmaker was fixed.
2. The default ini settings were changed to work on a larger number of computers without making any changes.
3. Added an ini setting to make DFWall stop rewalling if it can't find an appropriate material (MAY BE BUGGY - OFF by default).
4. New features implemented:
- CTRL+. - use this to save what a nine and an empty tile looks like in your tileset. USAGE: select any material with at least 90 units and press this key combination. If you don't have any such material you can select any other material instead, but if you don't do that then the third of the new features below will not work correctly.
- / - use this insead of a material number to tell DFWall to use ANY material for rectangle rewalling.
- . - use this insead of a material number to tell DFWall to use any material with more than 9 units for rectangle rewalling.
- , - use this insead of a material number to tell DFWall to use any material with more than 99 units for rectangle rewalling.

0.916 -> 0.916a changes:
Fixed the "stop rewalling on error" feature not respecting its ini setting.

[ May 19, 2008: Message edited by: LordZabujca ]

Logged

Mlittle

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #1 on: April 12, 2008, 07:11:00 am »

Sounds interesting, but could you please upload it to Dwarf Fortress File Depo. Thanks.
Logged
With the final words said, the little bearded loony goes back into his cave.

LordZabujca

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #2 on: April 12, 2008, 11:38:00 am »

I would, but apparently DFFD hates me - it kept refusing to send me the account activation email... until I've told it to reset the password, after which I got the activation email, but now it won't send me the new password. For maximum annoyance I'll probably get this password reset email either 5 seconds after sending this post, or not at all. Yay. (EDIT: Finally got it. I'll upload DFWall in a minute.)

Also, I figured a mass rewalling/reflooring utility would generate a little more interest, especially considering THIS. Oh well.

[ April 12, 2008: Message edited by: LordZabujca ]

Logged

Tahin

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #3 on: April 12, 2008, 12:54:00 pm »

Nice. I'm going to try this at some point.
Logged

Istrian

  • Bay Watcher
  • Malevolent Manager
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #4 on: April 12, 2008, 06:25:00 pm »

Definitely useful. However, you might wish to change the title of this thread to something containing "mass rewall utility" or people might not notice it exists.
Logged

LordZabujca

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #5 on: April 13, 2008, 05:35:00 am »

Done.

See? A little feedback and I was able to make improvements already  :) .

Logged

LordZabujca

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #6 on: April 23, 2008, 03:32:00 pm »

DFWall 0.91 is up.

Major changes:
1. Krazy changes to the interface, with a capital "K"
2. Template construction

Comments would be appreciated.

[ April 23, 2008: Message edited by: LordZabujca ]

Logged

Deon

  • Bay Watcher
  • 💀 💀 💀 💀 💀
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #7 on: April 23, 2008, 06:07:00 pm »

What if I play with square tileset?
Should I wait to the end of notification (it's done) in the opened graphical editor, or can I switch to another window?
What should I edit in .ini? Just x/y positions?
Logged
▬(ஜ۩۞۩ஜ)▬
✫ DF Wanderer ✫ - the adventure mode crafting and tweaks
✫ Cartographer's Lounge ✫ - a custom worldgen repository

LordZabujca

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #8 on: April 23, 2008, 08:14:00 pm »

1. It should work with any tileset provided that the tileset doesn't do anything particularily funky with the representation of letters (like, say, having more than one letter tile look exactly the same, only with different colours). You do need to setup your DF window resolution correctly though.
2. You should wait, since the scanning process scans the active window. You can imagine the consequences of changing that in the middle of a scan.
3. As for what to change in the ini, well - you also need to change the width and height of a tile (and also the width and height of the tileset file in tiles in the MapMaker ini). Other than that (and the obvious, like the button config - look at PageDownButton and ScrollDownButton in particular), no. You can mess with CompareDepth and PageDownCheckDelay to gain better performance, but if you set the first one too low you can get false positives on comparing, say, "granite" and "green glass blocks" (CompareDepth set to 2 makes DFWall see both as "gr"), and if you set the second one too low you can expect to see holes in your mass constructions.

[ April 23, 2008: Message edited by: LordZabujca ]

Logged

Lyrax

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #9 on: April 25, 2008, 11:38:00 pm »

Ummmmm.... YES?

H*** YES?

WHERE... there's my caps lock.  Where do I download it?

Logged
Witty

Comedian
Dabbling Pacifier
Dabbling Judge of Intent
Skilled Forum Poster

LordZabujca

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #10 on: April 26, 2008, 04:29:00 am »

There's a link at the top of the OP that leads here:  http://dffd.wimbli.com/file.php?id=108
Logged

Tahin

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #11 on: April 30, 2008, 11:12:00 pm »

I finally got around to checking this out, and I have to say that this is absolutely amazing. The only thing I'd like to see is if it could possibly detect somehow if you ran out of material partway through the construction and stop it, and also if it could allow for the use of multiple materials (For instance, if I don't really care which wood it uses for a wall. Not sure how this would be done.)

I love it.

EDIT: Woah, wait... It's not appearing to correctly pick which material I want... It's just choosing the nearest one, I think. Huh.

[ May 01, 2008: Message edited by: Tahin ]

Logged

LordZabujca

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #12 on: May 01, 2008, 02:43:00 am »

That is strange. I've been using this script for some time to do all my constructions and I've never noticed it doing that - the whole point of this utility is to build using the same material every time. It should work exactly as in those movies up there.

What version are you using? Is it properly configured? What is your tileset? I know of a bug in 0.91 when your selected material is the last on a page - in fact I've just fixed it and I'll be posting in an update (after I upgrade the interface a bit). Maybe that's what's wrong?

Can has DFWall.ini settings + a screenshot of your whole DF window? Are you building from a template, or simply making a rectangle?

EDIT: The new version is up. Changes:
1. Made the interface a bit more reasonable (no more conflicts with the manager screen, yay!)
2. Material selection bug fixed.

[ May 01, 2008: Message edited by: LordZabujca ]

Logged

MickEfinn

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #13 on: May 01, 2008, 06:38:00 am »

Excellent, no more(read somewhat less) carpel tunnel walling. And flooring. And statuing.

Kudos good sir/ma'am.

Logged

Tahin

  • Bay Watcher
    • View Profile
Re: DFWall - a mass rewall/refloor utility
« Reply #14 on: May 01, 2008, 11:38:00 am »

I'll explain exactly what I did, tell me what I'm doing wrong:

1. I unzipped DF and created a new world, fresh install. I only changed the init file to turn off music and the intro and to make it start in windowed mode. Oh, and I set the population really low. Then I opened DF and started generating a pocket world. I used the 640 by 300 font, which is what DFWall seems to by calibrated to.

2. I unzipped and ran DFWall, the icon appeared in my system tray.

3. I started a fort in a heavily forested area (Oh yeah, should I mention that I was playing as humans modified to use the dwarf characters?).

4. I told my woodcutter to cut down a bunch of trees.

5. Then I went into my build menu, constructions, wall, placed it, chose a material (I believe it was pine) and pressed ctrl+1 as you said to.

6. I then backed out to the point where you choose the corners and, much to my dismay, found that ctrl+numpad doesn't work. I used the arrow keys instead of move to the other corner and released ctrl.

7. I then pressed shift+1 and it placed walls in the area I told it to.

8. I unpaused and watched my carpenter go and build the wall.

9. When I checked the walls using [k], they were made out of all kinds of wood.

What did I do wrong? It didn't have to do with my playing as humans, did it?

Logged
Pages: [1] 2 3 ... 5