v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

User:Vjek

From Dwarf Fortress Wiki
Revision as of 19:51, 28 June 2012 by Vjek (talk | contribs) (Vjek's DFHack Scripts)
Jump to navigation Jump to search

The Scripts

Scripts for Dwarf Fortress 34.10 with DFHack 34.10:
First, the links to the actual scripts...

brainwash

elevate_mental

elevate_physical

make_legendary

rejuvenate

armoks_blessing

So, how do these work? These .lua files linked above are scripts written in the Lua programming language. DFHack, as of at least 34.10, includes an interpreter that will parse and execute code written in Lua.
With each new release of DFHack, there are updated variables, functions and other changes to interface. As such, there will be a delay between new releases and when some of these scripts will work. However, feel free to modify any and all of the scripts as much as you wish. Let the code be free! Fly code, fly!

Now what does each script do? A good starting point!

Information about each script

brainwash

The brainwash script modifies the personality traits of a single dwarf to match an ideal personality. What ideal means will doubtless vary from person to person, but I created my ideal based on the goal that the dwarf would be as stable and reliable as possible.
An interesting result of my ideal personality values is that dwarves without clothing are remarkably resistant to tantrums. In fact, I had an entirely naked fort for many months, and while all the dwarves were at zero happiness, there were no tantrums, no fights, no deaths. So, brainwashing works on dwarves!
Modifying the script is straightforward, just adjust the values you wish by each personality trait. Subsequent adjustments will overwrite any previous adjustments, and you can adjust a dwarf as many times or as often as you wish, as far as I call tell.
You could also make a very "unstable" and "unreliable" dwarf by modifying the values in the script, which has all sorts of entertainment potential.

elevate_mental

This script will adjust all the mental attributes of a single dwarf from whatever they currently are to the value 2600. While 2600 is not the maximum, it's very high, and you'll find this is high enough for most common activities. To adjust this value, pass the new value to the script as an argument. For example: 'elevate_mental 2700' This script can also be used to LOWER all the mental attributes of a particular dwarf. Use 'elevate_mental 200' for example. Yes, I know, it's not really "elevating" if you're lowering a value, but meh, the name is the name, change it if you want.

elevate_physical

This script will adjust all the physical attributes of a single dwarf from whatever they currently are to the value 2600. This value can also be changed by passing an argument to the script such as 'elevate_physical 3000' to adjust them all to 3000 instead of 2600. As with the elevate_mental script, this script can also be used to LOWER all the physical attributes of a particular dwarf. . I have had the need to do this, for example, with pesky nobles who insist on beating the hell out of their fellow dwarves. Not so easy to beat someone with a strength of 10, now is it?! Hee hee.

make_legendary

This script will make a single dwarf legendary in either a single skill, a group of skills, or all skills. Skills are things like Carpentry, Mining, Dodging, Lying, and so forth. Each skill has a category or class, and those classes can be seen by passing the 'classes' argument to the script. Similarly, passing 'list' to the script will show all the available skills. Specifying a single skill such as 'make_legendary MINING' will make that single skill Legendary +5. Presto! You have a legendary miner, go forth, mine legendarily!
The classes are broken up into fairly predictable groups, the most common will be the 'Normal' class which includes all the non-military and non-social skills like Mining, Carpentry, Strand Extraction, Cheese Making, Furnace Operating, and so on. Using the script thusly 'make_legendary Normal' will make the selected dwarf legendary in ALL those skills.
Speaking of all, the 'all' argument will make your dwarf legendary in every single skill there is, including military, social, medical, and normal. 'make_legendary all' and voila, truly a dwarf of legends!

rejuvenate

I wrote this script while doing some very long term experiments without births or migrants, and didn't want my dwarves dying on me. It's very simple, it just checks to see if a dwarf is older than 20 years old, and if they are, it makes them 20 years old. It does not work on children. You can try to use it on children, it just won't do anything.

armoks_blessing

This script combines the previous scripts into one that affects all dwarves currently in play. If the script is executed without any arguments, it runs the equivalent of rejuvenate, elevate_physical, elevate_mental, and brainwash on all dwarves currently on the map. It will only rejuvenate dwarves 21 years or older.

If the script has been copied into /df_install_dir/hack/scripts/ , you'll see the following

[DFHack]# ls
...
scripts:
  armoks_blessing       - Adjust all attributes, personality, age and skills of all dwarves in play

Now running the script by itself

[DFHack]# armoks_blessing
No skillname supplied, no skills will be adjusted.  Pass argument 'list' to see a skill list, 'classes' to show skill classes, or use 'all' if you want all skills legendary.
Adjusting Nil Laruzol
Adjusting Sibrek Sarveshtangath
Adjusting Aban Oltarmörul
Adjusting Olon Kolakmam
Adjusting Edzul Isonzas
Adjusting Ast Mamotiden
Adjusting Doren Aranònul
[DFHack]#

I ran that on a new embark with just the starting seven. What it did:

-changed all the personality values to "an ideal", the specifics of which are in the code.
-adjusted all mental and physical attributes to 2600.
-reduced the age of all dwarves older than 20 to age 20.

The script will accept arguments. Use 'list' or 'classes' to see them, but the most common ones will be:

all
Normal
MilitaryDefense
MilitaryAttack
MINING
CARPENTRY
...

all - this makes all your dwarves legendary in all skills. All. Every single one. Normal - this makes your dwarves legendary in the common labour skills plus a few extras (exactly shown with 'list' ) MilitaryDefense - the defensive military skills (dodge, armor, shield) are all made legendary MilitaryAttack - the offensive military skills (weapons, fighting, biting, etc) are all made legendary. MINING - all dwarves are made into legendary miners.

Example:

[DFHack]# armoks_blessing CARPENTRY
Adjusting Nil Laruzol
nil is now a Legendary Carpenter
Adjusting Sibrek Sarveshtangath
sibrek is now a Legendary Carpenter
Adjusting Aban Oltarmörul
aban is now a Legendary Carpenter
Adjusting Olon Kolakmam
olon is now a Legendary Carpenter
Adjusting Edzul Isonzas
edzul is now a Legendary Carpenter
Adjusting Ast Mamotiden
ast is now a Legendary Carpenter
Adjusting Doren Aranònul
doren is now a Legendary Carpenter
[DFHack]#

Another example:

[DFHack]# armoks_blessing Normal
Adjusting Nil Laruzol
Skill Mining is type: Normal and is now Legendary for nil
...
Skill Wax Working is type: Normal and is now Legendary for nil
Adjusting Sibrek Sarveshtangath
Skill Mining is type: Normal and is now Legendary for sibrek
...
Skill Wax Working is type: Normal and is now Legendary for sibrek
Adjusting Aban Oltarmörul
Skill Mining is type: Normal and is now Legendary for aban
...
Skill Wax Working is type: Normal and is now Legendary for aban
Adjusting Olon Kolakmam
Skill Mining is type: Normal and is now Legendary for olon
...
Skill Wax Working is type: Normal and is now Legendary for olon
Adjusting Edzul Isonzas
Skill Mining is type: Normal and is now Legendary for edzul
...
Skill Wax Working is type: Normal and is now Legendary for edzul
Adjusting Ast Mamotiden
Skill Mining is type: Normal and is now Legendary for ast
...
Skill Wax Working is type: Normal and is now Legendary for ast
Adjusting Doren Aranònul
Skill Mining is type: Normal and is now Legendary for doren
...
Skill Wax Working is type: Normal and is now Legendary for doren
[DFHack]#

To reiterate: the previous scripts work on single dwarves, this one works on all the dwarves currently on the map. You should be REALLY REALLY sure you want to affect ALL YOUR DWARVES before you even copy this script into your /hack/scripts/ directory, and you should definitely have a backup/save ready in case you make changes you weren't expecting.

How do I install and use the scripts?

Installation

Happily, this is the easy part. Install Dwarf Fortress. Install DFHack. Copy the scripts into the /hack/scripts/ directory. That means you click on the link to the script, and save that file into that directory.
So, if you clicked on the rejuvenate link, for example, it would show you the rejuvenate.lua source code file. In your browser, save that page as, browse to your DF installation directory, browse to /hack/, browse to /scripts/ and save the file there.
If all went well, in the DFHack command line interface, if you use the 'ls' command, it will enumerate, near the bottom, all the scripts in the /hack/scripts/ directory. If rejuvenate shows up there, you're set!

Use

If you installed the .lua script files into /hack/scripts/, you can simply type the script name, without the .lua extension, and it will be executed/run.

Alternately, you can use the 'lua' command in DFHack, and specify the exact path to the script. For example, 'lua c:\dfhack_scripts\rejuvenate.lua' if you wanted to keep your scripts separate from the dfhack directory structure for some reason.

Arguments are options passed to the script when you call it. So, something like 'elevate_physical 2700' would pass the argument 2700 to the script elevate_physical when it runs. Similarly, as mentioned above, 'lua c:\dfhack_scripts\elevate_physical.lua 2700' would also work.

For those using the scripts (or DFHack) for the first time, I highly recommend you save (or save & copy/backup) your game before you use the scripts. It is easy to make changes you may not have intended to make, and having a backup in this case is a good idea.

Most of the scripts require a dwarf to be a target within the main DF interface. This means you pause the game, press 'k', and move the cursor so it is on top of the dwarf you want. If there are multiple dwarves on a single tile, whichever one is selected in the list is the target of the script. Once the target is selected, alt-tab to the DFHack command line interface, type in the name of the script (with any optional arguments) and press enter. If all goes well, your dwarf will be modified, you can unpause the game and continue.

Bugs?

I've never seen these scripts crash DF, but if they do, please PM me on the forums, or e-mail via the wiki. Note, for the moment, these scripts are meant for use with DF & DFHack 34.10 ONLY