├── .gitattributes ├── fix ├── about.txt ├── civil-war.lua ├── occupancy.lua ├── corrupt-jobs.lua ├── sleepers.lua └── population-cap.lua ├── devel ├── pop-screen.lua ├── all-bob.lua ├── print-args.lua ├── about.txt ├── print-args2.lua ├── lua-example.lua ├── nuke-items.lua ├── scanitemother.lua ├── spawn-unit-helper.lua ├── clear-script-env.lua └── send-key.lua ├── .github ├── pull_request_template.md └── workflows │ ├── clean-cache.yml │ └── build.yml ├── about.txt ├── twaterlvl.lua ├── .gitignore ├── internal ├── manipulator │ └── presets.lua ├── gm-unit │ └── base_editor.lua ├── quickfort │ └── common.lua └── journal │ └── contexts │ └── dummy.lua ├── docs ├── clear-smoke.rst ├── modtools │ ├── raw-lint.rst │ ├── equip-item.rst │ ├── extra-gamelog.rst │ ├── reaction-trigger-transition.rst │ ├── anonymous-script.rst │ ├── create-tree.rst │ ├── projectile-trigger.rst │ ├── spawn-liquid.rst │ ├── outside-only.rst │ ├── reaction-product-trigger.rst │ ├── skill-change.rst │ ├── if-entity.rst │ ├── invader-item-destroyer.rst │ └── spawn-flow.rst ├── binpatch.rst ├── devel │ ├── all-bob.rst │ ├── hello-world.rst │ ├── lua-example.rst │ ├── print-args.rst │ ├── print-args2.rst │ ├── export-dt-ini.rst │ ├── watch-minecarts.rst │ ├── modstate-monitor.rst │ ├── nuke-items.rst │ ├── check-release.rst │ ├── block-borders.rst │ ├── click-monitor.rst │ ├── save-version.rst │ ├── cmptiles.rst │ ├── unit-path.rst │ ├── print-event.rst │ ├── check-other-ids.rst │ ├── tree-info.rst │ ├── light.rst │ ├── annc-monitor.rst │ ├── test-perlin.rst │ ├── list-filters.rst │ ├── visualize-structure.rst │ ├── sc.rst │ ├── scan-vtables.rst │ ├── scanitemother.rst │ ├── clear-script-env.rst │ ├── tile-browser.rst │ ├── dump-offsets.rst │ ├── spawn-unit-helper.rst │ ├── kill-hf.rst │ ├── find-primitive.rst │ ├── lsmem.rst │ ├── send-key.rst │ ├── inspect-screen.rst │ ├── eventful-client.rst │ ├── input-monitor.rst │ ├── pop-screen.rst │ ├── dump-tooltip-ids.rst │ └── inject-raws.rst ├── gui │ ├── petitions.rst │ ├── suspendmanager.rst │ ├── autotraining.rst │ ├── gm-unit.rst │ ├── kitchen-info.rst │ ├── autobutcher.rst │ ├── unit-syndromes.rst │ ├── siegemanager.rst │ ├── spectate.rst │ ├── masspit.rst │ ├── clone-uniform.rst │ ├── stamper.rst │ ├── color-schemes.rst │ ├── autofish.rst │ ├── room-list.rst │ ├── manipulator.rst │ ├── prerelease-warning.rst │ ├── quickcmd.rst │ ├── stockpiles.rst │ ├── workorder-details.rst │ ├── confirm.rst │ ├── extended-status.rst │ ├── autochop.rst │ ├── cp437-table.rst │ ├── seedwatch.rst │ ├── dfstatus.rst │ ├── liquids.rst │ ├── power-meter.rst │ ├── guide-path.rst │ ├── keybinds.rst │ ├── teleport.rst │ ├── biomes.rst │ ├── choose-weapons.rst │ ├── mod-manager.rst │ ├── unit-info-viewer.rst │ ├── aquifer.rst │ ├── mass-remove.rst │ ├── overlay.rst │ ├── notify.rst │ ├── blueprint.rst │ ├── notes.rst │ └── load-screen.rst ├── make-monarch.rst ├── ghostly.rst ├── twaterlvl.rst ├── adv-max-skills.rst ├── fix │ ├── blood-del.rst │ ├── corrupt-jobs.rst │ ├── stuckdoors.rst │ ├── civil-war.rst │ ├── loyaltycascade.rst │ ├── sleepers.rst │ ├── stable-temp.rst │ ├── symbol-unstick.rst │ ├── engravings.rst │ ├── general-strike.rst │ ├── drop-webs.rst │ ├── stuck-merchants.rst │ ├── stuck-instruments.rst │ ├── retrieve-units.rst │ ├── dry-buckets.rst │ ├── ownership.rst │ ├── protect-nicks.rst │ ├── occupancy.rst │ ├── population-cap.rst │ ├── empty-wheelbarrows.rst │ └── dead-units.rst ├── break-dance.rst ├── quicksave.rst ├── hotkey-notes.rst ├── tidlers.rst ├── quickstart-guide.rst ├── install-info.rst ├── cannibalism.rst ├── suspend.rst ├── names.rst ├── firestarter.rst ├── troubleshoot-item.rst ├── forbid.rst ├── reveal-hidden-units.rst ├── setfps.rst ├── weather.rst ├── flashstep.rst ├── migrants-now.rst ├── fillneeds.rst ├── fixnaked.rst ├── ungeld.rst ├── trackstop.rst ├── elevate-mental.rst ├── view-unit-reports.rst ├── reveal-adv-map.rst ├── forget-dead-body.rst ├── reveal-hidden-sites.rst ├── immortal-cravings.rst ├── resurrect-adv.rst ├── hermit.rst ├── extinguish.rst ├── points.rst ├── linger.rst ├── undump-buildings.rst ├── questport.rst ├── elevate-physical.rst ├── unforbid.rst ├── toggle-kbd-cursor.rst ├── makeown.rst ├── remove-wear.rst ├── geld.rst ├── growcrops.rst ├── list-agreements.rst ├── bodyswap.rst ├── multicmd.rst ├── hide-interface.rst ├── colonies.rst ├── clear-webs.rst ├── siren.rst ├── confirm.rst ├── embark-anyone.rst ├── brainwash.rst ├── justice.rst ├── tame.rst ├── putontable.rst ├── catsplosion.rst ├── launch.rst ├── autolabor-artisans.rst ├── necronomicon.rst ├── resize-armor.rst ├── add-recipe.rst ├── diplomacy.rst ├── view-item-info.rst ├── superdwarf.rst ├── adaptation.rst ├── assign-minecarts.rst ├── make-legendary.rst ├── once-per-save.rst ├── on-new-fortress.rst ├── do-job-now.rst ├── fix-ster.rst ├── load-save.rst ├── position.rst ├── burial.rst ├── embark-skills.rst ├── unretire-anyone.rst ├── feature.rst ├── gaydar.rst ├── lever.rst ├── autocheese.rst ├── autonick.rst ├── locate-ore.rst ├── spawnunit.rst ├── prefchange.rst ├── deathcause.rst ├── teleport.rst └── remove-stress.rst ├── migrants-now.lua ├── test ├── teleport.lua ├── quickfort │ └── notes_unit.lua └── startdwarf.lua ├── tidlers.lua ├── points.lua ├── on-new-fortress.lua ├── gui └── about.txt ├── reveal-hidden-sites.lua ├── multicmd.lua ├── ungeld.lua ├── CMakeLists.txt ├── hotkey-notes.lua ├── ghostly.lua ├── resurrect-adv.lua ├── setfps.lua ├── cannibalism.lua ├── break-dance.lua ├── suspend.lua ├── firestarter.lua ├── toggle-kbd-cursor.lua ├── reveal-hidden-units.lua ├── adv-max-skills.lua ├── modtools ├── if-entity.lua ├── anonymous-script.lua └── about.txt ├── light-aquifers-only.lua ├── fillneeds.lua ├── undump-buildings.lua ├── advtools.lua ├── flashstep.lua ├── clear-smoke.lua ├── putontable.lua ├── remove-wear.lua ├── repeat.lua ├── forget-dead-body.lua ├── .pre-commit-config.yaml ├── once-per-save.lua ├── hide-interface.lua ├── teleport.lua └── burial.lua /.gitattributes: -------------------------------------------------------------------------------- 1 | changelog.txt merge=union 2 | -------------------------------------------------------------------------------- /fix/about.txt: -------------------------------------------------------------------------------- 1 | ``fix/*`` scripts fix various bugs and issues, some of them obscure. 2 | -------------------------------------------------------------------------------- /devel/pop-screen.lua: -------------------------------------------------------------------------------- 1 | -- Forcibly closes the current screen 2 | 3 | dfhack.screen.dismiss(dfhack.gui.getCurViewscreen()) 4 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | If this PR makes an externally-visible change in behavior, please add an appropriate line to `changelog.txt`. 2 | -------------------------------------------------------------------------------- /about.txt: -------------------------------------------------------------------------------- 1 | Basic scripts are not stored in any subdirectory, and can be invoked directly. 2 | They are generally useful tools for any player. 3 | -------------------------------------------------------------------------------- /twaterlvl.lua: -------------------------------------------------------------------------------- 1 | local flags = df.global.d_init.display.flags 2 | flags.SHOW_FLOW_AMOUNTS = not flags.SHOW_FLOW_AMOUNTS 3 | print('Water level display toggled.') 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # kdevelop 2 | *.kdev4 3 | .kdev4 4 | 5 | # vim files 6 | *.swp 7 | .vimrc 8 | 9 | # VSCode files 10 | .vscode 11 | 12 | # CLion 13 | .idea 14 | -------------------------------------------------------------------------------- /internal/manipulator/presets.lua: -------------------------------------------------------------------------------- 1 | --@module=true 2 | 3 | PRESETS = { 4 | { 5 | name='', 6 | groups={ 7 | 8 | }, 9 | }, 10 | } 11 | -------------------------------------------------------------------------------- /devel/all-bob.lua: -------------------------------------------------------------------------------- 1 | -- Changes the first name of all units to "Bob" 2 | --author expwnent 3 | 4 | for _,v in ipairs(df.global.world.units.active) do 5 | v.name.first_name = "Bob" 6 | end 7 | -------------------------------------------------------------------------------- /docs/clear-smoke.rst: -------------------------------------------------------------------------------- 1 | clear-smoke 2 | =========== 3 | 4 | .. dfhack-tool:: 5 | :summary: Removes all smoke from the map. 6 | :tags: fort armok fps map 7 | 8 | 9 | Usage 10 | ----- 11 | 12 | :: 13 | 14 | clear-smoke 15 | -------------------------------------------------------------------------------- /docs/modtools/raw-lint.rst: -------------------------------------------------------------------------------- 1 | modtools/raw-lint 2 | ================= 3 | 4 | .. dfhack-tool:: 5 | :summary: Check for errors in raw files. 6 | :tags: unavailable 7 | 8 | Checks for simple issues with raw files. Can be run automatically. 9 | -------------------------------------------------------------------------------- /.github/workflows/clean-cache.yml: -------------------------------------------------------------------------------- 1 | name: Clean up PR caches 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - closed 7 | 8 | jobs: 9 | cleanup: 10 | uses: DFHack/dfhack/.github/workflows/clean-cache.yml@develop 11 | secrets: inherit 12 | -------------------------------------------------------------------------------- /docs/binpatch.rst: -------------------------------------------------------------------------------- 1 | binpatch 2 | ======== 3 | 4 | .. dfhack-tool:: 5 | :summary: Applies or removes binary patches. 6 | :tags: unavailable 7 | 8 | See `binpatches` for more info. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | binpatch check|apply|remove 16 | -------------------------------------------------------------------------------- /docs/devel/all-bob.rst: -------------------------------------------------------------------------------- 1 | devel/all-bob 2 | ============= 3 | 4 | .. dfhack-tool:: 5 | :summary: Changes the first name of all units to "Bob".. 6 | :tags: dev 7 | 8 | Useful for testing `modtools/interaction-trigger` events. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | devel/all-bob 16 | -------------------------------------------------------------------------------- /docs/devel/hello-world.rst: -------------------------------------------------------------------------------- 1 | devel/hello-world 2 | ================= 3 | 4 | .. dfhack-tool:: 5 | :summary: A basic GUI example script. 6 | :tags: dev 7 | 8 | A basic example for testing, or to start your own script from. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | devel/hello-world 16 | -------------------------------------------------------------------------------- /docs/gui/petitions.rst: -------------------------------------------------------------------------------- 1 | gui/petitions 2 | ============= 3 | 4 | .. dfhack-tool:: 5 | :summary: List guildhall and temple agreements. 6 | :tags: fort inspection 7 | 8 | Show your fort's petitions, both pending and fulfilled. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | gui/petitions 16 | -------------------------------------------------------------------------------- /docs/devel/lua-example.rst: -------------------------------------------------------------------------------- 1 | devel/lua-example 2 | ================= 3 | 4 | .. dfhack-tool:: 5 | :summary: An example lua script. 6 | :tags: unavailable 7 | 8 | This is an example Lua script which just reports the number of times it has been 9 | called. Useful for testing environment persistence. 10 | -------------------------------------------------------------------------------- /docs/devel/print-args.rst: -------------------------------------------------------------------------------- 1 | devel/print-args 2 | ================ 3 | 4 | .. dfhack-tool:: 5 | :summary: Echo parameters to the output. 6 | :tags: dev 7 | 8 | Prints all the arguments you supply to the script, one per line. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | devel/print-args [] 16 | -------------------------------------------------------------------------------- /docs/make-monarch.rst: -------------------------------------------------------------------------------- 1 | make-monarch 2 | ============ 3 | 4 | .. dfhack-tool:: 5 | :summary: Crown the selected unit as a monarch. 6 | :tags: fort armok units 7 | 8 | This tool can make the selected unit king or queen of your civilization. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | make-monarch 16 | -------------------------------------------------------------------------------- /docs/ghostly.rst: -------------------------------------------------------------------------------- 1 | ghostly 2 | ======= 3 | 4 | .. dfhack-tool:: 5 | :summary: Toggles an adventurer's ghost status. 6 | :tags: adventure armok units 7 | 8 | This is useful for walking through walls, avoiding attacks, or recovering after 9 | a death. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | ghostly 17 | -------------------------------------------------------------------------------- /docs/modtools/equip-item.rst: -------------------------------------------------------------------------------- 1 | modtools/equip-item 2 | =================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Force a unit to equip an item. 6 | :tags: unavailable 7 | 8 | Force a unit to equip an item with a particular body part; useful in 9 | conjunction with the ``create`` scripts above. See also `forceequip`. 10 | -------------------------------------------------------------------------------- /internal/gm-unit/base_editor.lua: -------------------------------------------------------------------------------- 1 | -- Editor base class for gui/gm-unit. Every other editor should inherit from this. 2 | --@ module = true 3 | 4 | local widgets = require('gui.widgets') 5 | 6 | Editor = defclass(Editor, widgets.Panel) 7 | Editor.ATTRS{ 8 | target_unit = DEFAULT_NIL, 9 | frame_title = DEFAULT_NIL, 10 | } 11 | -------------------------------------------------------------------------------- /devel/print-args.lua: -------------------------------------------------------------------------------- 1 | --print-args.lua 2 | --author expwnent 3 | --[====[ 4 | 5 | devel/print-args 6 | ================ 7 | Prints all the arguments you supply to the script on their own line. 8 | Useful for debugging other scripts. 9 | 10 | ]====] 11 | 12 | local args = {...} 13 | for _,arg in ipairs(args) do 14 | print(arg) 15 | end 16 | -------------------------------------------------------------------------------- /docs/twaterlvl.rst: -------------------------------------------------------------------------------- 1 | twaterlvl 2 | ========= 3 | 4 | .. dfhack-tool:: 5 | :summary: Show/hide numeric liquid depth on the map. 6 | :tags: interface 7 | 8 | You can use this tool to toggle between displaying/not displaying liquid depth 9 | as numbers on the map. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | twaterlvl 17 | -------------------------------------------------------------------------------- /docs/adv-max-skills.rst: -------------------------------------------------------------------------------- 1 | adv-max-skills 2 | ============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Raises adventurer stats to max. 6 | :tags: unavailable 7 | 8 | When creating an adventurer, raises all changeable skills and attributes to 9 | their maximum level. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | adv-max-skills 17 | -------------------------------------------------------------------------------- /docs/fix/blood-del.rst: -------------------------------------------------------------------------------- 1 | fix/blood-del 2 | ============= 3 | 4 | .. dfhack-tool:: 5 | :summary: Removes unusable liquids from caravan manifests. 6 | :tags: fort bugfix 7 | 8 | This fix ensures future caravans won't bring barrels full of blood, ichor, or 9 | goo. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | fix/blood-del 17 | -------------------------------------------------------------------------------- /docs/devel/print-args2.rst: -------------------------------------------------------------------------------- 1 | devel/print-args2 2 | ================= 3 | 4 | .. dfhack-tool:: 5 | :summary: Echo parameters to the output. 6 | :tags: dev 7 | 8 | Prints all the arguments you supply to the script, one per line, with quotes 9 | around them. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | devel/print-args2 [] 17 | -------------------------------------------------------------------------------- /migrants-now.lua: -------------------------------------------------------------------------------- 1 | -- Force a migrant wave (only after hardcoded waves) 2 | 3 | df.global.timed_events:insert('#',{ 4 | new = true, 5 | type = df.timed_event_type.Migrants, 6 | season = df.global.cur_season, 7 | season_ticks = df.global.cur_season_tick+1, 8 | entity = df.historical_entity.find(df.global.plotinfo.civ_id) 9 | }) 10 | -------------------------------------------------------------------------------- /test/teleport.lua: -------------------------------------------------------------------------------- 1 | config = { 2 | mode = 'fortress', 3 | } 4 | 5 | local t = reqscript('teleport') 6 | 7 | function test.teleport() 8 | local unit = df.global.world.units.active[0] 9 | local newpos = {x=unit.pos.x+1, y=unit.pos.y+1, z=unit.pos.z} 10 | t.teleport(unit, newpos) 11 | expect.table_eq(newpos, unit.pos) 12 | end 13 | -------------------------------------------------------------------------------- /tidlers.lua: -------------------------------------------------------------------------------- 1 | --Toggle idlers count 2 | --[====[ 3 | 4 | tidlers 5 | ======= 6 | Toggle between all possible positions where the idlers count can be placed 7 | (see ``data/init/d_init.txt`` for details). 8 | 9 | ]====] 10 | df.global.d_init.idlers = df.d_init_idlers:next_item(df.global.d_init.idlers) 11 | print('Toggled the display of idlers.') 12 | -------------------------------------------------------------------------------- /docs/break-dance.rst: -------------------------------------------------------------------------------- 1 | break-dance 2 | =========== 3 | 4 | .. dfhack-tool:: 5 | :summary: Fixes buggy tavern dances. 6 | :tags: unavailable 7 | 8 | Sometimes when a unit can't find a dance partner, the dance becomes stuck and 9 | never stops. This tool can get them unstuck. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | break-dance 17 | -------------------------------------------------------------------------------- /docs/devel/export-dt-ini.rst: -------------------------------------------------------------------------------- 1 | devel/export-dt-ini 2 | =================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Export memory addresses for Dwarf Therapist configuration. 6 | :tags: dev 7 | 8 | This tool exports an ini file containing memory addresses for Dwarf Therapist. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | devel/export-dt-ini 16 | -------------------------------------------------------------------------------- /docs/gui/suspendmanager.rst: -------------------------------------------------------------------------------- 1 | gui/suspendmanager 2 | ================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Intelligently suspend and unsuspend jobs. 6 | :tags: fort jobs 7 | 8 | This is the graphical configuration interface for the `suspendmanager` 9 | automation tool. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | gui/suspendmanager 17 | -------------------------------------------------------------------------------- /docs/quicksave.rst: -------------------------------------------------------------------------------- 1 | quicksave 2 | ========= 3 | 4 | .. dfhack-tool:: 5 | :summary: Immediately autosave the game. 6 | :tags: dfhack fort 7 | 8 | When this tool is called with a fort loaded, DF will immediately do an 9 | autosave. Note that the game only keeps the last 3 autosaves. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | quicksave 17 | -------------------------------------------------------------------------------- /devel/about.txt: -------------------------------------------------------------------------------- 1 | ``devel/*`` scripts are intended for developer use, but many may 2 | be of interest to anyone investigating odd phenomena or just messing 3 | around. They are documented to encourage such inquiry. 4 | 5 | Some can PERMANENTLY DAMAGE YOUR SAVE if misused, so please be careful. 6 | The warnings are real; if in doubt make backups before running the command. 7 | -------------------------------------------------------------------------------- /devel/print-args2.lua: -------------------------------------------------------------------------------- 1 | --print-args2.lua 2 | --author expwnent 3 | --[====[ 4 | 5 | devel/print-args2 6 | ================= 7 | Prints all the arguments you supply to the script on their own line 8 | with quotes around them. 9 | 10 | ]====] 11 | 12 | local args = {...} 13 | print("print-args") 14 | for _,arg in ipairs(args) do 15 | print("'"..arg.."'") 16 | end 17 | -------------------------------------------------------------------------------- /docs/devel/watch-minecarts.rst: -------------------------------------------------------------------------------- 1 | devel/watch-minecarts 2 | ===================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Inspect minecart coordinates and speeds. 6 | :tags: unavailable 7 | 8 | When running, this tool will log minecart coordinates and speeds to the console. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | devel/watch-minecarts start|stop 16 | -------------------------------------------------------------------------------- /docs/devel/modstate-monitor.rst: -------------------------------------------------------------------------------- 1 | devel/modstate-monitor 2 | ====================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Display changes in key modifier state. 6 | :tags: dev 7 | 8 | This tool will show changes in :kbd:`Ctrl`, :kbd:`Alt`, and :kbd:`Shift` 9 | modifier states. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | enable devel/modstate-monitor 17 | -------------------------------------------------------------------------------- /docs/devel/nuke-items.rst: -------------------------------------------------------------------------------- 1 | devel/nuke-items 2 | ================ 3 | 4 | .. dfhack-tool:: 5 | :summary: Deletes all free items in the game. 6 | :tags: unavailable 7 | 8 | This tool deletes **ALL** items not referred to by units, buildings, or jobs. 9 | Intended solely for lag investigation. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | devel/nuke-items 17 | -------------------------------------------------------------------------------- /docs/hotkey-notes.rst: -------------------------------------------------------------------------------- 1 | hotkey-notes 2 | ============ 3 | 4 | .. dfhack-tool:: 5 | :summary: Show info on DF map location hotkeys. 6 | :tags: unavailable 7 | 8 | This command lists the key (e.g. :kbd:`F1`), name, and jump position of the 9 | map location hotkeys you set in the :kbd:`H` menu. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | hotkey-notes 17 | -------------------------------------------------------------------------------- /points.lua: -------------------------------------------------------------------------------- 1 | if dfhack.isWorldLoaded() then 2 | df.global.world.worldgen.worldgen_parms.embark_points = tonumber(...) 3 | local scr = dfhack.gui.getDFViewscreen() 4 | if df.viewscreen_setupdwarfgamest:is_instance(scr) then 5 | scr.points_remaining = tonumber(...) 6 | end 7 | else 8 | qerror('no world loaded - cannot modify embark points') 9 | end 10 | -------------------------------------------------------------------------------- /docs/devel/check-release.rst: -------------------------------------------------------------------------------- 1 | devel/check-release 2 | =================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Perform basic checks for DFHack release readiness. 6 | :tags: dev 7 | 8 | This script is run as part of the DFHack release process to check that release 9 | flags are properly set. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | devel/check-release 17 | -------------------------------------------------------------------------------- /docs/tidlers.rst: -------------------------------------------------------------------------------- 1 | tidlers 2 | ======= 3 | 4 | .. dfhack-tool:: 5 | :summary: Change where the idlers count is displayed. 6 | :tags: unavailable 7 | 8 | This tool simply cycles the idlers count among the possible positions where the 9 | idlers count can be placed, including making it disappear entirely. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | tidlers 17 | -------------------------------------------------------------------------------- /on-new-fortress.lua: -------------------------------------------------------------------------------- 1 | -- runs dfhack commands only in a newborn fortress 2 | 3 | if not (...) then 4 | print(dfhack.script_help()) 5 | return 6 | end 7 | 8 | if not (dfhack.world.isFortressMode() and df.global.plotinfo.fortress_age == 0) then return end 9 | 10 | for cmd in table.concat({...}, ' '):gmatch("%s*([^;]+);?%s*") do 11 | dfhack.run_command(cmd) 12 | end 13 | -------------------------------------------------------------------------------- /gui/about.txt: -------------------------------------------------------------------------------- 1 | ``gui/*`` scripts implement dialogs in the main game window. 2 | 3 | In order to avoid user confusion, as a matter of policy all these tools 4 | display the word :guilabel:`DFHack` on the screen somewhere while active. 5 | When that is not appropriate because they merely add keybinding hints to 6 | existing DF screens, they deliberately use red instead of green for the key. 7 | -------------------------------------------------------------------------------- /reveal-hidden-sites.lua: -------------------------------------------------------------------------------- 1 | local count = 0 2 | for _, site in ipairs(df.global.world.world_data.sites) do 3 | if site.flag.HIDDEN then 4 | site.flag.HIDDEN = false 5 | count = count + 1 6 | end 7 | end 8 | 9 | if count == 0 then 10 | print("No hidden sites detected!") 11 | else 12 | print("Exposed " .. count .. " site" .. (count == 1 and "" or "s") .. "!") 13 | end 14 | -------------------------------------------------------------------------------- /docs/quickstart-guide.rst: -------------------------------------------------------------------------------- 1 | quickstart-guide 2 | ================ 3 | 4 | .. dfhack-tool:: 5 | :summary: In-game quickstart guide for new users of DFHack. 6 | 7 | 8 | This command displays a window in-game where a player can browse the quickstart 9 | guide from the official DFHack docs, section by section. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | quickstart-guide 17 | -------------------------------------------------------------------------------- /docs/devel/block-borders.rst: -------------------------------------------------------------------------------- 1 | devel/block-borders 2 | =================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Outline map blocks on the map screen. 6 | :tags: dev map 7 | 8 | This tool displays an overlay that highlights the borders of map blocks. See 9 | :doc:`/docs/api/Maps` for details on map blocks. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | devel/block-borders 17 | -------------------------------------------------------------------------------- /docs/fix/corrupt-jobs.rst: -------------------------------------------------------------------------------- 1 | fix/corrupt-jobs 2 | ================ 3 | 4 | .. dfhack-tool:: 5 | :summary: Removes jobs with an id of -1 from units. 6 | :tags: fort bugfix 7 | 8 | This fix cleans up corrupt jobs so they don't cause crashes. It runs automatically on fort load, so you don't have to run it manually. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | fix/corrupt-jobs 16 | -------------------------------------------------------------------------------- /docs/gui/autotraining.rst: -------------------------------------------------------------------------------- 1 | gui/autotraining 2 | ================ 3 | 4 | .. dfhack-tool:: 5 | :summary: GUI interface for ``autotraining`` 6 | :tags: fort auto interface 7 | 8 | This is an in-game configuration interface for `autotraining`. You can pick squads for training, select ignored units, and set the needs threshold. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | gui/autotraining 16 | -------------------------------------------------------------------------------- /docs/modtools/extra-gamelog.rst: -------------------------------------------------------------------------------- 1 | modtools/extra-gamelog 2 | ====================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Write info to the gamelog for Soundsense. 6 | :tags: unavailable 7 | 8 | This script writes extra information to the gamelog. 9 | This is useful for tools like :forums:`Soundsense <60287>`. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | modtools/extra-gamelog enable 17 | -------------------------------------------------------------------------------- /devel/lua-example.lua: -------------------------------------------------------------------------------- 1 | -- Example of a lua script. 2 | --[====[ 3 | 4 | devel/lua-example 5 | ================= 6 | An example Lua script which reports the number of times it has been called. 7 | Useful for testing environment persistence. 8 | 9 | ]====] 10 | 11 | run_count = run_count or 0 12 | run_count = run_count + 1 13 | 14 | print('Arguments: ',...) 15 | print('Command called '..run_count..' times.') 16 | -------------------------------------------------------------------------------- /docs/install-info.rst: -------------------------------------------------------------------------------- 1 | install-info 2 | ============ 3 | 4 | .. dfhack-tool:: 5 | :summary: Exports information about DFHack for bug reports. 6 | :tags: dfhack 7 | 8 | This command saves information about the current DFHack installation and recent 9 | errors to ``install-info.txt`` in the current DF folder. Useful for bug reports. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | install-info 17 | -------------------------------------------------------------------------------- /internal/quickfort/common.lua: -------------------------------------------------------------------------------- 1 | -- common logic for the quickfort modules 2 | --@ module = true 3 | 4 | if not dfhack_flags.module then 5 | qerror('this script cannot be called directly') 6 | end 7 | 8 | verbose = false 9 | 10 | function log(...) 11 | if verbose then print(string.format(...)) end 12 | end 13 | 14 | function logfn(target_fn, ...) 15 | if verbose then target_fn{...} end 16 | end 17 | -------------------------------------------------------------------------------- /docs/devel/click-monitor.rst: -------------------------------------------------------------------------------- 1 | devel/click-monitor 2 | =================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Displays the grid coordinates of mouse clicks in the console. 6 | :tags: dev 7 | 8 | This tool will watch for mouse activity and print relevant information to the 9 | console. Useful for plugin/script development. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | enable devel/click-monitor 17 | -------------------------------------------------------------------------------- /docs/gui/gm-unit.rst: -------------------------------------------------------------------------------- 1 | gui/gm-unit 2 | =========== 3 | 4 | .. dfhack-tool:: 5 | :summary: Inspect and edit unit attributes. 6 | :tags: dfhack armok inspection animals units 7 | 8 | This tool provides an editor for unit attributes. Select a unit in-game before 9 | running this command or pass a target unit ID on the commandline. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | gui/gm-unit [unit id] 17 | -------------------------------------------------------------------------------- /docs/cannibalism.rst: -------------------------------------------------------------------------------- 1 | cannibalism 2 | =========== 3 | 4 | .. dfhack-tool:: 5 | :summary: Allows an adventurer to consume sapient corpses. 6 | :tags: unavailable 7 | 8 | This tool clears the flag from items that mark them as being from a sapient 9 | creature. Use from an adventurer's inventory screen or an individual item's 10 | detail screen. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | cannibalism 18 | -------------------------------------------------------------------------------- /docs/devel/save-version.rst: -------------------------------------------------------------------------------- 1 | devel/save-version 2 | ================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Display what DF version has handled the current save. 6 | :tags: dev 7 | 8 | This tool displays the DF version that created the game, the most recent DF 9 | version that has loaded and saved the game, and the current DF version. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | devel/save-version 17 | -------------------------------------------------------------------------------- /docs/gui/kitchen-info.rst: -------------------------------------------------------------------------------- 1 | gui/kitchen-info 2 | ================ 3 | 4 | .. dfhack-tool:: 5 | :summary: Show food item uses in the kitchen status screen. 6 | :tags: unavailable 7 | 8 | This tool is an overlay that adds more info to the Kitchen screen, such as the potential 9 | alternate uses of the items that you could mark for cooking. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | enable gui/kitchen-info 17 | -------------------------------------------------------------------------------- /docs/suspend.rst: -------------------------------------------------------------------------------- 1 | suspend 2 | ======= 3 | 4 | .. dfhack-tool:: 5 | :summary: Suspends building construction jobs. 6 | :tags: fort jobs 7 | 8 | This tool will suspend jobs all construction jobs. This is mainly useful as an 9 | emergency measure. Consider using `suspendmanager` from `gui/control-panel` to 10 | automatically suspend and unsuspend jobs. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | suspend 18 | -------------------------------------------------------------------------------- /docs/devel/cmptiles.rst: -------------------------------------------------------------------------------- 1 | devel/cmptiles 2 | ============== 3 | 4 | .. dfhack-tool:: 5 | :summary: List or compare two tiletype material groups. 6 | :tags: unavailable 7 | 8 | Lists and/or compares two tiletype material groups. You can see the list of 9 | valid material groups by running:: 10 | 11 | :lua @df.tiletype_material 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | devel/cmptiles material1 [material2] 19 | -------------------------------------------------------------------------------- /docs/fix/stuckdoors.rst: -------------------------------------------------------------------------------- 1 | fix/stuckdoors 2 | ============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Allow doors that are stuck open to close. 6 | :tags: fort bugfix buildings 7 | 8 | This tool can fix doors that are stuck open due to incorrect map occupancy 9 | flags. If you see a door that never closes with no obvious cause, try running 10 | this tool. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | fix/stuckdoors 18 | -------------------------------------------------------------------------------- /docs/devel/unit-path.rst: -------------------------------------------------------------------------------- 1 | devel/unit-path 2 | =============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Inspect where a unit is going and how it's getting there. 6 | :tags: unavailable 7 | 8 | When run with a unit selected, the path that the unit is currently following is 9 | highlighted on the map. You can jump between the unit and the destination tile. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | devel/unit-path 17 | -------------------------------------------------------------------------------- /docs/names.rst: -------------------------------------------------------------------------------- 1 | names 2 | ===== 3 | 4 | .. dfhack-tool:: 5 | :summary: Rename units or items with the DF name generator. 6 | :tags: unavailable 7 | 8 | This tool allows you to rename the selected unit or item (including artifacts) 9 | with the native Dwarf Fortress name generation interface. 10 | 11 | To modify or remove the first name, press :kbd:`f` and edit. 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | names 19 | -------------------------------------------------------------------------------- /docs/firestarter.rst: -------------------------------------------------------------------------------- 1 | firestarter 2 | =========== 3 | 4 | .. dfhack-tool:: 5 | :summary: Lights things on fire. 6 | :tags: fort adventure armok items map units 7 | 8 | Feel the need to burn something? Set items, locations, or even entire 9 | inventories on fire! Use while viewing an item, with the cursor over a map tile, 10 | or while viewing a unit's inventory. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | firestarter 18 | -------------------------------------------------------------------------------- /docs/troubleshoot-item.rst: -------------------------------------------------------------------------------- 1 | troubleshoot-item 2 | ================= 3 | 4 | .. dfhack-tool:: 5 | :summary: Inspect properties of the selected item. 6 | :tags: fort inspection items 7 | 8 | This tool lets you inspect internal properties of the selected item. This is 9 | useful for troubleshooting issues such as dwarves refusing to touch certain 10 | items. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | troubleshoot-item 18 | -------------------------------------------------------------------------------- /docs/forbid.rst: -------------------------------------------------------------------------------- 1 | forbid 2 | ====== 3 | 4 | .. dfhack-tool:: 5 | :summary: Forbid and list forbidden items on the map. 6 | :tags: fort productivity items 7 | 8 | List forbidden items, forbid all items on the map, or forbid unreachable items. 9 | Forbidding unreachable items checks if any of your citizens can walk to the item. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | forbid 17 | forbid all 18 | forbid unreachable 19 | -------------------------------------------------------------------------------- /docs/gui/autobutcher.rst: -------------------------------------------------------------------------------- 1 | 2 | gui/autobutcher 3 | =============== 4 | 5 | .. dfhack-tool:: 6 | :summary: Automatically butcher excess livestock. 7 | :tags: fort auto fps animals 8 | 9 | This is an in-game interface for `autobutcher`, which allows you to set 10 | thresholds for how many animals you want to keep and the extras will be 11 | automatically butchered. 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | gui/autobutcher 19 | -------------------------------------------------------------------------------- /docs/gui/unit-syndromes.rst: -------------------------------------------------------------------------------- 1 | gui/unit-syndromes 2 | ================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Inspect syndrome details. 6 | :tags: fort inspection units 7 | 8 | This tool can list the syndromes affecting game units and the remaining and 9 | maximum duration of those syndromes, along with (optionally) substantial detail 10 | about the effects. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | gui/unit-syndromes 18 | -------------------------------------------------------------------------------- /docs/devel/print-event.rst: -------------------------------------------------------------------------------- 1 | devel/print-event 2 | ================= 3 | 4 | .. dfhack-tool:: 5 | :summary: Show historical events. 6 | :tags: unavailable 7 | 8 | This tool displays the description of a historical event. 9 | 10 | Usage 11 | ----- 12 | 13 | ``devel/print-event --index `` 14 | Displays the historical event at the given index. 15 | ``devel/print-event --id `` 16 | Displays the historical event by the given id. 17 | -------------------------------------------------------------------------------- /docs/gui/siegemanager.rst: -------------------------------------------------------------------------------- 1 | gui/siegemanager 2 | ================ 3 | 4 | .. dfhack-tool:: 5 | :summary: Manage siege engines at a glance 6 | :tags: buildings interface productivity 7 | 8 | This interface provides a list of siege engines, their ammo count, and current active 9 | jobs whilst providing shortcuts to configure their firing/standy mode and view them in-world. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | gui/siegemanager 17 | -------------------------------------------------------------------------------- /devel/nuke-items.lua: -------------------------------------------------------------------------------- 1 | -- Delete ALL items not held by units, buildings or jobs 2 | 3 | local count = 0 4 | 5 | for _,v in ipairs(df.global.world.items.all) do 6 | if not (v.flags.in_building or v.flags.construction or v.flags.in_job 7 | or dfhack.items.getGeneralRef(v,df.general_ref_type.UNIT_HOLDER)) then 8 | count = count + 1 9 | dfhack.items.remove(v) 10 | end 11 | end 12 | 13 | print('Deletion requested: '..count) 14 | -------------------------------------------------------------------------------- /docs/devel/check-other-ids.rst: -------------------------------------------------------------------------------- 1 | devel/check-other-ids 2 | ===================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Verify that game entities are referenced by the correct vectors. 6 | :tags: dev 7 | 8 | This script runs through all ``world.items.other`` and ``world.buildings.other`` vectors 9 | and verifies that the items contained in them have the expected types. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | devel/check-other-ids 17 | -------------------------------------------------------------------------------- /docs/devel/tree-info.rst: -------------------------------------------------------------------------------- 1 | devel/tree-info 2 | =============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Print a tree_info visualization of the tree at the cursor. 6 | :tags: dev 7 | 8 | Print a tree_info visualization of the tree at the cursor. For each tile it 9 | prints a representation of trunk/branch/twig/blocked flags, then branch 10 | direction, then parent direction. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | devel/tree-info 18 | -------------------------------------------------------------------------------- /docs/devel/light.rst: -------------------------------------------------------------------------------- 1 | devel/light 2 | =========== 3 | 4 | .. dfhack-tool:: 5 | :summary: Experiment with lighting overlays. 6 | :tags: unavailable 7 | 8 | This is an experimental lighting engine for DF, using the `rendermax` plugin. 9 | 10 | Press :kbd:`~` to recalculate lighting. Press :kbd:`\`` to exit. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | devel/light [static] 18 | 19 | Pass ``static`` to not recalculate lighting when in game. 20 | -------------------------------------------------------------------------------- /docs/fix/civil-war.rst: -------------------------------------------------------------------------------- 1 | fix/civil-war 2 | ============= 3 | 4 | .. dfhack-tool:: 5 | :summary: Removes a civil war. 6 | :tags: fort bugfix 7 | 8 | This script removes a negative relation with your own government (civil war). 9 | 10 | If caravans/migrants do not return after fixing the civil war, try running "force Caravan" and trading to increase wealth exported to parent civ. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | fix/civil-war 18 | -------------------------------------------------------------------------------- /docs/reveal-hidden-units.rst: -------------------------------------------------------------------------------- 1 | reveal-hidden-units 2 | =================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Reveal sneaking units. 6 | :tags: adventure fort armok map units 7 | 8 | This tool exposes all units on the map who are currently sneaking or waiting in 9 | ambush, and thus hidden from the player's view. 10 | 11 | It is usable in both fortress and adventure mode. 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | reveal-hidden-units 19 | -------------------------------------------------------------------------------- /docs/gui/spectate.rst: -------------------------------------------------------------------------------- 1 | gui/spectate 2 | ============ 3 | 4 | .. dfhack-tool:: 5 | :summary: Automated spectator mode. 6 | :tags: fort inspection interface 7 | 8 | This is an in-game configuration interface for `spectate`, which automatically 9 | sets the camera to follow interesting units. 10 | 11 | You can configure the overlay tooltip settings as well as the follow mode 12 | settings. 13 | 14 | Usage 15 | ----- 16 | 17 | :: 18 | 19 | gui/spectate 20 | -------------------------------------------------------------------------------- /docs/setfps.rst: -------------------------------------------------------------------------------- 1 | setfps 2 | ====== 3 | 4 | .. dfhack-tool:: 5 | :summary: Set the graphics FPS cap. 6 | :tags: dfhack fps 7 | 8 | This command can set the FPS cap at runtime. This is useful for when you want to 9 | speed up the game or watch combat in slow motion. 10 | 11 | Note that setting the cap higher than what your computer can support will not 12 | make the game go any faster. 13 | 14 | Usage 15 | ----- 16 | 17 | :: 18 | 19 | setfps 20 | -------------------------------------------------------------------------------- /docs/gui/masspit.rst: -------------------------------------------------------------------------------- 1 | gui/masspit 2 | =========== 3 | 4 | .. dfhack-tool:: 5 | :summary: Designate creatures for pitting. 6 | :tags: fort productivity animals 7 | 8 | Using this tool you can designate all caged creatures in an animal stockpile to 9 | be sent to a pit. 10 | 11 | The script provides a visual interface, you can select the stockpile/pit using 12 | keyboard controls or click the map. 13 | 14 | Usage 15 | ----- 16 | 17 | :: 18 | 19 | gui/masspit 20 | -------------------------------------------------------------------------------- /docs/weather.rst: -------------------------------------------------------------------------------- 1 | weather 2 | ======= 3 | 4 | .. dfhack-tool:: 5 | :summary: Change the weather. 6 | :tags: fort armok inspection map 7 | 8 | This tool allows you to inspect or control the weather. 9 | 10 | Usage 11 | ----- 12 | 13 | ``weather`` 14 | Print a map of the local weather. 15 | ``weather clear|rain|snow`` 16 | Change the weather as specified. 17 | 18 | Examples 19 | -------- 20 | 21 | ``weather clear`` 22 | Make it stop raining/snowing. 23 | -------------------------------------------------------------------------------- /fix/civil-war.lua: -------------------------------------------------------------------------------- 1 | -- Reverts a civil war state 2 | 3 | local civ = df.historical_entity.find(df.global.plotinfo.civ_id) 4 | 5 | local fixed = false 6 | for _, entity in ipairs(civ.relations.diplomacy.state) do 7 | if entity.group_id == civ.id and entity.relation > 0 then 8 | entity.relation = 0 9 | fixed = true 10 | end 11 | end 12 | 13 | if fixed then 14 | print("Civil war removed!") 15 | else 16 | print("No civil war found.") 17 | end 18 | -------------------------------------------------------------------------------- /docs/gui/clone-uniform.rst: -------------------------------------------------------------------------------- 1 | gui/clone-uniform 2 | ================= 3 | 4 | .. dfhack-tool:: 5 | :summary: Duplicate an existing military uniform. 6 | :tags: unavailable 7 | 8 | When invoked, this tool duplicates the currently selected uniform template and 9 | selects the newly created copy. Activate in the :guilabel:`Uniforms` page of the 10 | military screen with the cursor in the leftmost list. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | gui/clone-uniform 18 | -------------------------------------------------------------------------------- /docs/devel/annc-monitor.rst: -------------------------------------------------------------------------------- 1 | devel/annc-monitor 2 | ================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Track announcements and reports and echo them to the console. 6 | :tags: dev 7 | 8 | This tool monitors announcements and reports and echoes their contents to the 9 | console. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | enable devel/annc-monitor 17 | devel/annc-monitor report enable|disable 18 | 19 | Combat report monitoring is disabled by default. 20 | -------------------------------------------------------------------------------- /docs/devel/test-perlin.rst: -------------------------------------------------------------------------------- 1 | devel/test-perlin 2 | ================= 3 | 4 | .. dfhack-tool:: 5 | :summary: Generate an image based on perlin noise. 6 | :tags: unavailable 7 | 8 | Generates an image using multiple octaves of perlin noise. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | devel/test-perlin [-xy ] [-z ] 16 | 17 | The inquisitive will have to inspect the code to determine the meaning of the 18 | parameters. 19 | -------------------------------------------------------------------------------- /docs/flashstep.rst: -------------------------------------------------------------------------------- 1 | flashstep 2 | ========= 3 | 4 | .. dfhack-tool:: 5 | :summary: Teleport your adventurer to the mouse cursor. 6 | :tags: adventure armok units 7 | 8 | ``flashstep`` is a hotkey-friendly teleport that places your adventurer where 9 | your mouse cursor is. A small area around the target tile is revealed. If you 10 | take a step, then the normal vision cone area around the unit is revealed. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | flashstep 18 | -------------------------------------------------------------------------------- /multicmd.lua: -------------------------------------------------------------------------------- 1 | -- Run multiple dfhack commands separated by ';' 2 | --[====[ 3 | 4 | multicmd 5 | ======== 6 | Run multiple dfhack commands. The argument is split around the character ";", 7 | and all parts are run sequentially as independent dfhack commands. Useful for 8 | hotkeys. 9 | 10 | Example:: 11 | 12 | multicmd locate-ore IRON; digv; digcircle 16 13 | ]====] 14 | 15 | for _,cmd in ipairs(table.concat({...}, ' '):split(';+')) do 16 | dfhack.run_command(cmd) 17 | end 18 | -------------------------------------------------------------------------------- /ungeld.lua: -------------------------------------------------------------------------------- 1 | utils = require('utils') 2 | 3 | local validArgs = utils.invert({ 4 | 'unit', 5 | 'help', 6 | }) 7 | local args = utils.processArgs({...}, validArgs) 8 | 9 | if args.help then 10 | print(dfhack.script_help()) 11 | return 12 | end 13 | 14 | local geld_args = {'-ungeld'} 15 | 16 | if args.unit then 17 | table.insert(geld_args, '-unit') 18 | table.insert(geld_args, args.unit) 19 | end 20 | 21 | dfhack.run_script('geld', table.unpack(geld_args)) 22 | -------------------------------------------------------------------------------- /docs/migrants-now.rst: -------------------------------------------------------------------------------- 1 | migrants-now 2 | ============ 3 | 4 | .. dfhack-tool:: 5 | :summary: Trigger a migrant wave. 6 | :tags: fort armok units 7 | 8 | This tool can trigger an immediate migrant wave. Note that it only works after 9 | at least one wave of migrants have arrived naturally, and that no migrants are 10 | actually guaranteed to arrive (especially if you've just run this command a few 11 | times). 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | migrants-now 19 | -------------------------------------------------------------------------------- /docs/modtools/reaction-trigger-transition.rst: -------------------------------------------------------------------------------- 1 | modtools/reaction-trigger-transition 2 | ==================================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Help create reaction triggers. 6 | :tags: unavailable 7 | 8 | Prints useful things to the console and a file to help modders 9 | transition from ``autoSyndrome`` to `modtools/reaction-trigger`. 10 | 11 | This script is basically an apology for breaking backward 12 | compatibility in June 2014, and will be removed eventually. 13 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 2 | DESTINATION ${DFHACK_DATA_DESTINATION} 3 | FILES_MATCHING PATTERN "*.lua" 4 | PATTERN "*.json" 5 | PATTERN "scripts/docs" EXCLUDE 6 | PATTERN "scripts/test" EXCLUDE 7 | ) 8 | 9 | if(BUILD_TESTS) 10 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/test/ 11 | DESTINATION ${DFHACK_DATA_DESTINATION}/scripts/test/scripts 12 | ) 13 | endif() 14 | -------------------------------------------------------------------------------- /docs/devel/list-filters.rst: -------------------------------------------------------------------------------- 1 | devel/list-filters 2 | ================== 3 | 4 | .. dfhack-tool:: 5 | :summary: List input items for the selected building type. 6 | :tags: unavailable 7 | 8 | This tool lists input items for the building that is currently being built. You 9 | must be in build mode and have a building type selected for placement. This is 10 | where the filters in :file:`lua/dfhack/buildings.lua` come from. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | devel/list-filters 18 | -------------------------------------------------------------------------------- /docs/devel/visualize-structure.rst: -------------------------------------------------------------------------------- 1 | devel/visualize-structure 2 | ========================= 3 | 4 | .. dfhack-tool:: 5 | :summary: Display raw memory of a DF data structure. 6 | :tags: dev 7 | 8 | Displays the raw memory of a structure, field by field. Useful for checking if 9 | structures are aligned. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | devel/visualize-structure 17 | 18 | Example 19 | ------- 20 | 21 | :: 22 | 23 | devel/visualize-structure df.global.cursor 24 | -------------------------------------------------------------------------------- /docs/fillneeds.rst: -------------------------------------------------------------------------------- 1 | fillneeds 2 | ========= 3 | 4 | .. dfhack-tool:: 5 | :summary: Temporarily satisfy the needs of a unit. 6 | :tags: fort armok units 7 | 8 | Use with a unit selected to make them focused and unstressed. 9 | 10 | Usage 11 | ----- 12 | 13 | ``fillneeds`` 14 | Make the selected unit focused and unstressed. 15 | ``fillneeds --unit `` 16 | Make the specified unit focused and unstressed. 17 | ``fillneeds --all`` 18 | Make all citizens and residents focused and unstressed. 19 | -------------------------------------------------------------------------------- /docs/gui/stamper.rst: -------------------------------------------------------------------------------- 1 | gui/stamper 2 | =========== 3 | 4 | .. dfhack-tool:: 5 | :summary: Copy, paste, and transform dig designations. 6 | :tags: unavailable 7 | 8 | This tool allows you to copy and paste blocks of dig designations. You can also 9 | transform what you have copied by shifting it, reflecting it, rotating it, 10 | and/or inverting it. Designations can also be used as brushes to erase other 11 | designations and cancel constructions. 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | gui/stamper 19 | -------------------------------------------------------------------------------- /docs/gui/color-schemes.rst: -------------------------------------------------------------------------------- 1 | gui/color-schemes 2 | ================= 3 | 4 | .. dfhack-tool:: 5 | :summary: Modify the colors in the DF UI. 6 | :tags: unavailable 7 | 8 | This is an in-game interface for `color-schemes`, which allows you to modify the 9 | colors in the Dwarf Fortress interface. This script must be called from either 10 | the title screen (shown when you first start the Dwarf Fortress game) or the 11 | fortress main map screen. 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | gui/color-schemes 19 | -------------------------------------------------------------------------------- /docs/fixnaked.rst: -------------------------------------------------------------------------------- 1 | fixnaked 2 | ======== 3 | 4 | .. dfhack-tool:: 5 | :summary: Removes all unhappy thoughts due to lack of clothing. 6 | :tags: unavailable 7 | 8 | If you're having trouble keeping your dwarves properly clothed and the stress is 9 | mounting, this tool can help you calm things down. ``fixnaked`` will go through 10 | each of your units, scan for unhappy thoughts due to lack of clothing, and 11 | remove the unhappy thoughts from your dwarves' minds. 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | fixnaked 19 | -------------------------------------------------------------------------------- /docs/gui/autofish.rst: -------------------------------------------------------------------------------- 1 | gui/autofish 2 | ============ 3 | 4 | .. dfhack-tool:: 5 | :summary: Auto-manage fishing labors to control your stock of fish. 6 | :tags: fort auto labors 7 | 8 | This is the configuration interface for the `autofish` module. You can configure 9 | the number of fish you'd like to keep in stock, and whether or not the script 10 | should also count your raw fish. You can also check whether or not autofish is 11 | currently fishing or not. 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | gui/autofish 19 | -------------------------------------------------------------------------------- /docs/gui/room-list.rst: -------------------------------------------------------------------------------- 1 | gui/room-list 2 | ============= 3 | 4 | .. dfhack-tool:: 5 | :summary: Manage rooms owned by a dwarf. 6 | :tags: unavailable 7 | 8 | When invoked in :kbd:`q` mode with the cursor over an owned room, this tool 9 | lists other rooms owned by the same owner, or by the unit selected in the assign 10 | list, and allows unassigning them from other rooms. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | gui/room-list 18 | 19 | Screenshot 20 | ---------- 21 | 22 | .. image:: /docs/images/room-list.png 23 | -------------------------------------------------------------------------------- /hotkey-notes.lua: -------------------------------------------------------------------------------- 1 | -- prints info on assigned hotkeys to the console 2 | --[====[ 3 | 4 | hotkey-notes 5 | ============ 6 | Lists the key, name, and jump position of your hotkeys in the DFHack console. 7 | 8 | ]====] 9 | 10 | for i=1, #df.global.plotinfo.main.hotkeys do 11 | local hk = df.global.plotinfo.main.hotkeys[i-1] 12 | local key = dfhack.screen.getKeyDisplay(df.interface_key.D_HOTKEY1 + i - 1) 13 | if hk.cmd ~= -1 then 14 | print(key..': '..hk.name..': x='..hk.x..' y='..hk.y..' z='..hk.z) 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /docs/fix/loyaltycascade.rst: -------------------------------------------------------------------------------- 1 | fix/loyaltycascade 2 | ================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Halts loyalty cascades where dwarves are fighting dwarves. 6 | :tags: fort bugfix units 7 | 8 | This tool neutralizes loyalty cascades by fixing units who consider their own 9 | civilization to be the enemy. It will also halt all fighting on the map that 10 | involves your citizens, though "real" enemies will re-engage in combat after a 11 | short delay. 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | fix/loyaltycascade 19 | -------------------------------------------------------------------------------- /docs/gui/manipulator.rst: -------------------------------------------------------------------------------- 1 | gui/manipulator 2 | =============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Multi-function unit management interface. 6 | :tags: unavailable 7 | 8 | This spreadsheet-like UI allows you to see all your units, their skills, 9 | properties, assignments, etc. at a glance. You can search, sort, and filter to 10 | see exactly the information that you're looking for. Moreover, you can assign 11 | units to burrows, squads, work details, and workshops. 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | gui/manipulator 19 | -------------------------------------------------------------------------------- /docs/gui/prerelease-warning.rst: -------------------------------------------------------------------------------- 1 | gui/prerelease-warning 2 | ====================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Shows a warning if you are using a pre-release build of DFHack. 6 | :tags: dfhack 7 | 8 | This tool shows a warning on world load for pre-release builds. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | gui/prerelease-warning [force] 16 | 17 | With no arguments passed, the warning is shown unless the "do not show again" 18 | option has been selected. With the ``force`` argument, the warning is always 19 | shown. 20 | -------------------------------------------------------------------------------- /ghostly.lua: -------------------------------------------------------------------------------- 1 | if not dfhack.world.isAdventureMode() then 2 | qerror('This script must be used in adventure mode') 3 | end 4 | 5 | local unit = dfhack.world.getAdventurer() 6 | if unit then 7 | if unit.flags1.inactive then 8 | unit.flags1.inactive = false 9 | unit.flags3.ghostly = true 10 | elseif unit.body.components.body_part_status[0].missing then 11 | unit.flags1.inactive = true 12 | unit.flags3.ghostly = false 13 | else 14 | unit.flags3.ghostly = not unit.flags3.ghostly 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /docs/ungeld.rst: -------------------------------------------------------------------------------- 1 | ungeld 2 | ====== 3 | 4 | .. dfhack-tool:: 5 | :summary: Undo gelding for an animal. 6 | :tags: fort armok animals 7 | 8 | This tool will restore an animal's ability to reproduce after it has been 9 | gelded. Also see `geld` if you'd like to re-geld the animal. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | ungeld [--unit ] 17 | 18 | Options 19 | ------- 20 | 21 | ``--unit `` 22 | Ungelds the unit with the specified ID. If this option is not specified, the 23 | default is to use the currently selected unit. 24 | -------------------------------------------------------------------------------- /docs/modtools/anonymous-script.rst: -------------------------------------------------------------------------------- 1 | modtools/anonymous-script 2 | ========================= 3 | 4 | .. dfhack-tool:: 5 | :summary: Run dynamically generated script code. 6 | :tags: unavailable 7 | 8 | This allows running a short simple Lua script passed as an argument instead of 9 | running a script from a file. This is useful when you want to do something too 10 | complicated to make with the existing modtools, but too simple to be worth its 11 | own script file. Example:: 12 | 13 | anonymous-script "print(args[1])" arg1 arg2 14 | # prints "arg1" 15 | -------------------------------------------------------------------------------- /internal/journal/contexts/dummy.lua: -------------------------------------------------------------------------------- 1 | --@ module = true 2 | 3 | -- Dummy Context, no storage -- 4 | 5 | DummyJournalContext = defclass(DummyJournalContext) 6 | 7 | function DummyJournalContext:save_content(text, cursor) 8 | end 9 | 10 | function DummyJournalContext:load_content() 11 | return {text={''}, cursor={1}, show_tutorial=true} 12 | end 13 | 14 | function DummyJournalContext:delete_content() 15 | end 16 | 17 | function DummyJournalContext:welcomeCopy() 18 | return '' 19 | end 20 | 21 | function DummyJournalContext:tocWelcomeCopy() 22 | return '' 23 | end 24 | -------------------------------------------------------------------------------- /docs/trackstop.rst: -------------------------------------------------------------------------------- 1 | trackstop 2 | ========= 3 | 4 | .. dfhack-tool:: 5 | :summary: Add dynamic configuration options for track stops. 6 | :tags: fort buildings interface 7 | 8 | This script provides 2 overlays that are managed by the `overlay` framework. The script does nothing when executed. 9 | The trackstop overlay allows the player to change the friction and dump direction of a selected track stop after it has been constructed. 10 | The rollers overlay allows the player to change the roller direction and speed of a selected roller after it has been constructed. 11 | -------------------------------------------------------------------------------- /docs/elevate-mental.rst: -------------------------------------------------------------------------------- 1 | elevate-mental 2 | ============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Set mental attributes of a dwarf to an ideal. 6 | :tags: fort armok units 7 | 8 | Set all mental attributes of the selected dwarf to the maximum possible, or 9 | any value between 0 and 5000. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | elevate-mental [value] 17 | 18 | Examples 19 | -------- 20 | 21 | ``elevate-mental`` 22 | Boost mental attributes of the selected dwarf to the maximum. 23 | ``elevate-mental 100`` 24 | Make the selected dwarf very stupid indeed. 25 | -------------------------------------------------------------------------------- /docs/fix/sleepers.rst: -------------------------------------------------------------------------------- 1 | fix/sleepers 2 | ============ 3 | 4 | .. dfhack-tool:: 5 | :summary: Fixes sleeping units belonging to a camp that never wake up. 6 | :tags: adventure bugfix 7 | 8 | Fixes :bug:`6798`. This bug is characterized by sleeping units who refuse to 9 | awaken in adventure mode regardless of talking to them, hitting them, or waiting 10 | so long you die of thirst. If you come across one or more bugged sleepers in 11 | adventure mode, simply run the script and all nearby sleepers will be cured. 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | fix/sleepers 19 | -------------------------------------------------------------------------------- /docs/fix/stable-temp.rst: -------------------------------------------------------------------------------- 1 | fix/stable-temp 2 | =============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Solve FPS issues caused by fluctuating temperature. 6 | :tags: fort bugfix fps map 7 | 8 | This tool instantly sets the temperature of all free-lying items to be in 9 | equilibrium with the environment. This effectively halts FPS-draining 10 | temperature updates until something changes, such as letting magma flow to new 11 | tiles. 12 | 13 | To maintain this efficient state, use `tweak fast-heat `. 14 | 15 | Usage 16 | ----- 17 | 18 | :: 19 | 20 | fix/stable-temp 21 | -------------------------------------------------------------------------------- /docs/gui/quickcmd.rst: -------------------------------------------------------------------------------- 1 | gui/quickcmd 2 | ============ 3 | 4 | .. dfhack-tool:: 5 | :summary: Quickly run saved commands. 6 | :tags: dfhack 7 | 8 | This tool lets you keep a list of commands that you use often enough to not want 9 | to type it every time, but not often enough to be bothered to find a free 10 | keybinding. You can edit and save the commands from the UI. 11 | 12 | Also see `gui/launcher`, whose history search functionality allows you to run 13 | commands from your command history quickly and easily. 14 | 15 | Usage 16 | ----- 17 | 18 | :: 19 | 20 | gui/quickcmd 21 | -------------------------------------------------------------------------------- /docs/gui/stockpiles.rst: -------------------------------------------------------------------------------- 1 | gui/stockpiles 2 | ============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Import and export stockpile settings. 6 | :tags: unavailable 7 | 8 | With a stockpile selected in :kbd:`q` mode, you can use this tool to load 9 | stockpile settings from a file or save them to a file for later loading, in 10 | this fort or any other. 11 | 12 | Saved stockpile configs are stored in the :file:`stocksettings` subfolder in 13 | the DF folder. 14 | 15 | See `stockpiles` for a commandline interface. 16 | 17 | Usage 18 | ----- 19 | 20 | :: 21 | 22 | gui/stockpiles 23 | -------------------------------------------------------------------------------- /docs/gui/workorder-details.rst: -------------------------------------------------------------------------------- 1 | gui/workorder-details 2 | ===================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Adjust input materials and traits for workorders. 6 | :tags: unavailable fort inspection workorders 7 | 8 | This tool allows you to adjust item types, materials, and/or traits for items 9 | used in manager workorders. The jobs created from those workorders will inherit 10 | the details. 11 | 12 | Invoke while on a work order's detail screen (:kbd:`j-m`, select work order, 13 | :kbd:`d`). 14 | 15 | Usage 16 | ----- 17 | 18 | :: 19 | 20 | gui/workorder-details 21 | -------------------------------------------------------------------------------- /docs/view-unit-reports.rst: -------------------------------------------------------------------------------- 1 | view-unit-reports 2 | ================= 3 | 4 | .. dfhack-tool:: 5 | :summary: Show combat reports for a unit. 6 | :tags: unavailable 7 | 8 | Show combat reports specifically for the selected unit. You can select a unit 9 | with the cursor in :kbd:`v` mode, from the list in :kbd:`u` mode, or from the 10 | unit/corpse/splatter list in :kbd:`k` mode. You can also select the newest unit 11 | with a particular race when looking at a race-specific blood spatter in 12 | :kbd:`k` mode. 13 | 14 | Usage 15 | ----- 16 | 17 | :: 18 | 19 | view-unit-reports 20 | -------------------------------------------------------------------------------- /docs/gui/confirm.rst: -------------------------------------------------------------------------------- 1 | gui/confirm 2 | =========== 3 | 4 | .. dfhack-tool:: 5 | :summary: Configure which confirmation dialogs are enabled. 6 | :tags: fort interface 7 | 8 | This tool is a basic configuration interface for `confirm`. You can see and 9 | modify which confirmation dialogs are enabled. Your selections will be saved as 10 | personal preferences, and will apply to all forts going forward. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | gui/confirm [] 18 | 19 | You can optionally pass the ID of a confirmation dialog to have it initially 20 | selected in the list. 21 | -------------------------------------------------------------------------------- /docs/gui/extended-status.rst: -------------------------------------------------------------------------------- 1 | gui/extended-status 2 | =================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Add information on beds and bedrooms to the status screen. 6 | :tags: unavailable 7 | 8 | Adds an additional page to the ``z`` status screen where you can see information 9 | about beds, bedrooms, and whether your dwarves have bedrooms of their own. 10 | 11 | Usage 12 | ----- 13 | 14 | ``enable gui/extended-status`` 15 | Show a hotkey on the status screen to invoke the bedroom_list screen. 16 | ``gui/extended-status bedroom_list`` 17 | Show the bedroom status screen. 18 | -------------------------------------------------------------------------------- /docs/gui/autochop.rst: -------------------------------------------------------------------------------- 1 | gui/autochop 2 | ============ 3 | 4 | .. dfhack-tool:: 5 | :summary: Auto-harvest trees when low on stockpiled logs. 6 | :tags: fort auto plants 7 | 8 | This is the configuration interface for the `autochop` plugin. You can configure 9 | which burrows will be used for tree chopping, your target stock quantities, and 10 | other options. You can also see how many logs you have, the number of logs that 11 | the trees on the map are estimated to yield, and how many of each are currently 12 | inaccessible. 13 | 14 | Usage 15 | ----- 16 | 17 | :: 18 | 19 | gui/autochop 20 | -------------------------------------------------------------------------------- /docs/reveal-adv-map.rst: -------------------------------------------------------------------------------- 1 | reveal-adv-map 2 | ============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Reveal or hide the world map. 6 | :tags: adventure armok map 7 | 8 | This tool can be used to either reveal or hide all tiles on the world map in 9 | adventure mode (visible when viewing the quest log or fast traveling). 10 | 11 | Note that hidden lairs, camps, etc. are not revealed. Please see 12 | `reveal-hidden-sites` for that functionality. 13 | 14 | Usage 15 | ----- 16 | 17 | ``reveal-adv-map`` 18 | Reveal all world tiles. 19 | ``reveal-adv-map --hide`` 20 | Hide all world tiles. 21 | -------------------------------------------------------------------------------- /devel/scanitemother.lua: -------------------------------------------------------------------------------- 1 | -- Display the item lists that the selected item is part of. 2 | local selected_item = dfhack.gui.getAnyItem() 3 | 4 | if not selected_item then 5 | qerror("This script requires an item selected!") 6 | end 7 | 8 | local indices = {} 9 | for index, value in pairs(df.global.world.items.other) do 10 | for _, item in pairs(value) do 11 | if item == selected_item then 12 | table.insert(indices, index) 13 | end 14 | end 15 | end 16 | 17 | print("Found in the following indices:") 18 | for _, index in pairs(indices) do 19 | print(" " .. index) 20 | end 21 | -------------------------------------------------------------------------------- /docs/fix/symbol-unstick.rst: -------------------------------------------------------------------------------- 1 | fix/symbol-unstick 2 | ================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Unstick noble symbols that cannot be re-designated. 6 | :tags: fort bugfix items 7 | 8 | Remove symbol designation from artifacts that cannot be re-designated 9 | after the noble's promotion to a higher position. 10 | 11 | Usage 12 | ----- 13 | 14 | ``fix/symbol-unstick`` 15 | 16 | Select an artifact that was designated as a noble's symbol and run the 17 | command to remove its designation as a symbol. The operation will only 18 | be performed if the symbol is claimed by a vacated noble position. 19 | -------------------------------------------------------------------------------- /docs/forget-dead-body.rst: -------------------------------------------------------------------------------- 1 | forget-dead-body 2 | ================ 3 | 4 | .. dfhack-tool:: 5 | :summary: Removes emotions associated with seeing a dead body. 6 | :tags: unavailable 7 | 8 | This tool can help your dwarves recover from seeing a massacre. It removes all 9 | emotions associated with seeing a dead body. If your dwarves are traumatized and 10 | despondent after seeing a dead body, this tool can help. 11 | 12 | Usage 13 | ----- 14 | 15 | ``forget-dead-body`` 16 | Make the selected unit forget seeing dead bodies. 17 | ``forget-dead-body --all`` 18 | Make all units forget seeing dead bodies. 19 | -------------------------------------------------------------------------------- /docs/gui/cp437-table.rst: -------------------------------------------------------------------------------- 1 | gui/cp437-table 2 | =============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Virtual keyboard for typing with the mouse. 6 | :tags: dfhack 7 | 8 | This tool provides an in-game virtual keyboard. You can choose from all the 9 | characters that DF supports (code page 437). Just click on the characters to 10 | build the text that you want to send to the parent screen. The text is sent 11 | as soon as you hit :kbd:`Enter`, so make sure there is a text field selected 12 | in the parent window before starting this UI! 13 | 14 | Usage 15 | ----- 16 | 17 | :: 18 | 19 | gui/cp437-table 20 | -------------------------------------------------------------------------------- /docs/gui/seedwatch.rst: -------------------------------------------------------------------------------- 1 | gui/seedwatch 2 | ============= 3 | 4 | .. dfhack-tool:: 5 | :summary: Manages seed and plant cooking based on seed stock levels. 6 | :tags: fort auto plants 7 | 8 | This is the configuration interface for the `seedwatch` plugin. You can 9 | configure a target stock amount for each seed type. If the number of seeds of 10 | that type falls below the target, then the plants and seeds of that type will 11 | be protected from cookery. If the number rises above the target + 20, then 12 | cooking will be allowed again. 13 | 14 | Usage 15 | ----- 16 | 17 | :: 18 | 19 | gui/seedwatch 20 | -------------------------------------------------------------------------------- /docs/gui/dfstatus.rst: -------------------------------------------------------------------------------- 1 | gui/dfstatus 2 | ============ 3 | 4 | .. dfhack-tool:: 5 | :summary: Show a quick overview of critical stock quantities. 6 | :tags: unavailable 7 | 8 | This tool show a quick overview of stock quantities for: 9 | 10 | - drinks 11 | - wood 12 | - fuel 13 | - prepared_meals 14 | - tanned_hides 15 | - cloth 16 | - various metal bars 17 | 18 | Sections can be enabled/disabled/configured by modifying 19 | :file:`dfhack-config/dfstatus.lua`. In particular, you can customize the list 20 | of metals that you want to report on. 21 | 22 | Usage 23 | ----- 24 | 25 | :: 26 | 27 | gui/dfstatus 28 | -------------------------------------------------------------------------------- /docs/gui/liquids.rst: -------------------------------------------------------------------------------- 1 | gui/liquids 2 | =========== 3 | 4 | .. dfhack-tool:: 5 | :summary: Interactively paint liquids onto the map. 6 | :tags: fort armok map 7 | 8 | This tool is a gui for spawning water, magma, and river sources on the map, 9 | allowing you to click and paint liquid onto the map. It can optionally clean 10 | existing liquids on the map from salt or being stagnant. 11 | 12 | .. warning:: 13 | 14 | There is **no undo support**. Be sure you know what you are doing before 15 | spawning any liquid, especially river sources! 16 | 17 | Usage 18 | ----- 19 | 20 | :: 21 | 22 | gui/liquids 23 | -------------------------------------------------------------------------------- /docs/fix/engravings.rst: -------------------------------------------------------------------------------- 1 | fix/engravings 2 | ============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Fixes unengravable corrupted tiles so they are able to be engraved. 6 | :tags: fort bugfix 7 | 8 | When constructing a new wall or new floor over a previously engraved tile, the tile may become corrupted and unengravable. 9 | This fix detects the problem and resets the state of those tiles so they may be engraved again. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | fix/engravings [] 17 | 18 | Options 19 | ------- 20 | 21 | ``-q``, ``--quiet`` 22 | Only output status when something was actually fixed. 23 | -------------------------------------------------------------------------------- /docs/reveal-hidden-sites.rst: -------------------------------------------------------------------------------- 1 | reveal-hidden-sites 2 | =================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Reveal all sites in the world. 6 | :tags: adventure embark fort armok map 7 | 8 | This tool reveals all sites in the world that have yet to be discovered by the 9 | player (camps, lairs, shrines, vaults, etc), making them visible on the map. 10 | 11 | It is usable in both fortress and adventure mode, or on the embark map. 12 | 13 | Please see `reveal-adv-map` if you also want to expose hidden world map tiles in 14 | adventure mode. 15 | 16 | Usage 17 | ----- 18 | 19 | :: 20 | 21 | reveal-hidden-sites 22 | -------------------------------------------------------------------------------- /docs/immortal-cravings.rst: -------------------------------------------------------------------------------- 1 | immortal-cravings 2 | ================= 3 | 4 | .. dfhack-tool:: 5 | :summary: Allow immortals to satisfy their cravings for food and drink. 6 | :tags: fort gameplay 7 | 8 | When enabled, this script watches your fort for units that have no physiological 9 | need to eat or drink but still have personality needs that can only be satisfied 10 | by eating or drinking (e.g. necromancers or goblins). This enables those units 11 | to help themselves to a drink or a meal when they crave one and are not 12 | otherwise occupied. 13 | 14 | Usage 15 | ----- 16 | 17 | :: 18 | 19 | enable immortal-cravings 20 | -------------------------------------------------------------------------------- /resurrect-adv.lua: -------------------------------------------------------------------------------- 1 | local fullHeal = reqscript('full-heal') 2 | 3 | if not dfhack.world.isAdventureMode() then 4 | qerror("This script can only be used in adventure mode!") 5 | end 6 | 7 | local adventurer = dfhack.world.getAdventurer() 8 | if not adventurer or not adventurer.flags2.killed then 9 | qerror("Your adventurer hasn't died yet!") 10 | end 11 | 12 | fullHeal.heal(adventurer, true) 13 | 14 | -- this ensures that the player will be able to regain control of their unit after 15 | -- resurrection if the script is run before hitting DONE at the "You are deceased" message 16 | df.global.adventure.player_control_state = 1 17 | -------------------------------------------------------------------------------- /docs/resurrect-adv.rst: -------------------------------------------------------------------------------- 1 | resurrect-adv 2 | ============= 3 | 4 | .. dfhack-tool:: 5 | :summary: Bring a dead adventurer back to life. 6 | :tags: adventure armok units 7 | 8 | Have you ever died, but wish you hadn't? This tool can help : ) When you see the 9 | "You are deceased" message, run this command to be resurrected and fully healed. 10 | 11 | Usage 12 | ----- 13 | 14 | :: 15 | 16 | resurrect-adv 17 | 18 | Note that you can only resurrect the current player character in your party, and 19 | you must run this tool immediately after dying. It is not possible to resurrect 20 | the adventurer after the game has been ended. 21 | -------------------------------------------------------------------------------- /docs/devel/sc.rst: -------------------------------------------------------------------------------- 1 | devel/sc 2 | ======== 3 | 4 | .. dfhack-tool:: 5 | :summary: Scan DF structures for errors. 6 | :tags: dev 7 | 8 | Size Check: scans structures for invalid vectors, misaligned structures, and 9 | unidentified enum values. 10 | 11 | .. note:: 12 | 13 | This script can take a very long time to complete, and DF may be 14 | unresponsive while it is running. You can use `kill-lua` to interrupt 15 | this script. 16 | 17 | Usage 18 | ----- 19 | 20 | ``devel/sc`` 21 | Scan ``world``. 22 | ``devel/sc -all`` 23 | Scan all globals. 24 | ``devel/sc `` 25 | Scan the result of the given expression. 26 | -------------------------------------------------------------------------------- /docs/fix/general-strike.rst: -------------------------------------------------------------------------------- 1 | fix/general-strike 2 | ================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Prevent dwarves from getting stuck and refusing to work. 6 | :tags: fort bugfix 7 | 8 | This script attempts to fix known causes of the "general strike bug", where 9 | dwarves just stop accepting work and stand around with "No job". 10 | 11 | This script is set to run periodically by default in `gui/control-panel`. 12 | 13 | Usage 14 | ----- 15 | 16 | :: 17 | 18 | fix/general-strike [] 19 | 20 | Options 21 | ------- 22 | 23 | ``-q``, ``--quiet`` 24 | Only output status when something was actually fixed. 25 | -------------------------------------------------------------------------------- /docs/hermit.rst: -------------------------------------------------------------------------------- 1 | hermit 2 | ====== 3 | 4 | .. dfhack-tool:: 5 | :summary: Go it alone in your fortress and attempt the hermit challenge. 6 | :tags: fort gameplay 7 | 8 | This script blocks all caravans, migrants, diplomats, and forgotten beasts (not 9 | wildlife) from entering your fort. Useful for attempting the 10 | `hermit challenge`_. 11 | 12 | .. warning:: 13 | 14 | This script does not block sieges, and may not block visitors or monarchs. 15 | 16 | Usage 17 | ----- 18 | 19 | :: 20 | 21 | enable hermit 22 | hermit [status] 23 | 24 | .. _hermit challenge: http://dwarffortresswiki.org/index.php/Playstyle_challenge#Hermit 25 | -------------------------------------------------------------------------------- /fix/occupancy.lua: -------------------------------------------------------------------------------- 1 | local argparse = require('argparse') 2 | local plugin = require('plugins.fix-occupancy') 3 | 4 | local opts = { 5 | dry_run=false, 6 | } 7 | 8 | local positionals = argparse.processArgsGetopt({...}, { 9 | { 'h', 'help', handler = function() opts.help = true end }, 10 | { 'n', 'dry-run', handler = function() opts.dry_run = true end }, 11 | }) 12 | 13 | if positionals[1] == 'help' or opts.help then 14 | print(dfhack.script_help()) 15 | return 16 | end 17 | 18 | if not positionals[1] then 19 | plugin.fix_map(opts.dry_run) 20 | else 21 | plugin.fix_tile(argparse.coords(positionals[1], 'pos'), opts.dry_run) 22 | end 23 | -------------------------------------------------------------------------------- /setfps.lua: -------------------------------------------------------------------------------- 1 | -- Set the FPS cap at runtime. 2 | --[====[ 3 | 4 | setfps 5 | ====== 6 | Sets the FPS cap at runtime. Useful in case you want to speed up the game or 7 | watch combat in slow motion. 8 | 9 | Usage:: 10 | 11 | setfps 12 | 13 | ]====] 14 | 15 | local cap = ... 16 | local capnum = tonumber(cap) 17 | 18 | if not cap or cap:match('help') then 19 | print('Usage:\n\tsetfps ') 20 | return 21 | end 22 | 23 | if not capnum or capnum < 1 then 24 | qerror('Invalid FPS cap value: '..cap) 25 | end 26 | 27 | df.global.enabler.fps = capnum 28 | df.global.enabler.fps_per_gfps = df.global.enabler.fps / df.global.enabler.gfps 29 | -------------------------------------------------------------------------------- /docs/extinguish.rst: -------------------------------------------------------------------------------- 1 | extinguish 2 | ========== 3 | 4 | .. dfhack-tool:: 5 | :summary: Put out fires. 6 | :tags: fort adventure armok buildings items map units 7 | 8 | With this tool, you can put out fires affecting map tiles, plants, units, items, 9 | and buildings. 10 | 11 | Select a target in the UI or enable the keyboard cursor place it over the 12 | target tile before running the script. 13 | 14 | If your FPS is unplayably low because of the generated smoke, see `clear-smoke`. 15 | 16 | Usage 17 | ----- 18 | 19 | ``extinguish`` 20 | Put out the fire affecting the selected unit/item/map tile. 21 | ``extinguish --all`` 22 | Put out all fires on the map. 23 | -------------------------------------------------------------------------------- /docs/gui/power-meter.rst: -------------------------------------------------------------------------------- 1 | gui/power-meter 2 | =============== 3 | 4 | .. dfhack-tool:: 5 | :summary: Allow pressure plates to measure power. 6 | :tags: unavailable 7 | 8 | If you run this tool after selecting :guilabel:`Pressure Plate` in the build 9 | menu, you will build a power meter building instead of a regular pressure plate. 10 | This means that, once the building is built, you can select it to see a 11 | readout of how much power is being supplied to gear boxes built in the four 12 | adjacent N/S/W/E tiles. 13 | 14 | Usage 15 | ----- 16 | 17 | :: 18 | 19 | gui/power-meter 20 | 21 | Screenshot 22 | ---------- 23 | 24 | .. image:: /docs/images/power-meter.png 25 | -------------------------------------------------------------------------------- /docs/modtools/create-tree.rst: -------------------------------------------------------------------------------- 1 | modtools/create-tree 2 | ==================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Spawn trees. 6 | :tags: unavailable 7 | 8 | Spawns a tree. 9 | 10 | Usage 11 | ----- 12 | 13 | :: 14 | 15 | -tree treeName 16 | specify the tree to be created 17 | examples: 18 | OAK 19 | NETHER_CAP 20 | 21 | -age howOld 22 | set the age of the tree in years (integers only) 23 | defaults to 1 if omitted 24 | 25 | -location [ x y z ] 26 | create the tree at the specified coordinates 27 | 28 | example: 29 | modtools/create-tree -tree OAK -age 100 -location [ 33 145 137 ] 30 | -------------------------------------------------------------------------------- /cannibalism.lua: -------------------------------------------------------------------------------- 1 | function unmark_inventory(inventory) 2 | for _, entry in ipairs(inventory) do 3 | entry.item.flags.dead_dwarf = false 4 | end 5 | end 6 | 7 | local scrn = dfhack.gui.getCurViewscreen() 8 | if df.viewscreen_itemst:is_instance(scrn) then 9 | scrn.item.flags.dead_dwarf = false --hint:df.viewscreen_itemst 10 | elseif df.viewscreen_dungeon_monsterstatusst:is_instance(scrn) then 11 | unmark_inventory(scrn.inventory) --hint:df.viewscreen_dungeon_monsterstatusst 12 | elseif df.global.adventure.menu == df.ui_advmode_menu.Inventory then 13 | unmark_inventory(dfhack.world.getAdventurer().inventory) 14 | else 15 | qerror('Unsupported context') 16 | end 17 | -------------------------------------------------------------------------------- /docs/points.rst: -------------------------------------------------------------------------------- 1 | points 2 | ====== 3 | 4 | .. dfhack-tool:: 5 | :summary: Sets available points at the embark screen. 6 | :tags: embark fort armok 7 | 8 | Run at the embark screen when you are choosing items to bring with you and 9 | skills to assign to your dwarves. You can set the available points to any 10 | number. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | points 18 | 19 | Examples 20 | -------- 21 | 22 | ``points 1000000`` 23 | Grant yourself enough points to buy everything you ever dreamed of. 24 | ``points 0`` 25 | Embark with nothing more than what you have already selected. You can make 26 | life quite difficult for yourself this way. 27 | -------------------------------------------------------------------------------- /docs/devel/scan-vtables.rst: -------------------------------------------------------------------------------- 1 | devel/scan-vtables 2 | ================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Scan for and print likely vtable addresses. 6 | :tags: dev 7 | 8 | .. warning:: 9 | 10 | THIS SCRIPT IS STRICTLY FOR DFHACK DEVELOPERS. 11 | 12 | Running this script on a new DF version will NOT MAKE IT RUN CORRECTLY if 13 | any data structures changed, thus possibly leading to CRASHES AND/OR 14 | PERMANENT SAVE CORRUPTION. 15 | 16 | This script scans for likely vtables in memory pages mapped to the DF 17 | executable, and prints them in a format ready for inclusion in ``symbols.xml`` 18 | 19 | Usage 20 | ----- 21 | 22 | :: 23 | 24 | devel/scan-vtables 25 | -------------------------------------------------------------------------------- /docs/linger.rst: -------------------------------------------------------------------------------- 1 | linger 2 | ====== 3 | 4 | .. dfhack-tool:: 5 | :summary: Take control of your adventurer's killer. 6 | :tags: unavailable 7 | 8 | Run this script after being presented with the "You are deceased." message to 9 | abandon your dead adventurer and take control of your adventurer's killer. 10 | 11 | The killer is identified by examining the historical event generated when the 12 | adventurer died. If this is unsuccessful, the killer is assumed to be the last 13 | unit to have attacked the adventurer prior to their death. 14 | 15 | This will fail if the unit in question is no longer present on the local map. 16 | 17 | Usage 18 | ----- 19 | 20 | :: 21 | 22 | linger 23 | -------------------------------------------------------------------------------- /docs/undump-buildings.rst: -------------------------------------------------------------------------------- 1 | undump-buildings 2 | ================ 3 | 4 | .. dfhack-tool:: 5 | :summary: Undesignate building base materials for dumping. 6 | :tags: fort productivity buildings 7 | 8 | If you designate a bunch of tiles in dump mode, all the items on those tiles 9 | will be marked for dumping. Unfortunately, if there are buildings on any of 10 | those tiles, the items that were used to *build* those buildings will also be 11 | uselessly and confusingly marked for dumping. 12 | 13 | This tool will scan for buildings that have their construction materials marked 14 | for dumping and will unmark them. 15 | 16 | Usage 17 | ----- 18 | 19 | :: 20 | 21 | undump-buildings 22 | -------------------------------------------------------------------------------- /docs/questport.rst: -------------------------------------------------------------------------------- 1 | questport 2 | ========= 3 | 4 | .. dfhack-tool:: 5 | :summary: Teleport to your quest log map cursor. 6 | :tags: unavailable 7 | 8 | If you open the quest log map and move the cursor to your target location, you 9 | can run this command to teleport straight there. This can be done both within 10 | and outside of fast travel mode, and it is possible to ``questport`` in 11 | situations where fast travel is normally prohibited. 12 | 13 | It is not possible to ``questport`` into inaccessible locations like ocean and 14 | mountain tiles. 15 | 16 | See `reveal-adv-map` if you wish to teleport into hidden map tiles. 17 | 18 | Usage 19 | ----- 20 | 21 | :: 22 | 23 | questport 24 | -------------------------------------------------------------------------------- /docs/elevate-physical.rst: -------------------------------------------------------------------------------- 1 | elevate-physical 2 | ================ 3 | 4 | .. dfhack-tool:: 5 | :summary: Set physical attributes of a dwarf to an ideal. 6 | :tags: fort armok units 7 | 8 | Set all physical attributes of the selected dwarf to the maximum possible, or 9 | any value between 0 and 5000. Higher is usually better, but an ineffective 10 | hammerer can be useful too... 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | elevate-physical [value] 18 | 19 | Examples 20 | -------- 21 | 22 | ``elevate-physical`` 23 | Boost physical attributes of the selected dwarf to the maximum. 24 | ``elevate-physical 100`` 25 | Ensure your hammerer won't kill any citizens when they get punished. 26 | -------------------------------------------------------------------------------- /devel/spawn-unit-helper.lua: -------------------------------------------------------------------------------- 1 | -- Allow arena creature spawn after a mode change 2 | 3 | for key, _ in pairs(df.global.world.arena.race) do 4 | df.global.world.arena.race[key] = nil 5 | end 6 | 7 | for key, _ in pairs(df.global.world.arena.caste) do 8 | df.global.world.arena.caste[key] = nil 9 | end 10 | 11 | for creature_index, _ in pairs(df.global.world.raws.creatures.all) do 12 | for caste_index, _ in pairs(df.global.world.raws.creatures.all[creature_index].caste) do 13 | df.global.world.arena.race:insert('#', creature_index) 14 | df.global.world.arena.caste:insert('#', caste_index) 15 | end 16 | end 17 | 18 | df.global.world.arena.creature_cnt[#df.global.world.arena.race - 1] = 0 19 | -------------------------------------------------------------------------------- /docs/devel/scanitemother.rst: -------------------------------------------------------------------------------- 1 | devel/scanitemother 2 | =================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Display the item lists that the selected item is part of. 6 | :tags: dev 7 | 8 | When an item is selected in the UI, this tool will list the indices in 9 | ``world.item.other[]`` where the item appears. For example, if a piece of good 10 | meat is selected in the UI, this tool might output:: 11 | 12 | IN_PLAY 13 | ANY_GOOD_FOOD 14 | ANY_EDIBLE_RAW 15 | ANY_EDIBLE_CARNIVORE 16 | ANY_EDIBLE_BONECARN 17 | ANY_EDIBLE_VERMIN 18 | ANY_EDIBLE_VERMIN_BOX 19 | ANY_CAN_ROT 20 | ANY_COOKABLE 21 | MEAT 22 | 23 | Usage 24 | ----- 25 | 26 | :: 27 | 28 | devel/scanitemother 29 | -------------------------------------------------------------------------------- /docs/unforbid.rst: -------------------------------------------------------------------------------- 1 | unforbid 2 | ======== 3 | 4 | .. dfhack-tool:: 5 | :summary: Unforbid all items. 6 | :tags: fort productivity items 7 | 8 | This tool quickly and easily unforbids all items. This is especially useful 9 | after a siege to allow cleaning up the mess (or dumping of caged prisoner's 10 | equipment with `stripcaged`). 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | unforbid all [] 18 | 19 | Options 20 | ------- 21 | 22 | ``-u``, ``--include-unreachable`` 23 | Allows the tool to unforbid unreachable items. 24 | 25 | ``-q``, ``--quiet`` 26 | Suppress non-error console output. 27 | 28 | ``-X``, ``--include-worn`` 29 | Include worn (X) and tattered (XX) items when unforbidding. 30 | -------------------------------------------------------------------------------- /test/quickfort/notes_unit.lua: -------------------------------------------------------------------------------- 1 | local notes = reqscript('internal/quickfort/notes') 2 | 3 | function test.module() 4 | expect.error_match( 5 | 'this script cannot be called directly', 6 | function() dfhack.run_script('internal/quickfort/notes') end) 7 | end 8 | 9 | function test.do_run() 10 | local grid = {[20]={[10]={cell='A1', text='row1'}}, 11 | [22]={[10]={cell='A3', text='row3'}}} 12 | local ctx = {messages={}} 13 | notes.do_run(nil, grid, ctx) 14 | expect.table_eq({'row1\n\nrow3'}, ctx.messages) 15 | end 16 | 17 | function test.do_orders() 18 | expect.nil_(notes.do_orders()) 19 | end 20 | 21 | function test.do_undo() 22 | expect.nil_(notes.do_undo()) 23 | end 24 | -------------------------------------------------------------------------------- /docs/devel/clear-script-env.rst: -------------------------------------------------------------------------------- 1 | devel/clear-script-env 2 | ====================== 3 | 4 | .. dfhack-tool:: 5 | :summary: Clear a lua script environment. 6 | :tags: dev 7 | 8 | This tool can clear the environment of the specified lua script(s). This is 9 | useful during development since if you remove a global function, an old version 10 | of the function will stick around in the environment until it is cleared. 11 | 12 | Usage 13 | ----- 14 | 15 | :: 16 | 17 | devel/clear-script-env