### Reset and Assign Attributes Example Source: https://github.com/dfhack/scripts/blob/master/docs/assign-attributes.rst This example demonstrates resetting all attributes to tier 0 and then setting Strength to tier 2, Agility to tier -1, and Spatial Sense to tier -1. The exact numerical ranges for these tiers depend on the unit's race. ```bash assign-attributes --reset --attributes [ STRENGTH 2 AGILITY -1 SPATIAL_SENSE -1 ] ``` -------------------------------- ### Configure Auto-Start Tools Source: https://github.com/dfhack/scripts/blob/master/docs/control-panel.rst Configure tools to automatically start when a new fortress is initialized. This can be for tools that are enabled or commands that run once. ```bash control-panel autostart|noautostart ``` ```bash control-panel autostart autofarm ``` ```bash control-panel autostart fix/blood-del ``` -------------------------------- ### Start Interactive Lua Interpreter Source: https://github.com/dfhack/scripts/blob/master/docs/lua.rst Launches an interactive Lua interpreter. Type 'quit' to exit. ```bash lua ``` -------------------------------- ### Enable change-build-menu Ticker Source: https://github.com/dfhack/scripts/blob/master/docs/modtools/change-build-menu.rst Start the change-build-menu ticker to enable modifications to the build sidebar. This must be done before any changes take effect. ```bash enable modtools/change-build-menu ``` -------------------------------- ### Create a new god with SPEECH, SALT, SACRIFICE spheres (neuter emu) Source: https://github.com/dfhack/scripts/blob/master/docs/modtools/moddable-gods.rst This example demonstrates creating a god with specific spheres, a genderless (neuter) attribute, and a unique depiction as an emu. This allows for highly customized deity creation. ```bash moddable-gods -n Og -s SPEECH,SALT,SACRIFICE -g neuter -d emu ``` -------------------------------- ### Item Script API: Execute Example Source: https://github.com/dfhack/scripts/blob/master/docs/item.rst Demonstrates how to use the item script API to find and modify items. Use this to reveal or hide items based on conditions. ```lua local itemtools = reqscript('item') local cond = {} itemtools.condition_type(cond, "BOULDER") itemtools.execute('unhide', cond, {}) -- reveal all boulders itemtools.condition_stockpiled(cond, { negate = true }) itemtools.execute('hide', cond, {}) -- hide all boulders not in stockpiles ``` -------------------------------- ### Apply Dig Blueprint with Table Data Source: https://github.com/dfhack/scripts/blob/master/docs/quickfort.rst This example shows how to apply a dig blueprint using a nested table structure for data, specifying an exact starting coordinate (x=30, y=40, z=50). This method is useful for precise placement. ```lua -- dig a 10x10 block starting at coordinate x=30, y=40, z=50 quickfort.apply_blueprint{mode='dig', data={[50]={[40]={[30]='d(10x10)'}}}} ``` -------------------------------- ### Quickfort Transformations Source: https://github.com/dfhack/scripts/blob/master/docs/quickfort.rst Illustrates the available geometric transformations that can be applied to blueprints before they are modified on the game map. These transformations are anchored at the blueprint start cursor position. ```bash quickfort orders -t rotcw ``` ```bash quickfort orders -t rotccw ``` ```bash quickfort orders -t fliph ``` ```bash quickfort orders -t flipv ``` -------------------------------- ### Enable Starving Dead with Default Settings Source: https://github.com/dfhack/scripts/blob/master/docs/starvingdead.rst Starts the starving dead process with its default configuration. This is the basic command to activate the undead decay feature. ```bash enable starvingdead ``` -------------------------------- ### Assign Skills Example Source: https://github.com/dfhack/scripts/blob/master/docs/assign-skills.rst Clears all existing skills for a unit and then assigns Woodcutter at competent level and Axeman at adequate level. ```bash assign-skills --reset --skills [ WOODCUTTING 3 AXE 2 ] ``` -------------------------------- ### Enable Deterioration Source: https://github.com/dfhack/scripts/blob/master/docs/deteriorate.rst Start deteriorating items with the current settings. This is the default command to activate the script. ```bash enable deteriorate ``` -------------------------------- ### Reset and Assign a Goal Source: https://github.com/dfhack/scripts/blob/master/docs/assign-goals.rst This example demonstrates clearing all existing goals for a unit and then assigning the 'master a skill' goal. The resulting dream will be 'dreams of mastering a skill'. ```bash assign-goals --reset --goals [ MASTER_A_SKILL false ] ``` -------------------------------- ### Make Walls Unbuildable via Module Source: https://github.com/dfhack/scripts/blob/master/docs/modtools/change-build-menu.rst Example of using the ChangeBuildingAdv function to make walls unbuildable. This is not recommended. ```lua local typ, styp = df.building_type.Construction, df.construction_type.Wall buildmenu.ChangeBuildingAdv(typ, styp, -1, "CONSTRUCTIONS", false) ``` -------------------------------- ### Enable Prioritize Tool Source: https://github.com/dfhack/scripts/blob/master/docs/prioritize.rst Enables the prioritize tool to start automatically boosting job priorities. Use this to activate the script's monitoring and prioritization capabilities. ```bash enable prioritize ``` -------------------------------- ### Autoload Savegame on DF Start (Windows) Source: https://github.com/dfhack/scripts/blob/master/docs/load-save.rst Launch Dwarf Fortress with the load-save script to automatically load a specified savegame. Use quotes if the executable path contains spaces. ```bash "Dwarf Fortress.exe" +load-save region1 ``` -------------------------------- ### Get Death Cause Programmatically (Lua) Source: https://github.com/dfhack/scripts/blob/master/docs/deathcause.rst Call the getDeathCause function from the deathcause script API. This example demonstrates retrieving the death reason for a selected unit. ```lua local dc = reqscript('deathcause') -- Note: this is an arguably bad example because this is the same as running deathcause -- from the launcher, but this would theoretically still work. local deathReason = dc.getDeathCauseFromUnit(dfhack.gui.getSelectedUnit()) print(deathReason) ``` -------------------------------- ### Quickfort Configuration Source: https://github.com/dfhack/scripts/blob/master/docs/quickfort.rst Shows how to set global configuration options for the quickfort script using the 'quickfort set' command. Note that these settings are session-specific. ```bash quickfort set blueprints_user_dir dfhack-config/blueprints ``` -------------------------------- ### Set Up Custom Keybinding for Markdown Tool Source: https://github.com/dfhack/scripts/blob/master/docs/markdown.rst Configure a custom keybinding to quickly execute the 'markdown' command with specific arguments, such as a custom output filename. This can be done temporarily for the current session or permanently by adding it to the dfhack.init file. ```bash keybinding add Ctrl-Shift-S@dwarfmode/ViewSheets/UNIT|dwarfmode/ViewSheets/ITEM "markdown descriptions" ``` -------------------------------- ### Autoload Savegame on DF Start (Linux/MacOS) Source: https://github.com/dfhack/scripts/blob/master/docs/load-save.rst Start Dwarf Fortress with the load-save script to automatically load a specific savegame upon game launch. Ensure the path to dfhack is correct. ```bash ./dfhack +load-save region1 ``` -------------------------------- ### Quickfort Command-Line Options Source: https://github.com/dfhack/scripts/blob/master/docs/quickfort.rst Demonstrates various command-line options for the quickfort script, including specifying cursor position, dry runs, applying markers, setting priorities, preserving engravings, quiet/verbose output, repeating blueprints, shifting, and transformations. ```bash quickfort orders -c ,, -d -m -p --preserve-engravings -q -r , -s , -t ``` -------------------------------- ### Equip Unit with Items Source: https://github.com/dfhack/scripts/blob/master/docs/modtools/create-unit.rst Creates and equips items onto the unit. Equipment is sized and placed appropriately. Item quantity defaults to 1. ```bash -equip [ RING:CREATURE:DWARF:BONE:3 ] ``` ```bash -equip [ ITEM_WEAPON_PICK:INORGANIC:IRON ] ``` ```bash -equip [ "ITEM_SHIELD_BUCKLER:PLANT:OAK:WOOD" "AMULET:AMBER" ] ``` -------------------------------- ### Display Help for Combine Source: https://github.com/dfhack/scripts/blob/master/docs/combine.rst Run the 'combine' command without arguments to display its help information. ```bash combine ``` -------------------------------- ### Remove Carpenters Workshop via Module Source: https://github.com/dfhack/scripts/blob/master/docs/modtools/change-build-menu.rst Example of using the change-build-menu module to remove the carpenters workshop from the build menu. ```lua buildmenu.ChangeBuilding("CARPENTERS", "WORKSHOPS", false) ``` -------------------------------- ### Apply Dig Blueprint with String Data Source: https://github.com/dfhack/scripts/blob/master/docs/quickfort.rst Use this to apply a simple dig blueprint defined by a string, like 'd(10x10)', at the current mouse cursor position. Ensure the 'quickfort' script is required. ```lua local quickfort = reqscript('quickfort') -- dig a 10x10 block at the mouse cursor position quickfort.apply_blueprint{mode='dig', data='d(10x10)', pos=dfhack.gui.getMousePos()} ``` -------------------------------- ### Show Unit Cave Adaptation Source: https://github.com/dfhack/scripts/blob/master/docs/adaptation.rst Display the current cave adaptation level for the currently selected unit. No setup is required. ```bash adaptation show ``` -------------------------------- ### Reset Timeskip Duration Source: https://github.com/dfhack/scripts/blob/master/docs/set-timeskip-duration.rst Use the --clear argument to reset the timeskip duration to its default value. This will not affect timeskips that have already started. ```bash set-timeskip-duration --clear ``` -------------------------------- ### List DFHack Tools and Preferences Source: https://github.com/dfhack/scripts/blob/master/docs/control-panel.rst Use `control-panel list` to view current settings and available tools or preferences. You can filter the list by providing a search string. ```bash control-panel list ``` ```bash control-panel list butcher ``` -------------------------------- ### Script API for Autostart Status Source: https://github.com/dfhack/scripts/blob/master/docs/control-panel.rst Other scripts can query whether a command is set for autostart using the control-panel script API. ```APIDOC ## Script API: get_autostart ### Description Allows other DFHack scripts to query the autostart status of a given command. ### Method Signature ```lua control_panel.get_autostart(command) ``` ### Parameters - **command** (string) - The name of the command or tool to check. ### Returns - **enabled** (boolean) - `true` if the command is set for autostart, `false` otherwise. - **default** (boolean) - `true` if the command is set as a default autostart, `false` otherwise. (Note: The source text implies this return value, but its exact meaning or usage is not fully detailed.) ### Request Example ```lua local control_panel = reqscript('control-panel') local enabled, default = control_panel.get_autostart('autofarm') if enabled then print('Autofarm is set to autostart.') else print('Autofarm is not set to autostart.') end ``` ``` -------------------------------- ### Query Auto-Start Status via Script API Source: https://github.com/dfhack/scripts/blob/master/docs/control-panel.rst Access the DFHack control-panel script API to check if a command is configured for auto-start. ```lua local control_panel = reqscript('control-panel') local enabled, default = control_panel.get_autostart(command) ``` -------------------------------- ### Show all migration wave information Source: https://github.com/dfhack/scripts/blob/master/docs/list-waves.rst Run this command to see the count of dwarves per wave, arrival times, and the names of dwarves in each wave. This provides a comprehensive overview of your fort's population history. ```bash list-waves ``` -------------------------------- ### Get Workshop ID by Numeric Triplet Source: https://github.com/dfhack/scripts/blob/master/docs/modtools/change-build-menu.rst Retrieve the string ID of a workshop or furnace using its numeric ID triplet (type, subtype, custom). ```lua GetWShopID(btype, bsubtype, bcustom) ``` -------------------------------- ### Set Timeskip Duration by Ticks Source: https://github.com/dfhack/scripts/blob/master/docs/set-timeskip-duration.rst Set the end of the timeskip using a specific number of ticks. The provided example sets the timeskip to approximately 2 years. ```bash set-timeskip-duration --ticks 851249 ``` -------------------------------- ### Set Embark Points with DFHack Source: https://github.com/dfhack/scripts/blob/master/docs/points.rst Use this command at the embark screen to set the total available points. Setting a high number allows for purchasing more items and skills, while setting it to zero provides a challenge. ```bash points 1000000 ``` ```bash points 0 ``` -------------------------------- ### Get All Civilization IDs Source: https://github.com/dfhack/scripts/blob/master/docs/force.rst This Lua script retrieves and prints the IDs for all civilizations currently present in your game. Useful for specifying civ IDs in other 'force' commands. ```lua :lua ids={} for _,en in ipairs(world.entities.all) do ids[en.entity_raw.code] = true end for id in pairs(ids) do print(id) end ``` -------------------------------- ### Register and Load Default Color Scheme Quietly Source: https://github.com/dfhack/scripts/blob/master/docs/color-schemes.rst Register color schemes and then load the previously set default scheme without any output. This is ideal for inclusion in initialization files like `dfhack.init` to ensure a consistent color scheme on game startup. ```bash color-schemes -q register colorschemes color-schemes default load ``` -------------------------------- ### Enqueue Workorder with JSON Specification Source: https://github.com/dfhack/scripts/blob/master/docs/workorder.rst Create a workorder with properties defined in a JSON string. This example enqueues an 'EncrustWithGems' job for five 'finished_goods' without specifying a material. ```bash workorder "{\"job\":\"EncrustWithGems\",\"item_category\":[\"finished_goods\"],\"amount_total\":5}" ``` -------------------------------- ### Preview Item Combinations Source: https://github.com/dfhack/scripts/blob/master/docs/combine.rst Use the '--dry-run' option with 'combine all' to see which items would be merged across all stockpiles without making any changes. ```bash combine all --dry-run ``` -------------------------------- ### Compare Tiletype Materials (Shell) Source: https://github.com/dfhack/scripts/blob/master/docs/devel/cmptiles.rst Use the cmptiles script with one or two material group names to compare them. Provide one material group to list its details, or two to compare them. ```shell devel/cmptiles material1 [material2] ``` -------------------------------- ### Add Thought with Specifics Source: https://github.com/dfhack/scripts/blob/master/docs/add-thought.rst Assign a specific emotion, thought, and strength to a given unit ID. This example makes unit 23142 feel gratitude for a good meal. ```bash add-thought --unit 23142 --emotion GRATITUDE --thought GoodMeal --strength 1 ``` -------------------------------- ### Get Workshop Numeric ID Triplet by String ID Source: https://github.com/dfhack/scripts/blob/master/docs/modtools/change-build-menu.rst Retrieve the numeric ID triplet (type, subtype, custom) for a workshop or furnace using its string identifier. ```lua GetWShopType(id) ``` -------------------------------- ### Open gm-editor Source: https://github.com/dfhack/scripts/blob/master/docs/gui/gm-editor.rst Launches the game data editor. Without arguments, it opens on the currently selected game element. ```bash gui/gm-editor ``` -------------------------------- ### List Cages and Contents Source: https://github.com/dfhack/scripts/blob/master/docs/stripcaged.rst Use this command to see a list of all cages and the items they contain. This is useful for inventory management before dumping. ```bash stripcaged list ``` -------------------------------- ### List Available Confirmations Source: https://github.com/dfhack/scripts/blob/master/docs/confirm.rst Run without parameters to see a list of available confirmation dialogs and their IDs. This helps in managing which actions require confirmation. ```bash confirm list ``` -------------------------------- ### Get Item ID in DFHack Source: https://github.com/dfhack/scripts/blob/master/docs/remove-wear.rst This command is used within DFHack to retrieve the unique ID of a selected item. This ID can then be used with the 'remove-wear' tool to target specific items. ```lua :lua !item.id ``` -------------------------------- ### Set Timeskip Duration by Years, Months, Days, and Hours Source: https://github.com/dfhack/scripts/blob/master/docs/set-timeskip-duration.rst Set the timeskip duration by specifying years, months, days, and hours. This example achieves the same duration as setting --ticks 851249. ```bash set-timeskip-duration --years 2 --months 1 --days 9 --hours 8 --ticks 49 ``` -------------------------------- ### Combine All Items in All Stockpiles Source: https://github.com/dfhack/scripts/blob/master/docs/combine.rst Execute 'combine all' to merge item stacks in all stockpiles for all item types. ```bash combine all ``` -------------------------------- ### Reset and Assign Facets Example Source: https://github.com/dfhack/scripts/blob/master/docs/assign-facets.rst Resets all unit facets to neutral and then sets specific facets to defined levels. Hate propensity is set to a very low level (-2), and cheer propensity to a low level (-1). ```bash assign-facets --reset --facets [ HATE_PROPENSITY -2 CHEER_PROPENSITY -1 ] ``` -------------------------------- ### List Tiletype Materials (Lua) Source: https://github.com/dfhack/scripts/blob/master/docs/devel/cmptiles.rst Run this command to see a list of valid material groups for tiletypes. This is useful for understanding the available options before using cmptiles. ```lua @df.tiletype_material ``` -------------------------------- ### Accessing Tile Data in JSON Source: https://github.com/dfhack/scripts/blob/master/docs/devel/export-map.rst Illustrates how to access specific tile data (e.g., shape, light) from the exported JSON map using the defined ARGUMENT_OPTION_ORDER. Note that DF map indices start at 0, but some JSON libraries may use 1-based indexing, requiring coordinate adjustments. ```javascript shape = json_data.map[z][x][y][json_data.ARGUMENT_OPTIONS_ORDER.shape] ``` ```javascript light = json_data.map[z][x][y][json_data.ARGUMENT_OPTIONS_ORDER.light] ``` -------------------------------- ### Command Usage Source: https://github.com/dfhack/scripts/blob/master/docs/modtools/change-build-menu.rst Commands to enable, disable, add, remove, and revert items in the build menu. ```APIDOC ## Enable/Disable Ticker ### Description Starts or stops the change-build-menu ticker. Changes only take effect when the ticker is running. ### Commands - ``enable modtools/change-build-menu``: Start the ticker. - ``disable modtools/change-build-menu``: Stop the ticker. ## Add Item ### Description Adds a workshop or furnace to a specified category in the build menu. ### Command ``modtools/change-build-menu add []`` ### Parameters - **ID** (string): The text ID of the workshop or furnace to add (e.g., CARPENTERS). - **CATEGORY** (string): The category to add the item to. Valid options include: MAIN_PAGE, SIEGE_ENGINES, TRAPS, WORKSHOPS, FURNACES, CONSTRUCTIONS, MACHINES, CONSTRUCTIONS_TRACK. - **KEY** (string, optional): An optional DF hotkey ID. ## Remove Item ### Description Removes a workshop or furnace from a specified category in the build menu. ### Command ``modtools/change-build-menu remove `` ### Parameters - **ID** (string): The text ID of the workshop or furnace to remove. - **CATEGORY** (string): The category to remove the item from. Valid options are the same as for the 'add' command. ## Revert Changes ### Description Reverts a previously made add or remove operation for a specific item and category. ### Command ``modtools/change-build-menu revert `` ### Parameters - **ID** (string): The text ID of the item whose change should be reverted. - **CATEGORY** (string): The category the item belongs to. ``` -------------------------------- ### Set Material Preferences Source: https://github.com/dfhack/scripts/blob/master/docs/assign-preferences.rst Use this command to set a unit's preferences for specific materials. Ensure tokens are correctly formatted, especially for wood and plant materials. ```bash assign-preferences --reset --likematerial [ INORGANIC:ALABASTER PLANT:WILLOW:WOOD ] ``` -------------------------------- ### Command Line Usage Source: https://github.com/dfhack/scripts/blob/master/docs/color-schemes.rst Commands to manage color schemes via the command line. ```APIDOC ## Command Line Usage ### Register Color Scheme Directory Register the directory where color scheme files are stored. - **Command**: ``color-schemes register [-f] [-q]`` - **Options**: - ``-f``, ``--force``: Register and read incomplete or syntactically incorrect color schemes. - ``-q``, ``--quiet``: Suppress informational output. ### List Registered Color Schemes List all color schemes from the registered directories. - **Command**: ``color-schemes list`` ### Set Default Color Scheme Set a named color scheme as the default. - **Command**: ``color-schemes default set [-q]`` - **Options**: - ``-q``, ``--quiet``: Suppress informational output. ### Load Default Color Scheme Load the previously set default color scheme. - **Command**: ``color-schemes default load [-q]`` - **Options**: - ``-q``, ``--quiet``: Suppress informational output. ### Load Specific Color Scheme Load a named color scheme. - **Command**: ``color-schemes load [-q]`` - **Options**: - ``-q``, ``--quiet``: Suppress informational output. ```