From bb5d98e8959c6602d3fe31fb15d9fecb3b0f77fd Mon Sep 17 00:00:00 2001 From: Warmist Date: Fri, 15 Feb 2013 20:19:55 +0200 Subject: [PATCH 01/20] friendship fixes. --- plugins/lua/dfusion.lua | 1 + plugins/lua/dfusion/friendship.lua | 13 ++++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/plugins/lua/dfusion.lua b/plugins/lua/dfusion.lua index 107ccb870..29272ce9e 100644 --- a/plugins/lua/dfusion.lua +++ b/plugins/lua/dfusion.lua @@ -178,6 +178,7 @@ end function BinaryPlugin:move_to_df() local _,addr=df.sizeof(self.data) markAsExecutable(addr) + return addr end function BinaryPlugin:print_data() local out="" diff --git a/plugins/lua/dfusion/friendship.lua b/plugins/lua/dfusion/friendship.lua index 93a370c86..d114a8bb0 100644 --- a/plugins/lua/dfusion/friendship.lua +++ b/plugins/lua/dfusion/friendship.lua @@ -9,9 +9,18 @@ FriendshipRainbow.name="FriendshipRainbow" -- os independant... I think... FriendshipRainbow.ATTRS{filename="hack/lua/plugins/dfusion/friendship.o",name="FriendshipRainbow",race_data=DEFAULT_NIL} FriendshipRainbow.class_status="valid, not installed" +function FriendshipRainbow:findall_needles(codesg,needle) -- todo move to memscan.lua + local cidx,caddr=codesg.uint8_t:find(needle) + local ret={} + while cidx~=nil do + table.insert(ret,{cidx,caddr}) + cidx,caddr=codesg.uint8_t:find(needle,cidx+1) + end + return ret +end function FriendshipRainbow:find_one(codesg,needle,crace) dfu.concatTables(needle,dfu.dwordToTable(crace)) - return codesg.uint8_t:findall(needle) + return self:findall_needles(codesg,needle) end function FriendshipRainbow:find_all() local code=ms.get_code_segment() @@ -68,7 +77,9 @@ end function FriendshipRainbow:patchCalls(target) local addrs=self:find_all() local swaps={} + print("target=",target) for k,adr in ipairs(addrs) do + print(k,adr[1]) local newval=dfu.makeCall(adr[1],target) table.insert(newval,adr[2]) for t,val in ipairs(newval) do From ab6a993689a88cd5329479c6491a417095d493d7 Mon Sep 17 00:00:00 2001 From: Warmist Date: Fri, 15 Feb 2013 20:21:33 +0200 Subject: [PATCH 02/20] friendship.lua: removed debug printing --- plugins/lua/dfusion/friendship.lua | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/lua/dfusion/friendship.lua b/plugins/lua/dfusion/friendship.lua index d114a8bb0..81996fccf 100644 --- a/plugins/lua/dfusion/friendship.lua +++ b/plugins/lua/dfusion/friendship.lua @@ -77,9 +77,7 @@ end function FriendshipRainbow:patchCalls(target) local addrs=self:find_all() local swaps={} - print("target=",target) for k,adr in ipairs(addrs) do - print(k,adr[1]) local newval=dfu.makeCall(adr[1],target) table.insert(newval,adr[2]) for t,val in ipairs(newval) do From 6b70a89321aa4cc865433efa94f01e149903823b Mon Sep 17 00:00:00 2001 From: jj Date: Sun, 17 Feb 2013 02:05:01 +0100 Subject: [PATCH 03/20] ruby: typo in autogen/int8_t --- plugins/ruby/codegen.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/ruby/codegen.pl b/plugins/ruby/codegen.pl index 03017a0f5..a4bebb7e6 100755 --- a/plugins/ruby/codegen.pl +++ b/plugins/ruby/codegen.pl @@ -843,7 +843,7 @@ sub render_item_number { } elsif ($subtype eq 'uint8_t') { push @lines_rb, 'number 8, false'; } elsif ($subtype eq 'int8_t') { - push @lines_rb, 'number 8, false'; + push @lines_rb, 'number 8, true'; } elsif ($subtype eq 'bool') { push @lines_rb, 'number 8, true'; $initvalue ||= 'nil'; From 2bbe6824fba7604ed311b5a1f394228b16a30e1f Mon Sep 17 00:00:00 2001 From: jj Date: Thu, 21 Feb 2013 15:26:35 +0100 Subject: [PATCH 04/20] fix tweak/stable-cursor for low z-levels --- plugins/tweak.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp index e120cd172..433f8d197 100644 --- a/plugins/tweak.cpp +++ b/plugins/tweak.cpp @@ -251,10 +251,16 @@ struct stable_cursor_hook : df::viewscreen_dwarfmodest // Force update of ui state set tmp; - tmp.insert(interface_key::CURSOR_DOWN_Z); + if (last_cursor.z < 2) + tmp.insert(interface_key::CURSOR_UP_Z); + else + tmp.insert(interface_key::CURSOR_DOWN_Z); INTERPOSE_NEXT(feed)(&tmp); tmp.clear(); - tmp.insert(interface_key::CURSOR_UP_Z); + if (last_cursor.z < 2) + tmp.insert(interface_key::CURSOR_DOWN_Z); + else + tmp.insert(interface_key::CURSOR_UP_Z); INTERPOSE_NEXT(feed)(&tmp); } else if (!is_default && cur_cursor.isValid()) From bf0795d73840b4e70bbefa4cb7059c863751721c Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Tue, 26 Feb 2013 12:27:37 +0400 Subject: [PATCH 05/20] Edit documentation for some scripts, and fix syntax in Lua API.rst. --- Lua API.html | 98 +++++++++++++++++++++++++++++++++-- Lua API.rst | 78 ++++++++++++++++++++-------- NEWS | 4 +- Readme.html | 141 +++++++++++++++++++++++++++++++-------------------- Readme.rst | 38 +++++++++++++- 5 files changed, 274 insertions(+), 85 deletions(-) diff --git a/Lua API.html b/Lua API.html index e5318165d..232bfc8e4 100644 --- a/Lua API.html +++ b/Lua API.html @@ -402,10 +402,16 @@ ul.auto-toc {
  • Plugins @@ -3038,9 +3044,93 @@ set is the same as used by the command line.

    Does not export any native functions as of now. Instead, it calls lua code to perform the actual ordering of list items.

    +
    +

    Eventful

    +

    This plugin exports some events to lua thus allowing to run lua functions +on DF world events.

    +
    +

    List of events

    +
      +
    1. onReactionComplete(reaction,unit,input_items,input_reagents,output_items,call_native)

      +

      Auto activates if detects reactions starting with LUA_HOOK_. Is called when reaction finishes.

      +
    2. +
    3. onItemContaminateWound(item,unit,wound,number1,number2)

      +

      Is called when item tries to contaminate wound (e.g. stuck in).

      +
    4. +
    5. onProjItemCheckMovement(projectile)

      +

      Is called when projectile moves.

      +
    6. +
    7. onProjItemCheckImpact(projectile,somebool)

      +

      Is called when projectile hits something.

      +
    8. +
    9. onProjUnitCheckMovement(projectile)

      +

      Is called when projectile moves.

      +
    10. +
    11. onProjUnitCheckImpact(projectile,somebool)

      +

      Is called when projectile hits something.

      +
    12. +
    13. onWorkshopFillSidebarMenu(workshop,callnative)

      +

      Is called when viewing a workshop in 'q' mode, to populate reactions, usefull for custom viewscreens for shops.

      +
    14. +
    15. postWorkshopFillSidebarMenu(workshop)

      +

      Is called after calling (or not) native fillSidebarMenu(). Usefull for job button +tweaking (e.g. adding custom reactions)

      +
    16. +
    +
    +
    +

    Functions

    +
      +
    1. registerReaction(reaction_name,callback)

      +

      Simplified way of using onReactionComplete; the callback is function (same params as event).

      +
    2. +
    3. removeNative(shop_name)

      +

      Removes native choice list from the building.

      +
    4. +
    5. addReactionToShop(reaction_name,shop_name)

      +

      Add a custom reaction to the building.

      +
    6. +
    +
    +
    +

    Examples

    +

    Spawn dragon breath on each item attempt to contaminate wound:

    +
    +b=require "plugins.eventful"
    +b.onItemContaminateWound.one=function(item,unit,un_wound,x,y)
    +    local flw=dfhack.maps.spawnFlow(unit.pos,6,0,0,50000)
    +end
    +
    +

    Reaction complete example:

    +
    +b=require "plugins.eventful"
    +
    +b.onReactionComplete.one=function(reaction,unit,in_items,in_reag,out_items,call_native)
    +  local pos=copyall(unit.pos)
    +  -- spawn dragonbreath after 100 ticks
    +  dfhack.timeout(100,"ticks",function() dfhack.maps.spawnFlow(pos,6,0,0,50000) end)
    +  --do not call real item creation code
    +  call_native.value=false
    +end
    +
    +

    Granade example:

    +
    +b=require "plugins.eventful"
    +b.onProjItemCheckImpact.one=function(projectile)
    +  -- you can check if projectile.item e.g. has correct material
    +  dfhack.maps.spawnFlow(projectile.cur_pos,6,0,0,50000)
    +end
    +
    +

    Integrated tannery:

    +
    +b=require "plugins.eventful"
    +b.addReactionToShop("TAN_A_HIDE","LEATHERWORKS")
    +
    +
    +
    -

    Scripts

    +

    Scripts

    Any files with the .lua extension placed into hack/scripts/* are automatically used by the DFHack core as commands. The matching command name consists of the name of the file sans @@ -3071,7 +3161,7 @@ The name argument should be the name stem, as

    Note that this function lets errors propagate to the caller.

    -

    Save init script

    +

    Save init script

    If a save directory contains a file called raw/init.lua, it is automatically loaded and executed every time the save is loaded. It can also define the following functions to be called by dfhack:

    diff --git a/Lua API.rst b/Lua API.rst index a6bdca4ef..19ba7132d 100644 --- a/Lua API.rst +++ b/Lua API.rst @@ -2967,51 +2967,85 @@ on DF world events. List of events -------------- -1. onReactionComplete(reaction,unit,input_items,input_reagents,output_items,call_native) - auto activates if detects reactions starting with ``LUA_HOOK_``. Is called when reaction finishes. -2. onItemContaminateWound(item,unit,wound,number1,number2) - Is called when item tries to contaminate wound (e.g. stuck in) -3. onProjItemCheckMovement(projectile) - is called when projectile moves -4. onProjItemCheckImpact(projectile,somebool) - is called when projectile hits something -5. onProjUnitCheckMovement(projectile) - is called when projectile moves -6. onProjUnitCheckImpact(projectile,somebool) - is called when projectile hits something -7. onWorkshopFillSidebarMenu(workshop,callnative) - is called when viewing a workshop in 'q' mode, to populate reactions, usefull for custom viewscreens for shops -8. postWorkshopFillSidebarMenu(workshop) - is called after calling (or not) native fillSidebarMenu(). Usefull for job button tweaking (e.g. adding custom reactions) +1. ``onReactionComplete(reaction,unit,input_items,input_reagents,output_items,call_native)`` + + Auto activates if detects reactions starting with ``LUA_HOOK_``. Is called when reaction finishes. + +2. ``onItemContaminateWound(item,unit,wound,number1,number2)`` + + Is called when item tries to contaminate wound (e.g. stuck in). + +3. ``onProjItemCheckMovement(projectile)`` + + Is called when projectile moves. + +4. ``onProjItemCheckImpact(projectile,somebool)`` + + Is called when projectile hits something. + +5. ``onProjUnitCheckMovement(projectile)`` + + Is called when projectile moves. + +6. ``onProjUnitCheckImpact(projectile,somebool)`` + + Is called when projectile hits something. + +7. ``onWorkshopFillSidebarMenu(workshop,callnative)`` + + Is called when viewing a workshop in 'q' mode, to populate reactions, usefull for custom viewscreens for shops. + +8. ``postWorkshopFillSidebarMenu(workshop)`` + + Is called after calling (or not) native fillSidebarMenu(). Usefull for job button + tweaking (e.g. adding custom reactions) Functions --------- -1. registerReaction(reaction_name,callback) - simplified way of using onReactionComplete, the callback is function (same params as event) -2. removeNative(shop_name) - removes native choice list from the building -3. addReactionToShop(reaction_name,shop_name) - add a custom reaction to the building +1. ``registerReaction(reaction_name,callback)`` + + Simplified way of using onReactionComplete; the callback is function (same params as event). + +2. ``removeNative(shop_name)`` + + Removes native choice list from the building. + +3. ``addReactionToShop(reaction_name,shop_name)`` + + Add a custom reaction to the building. Examples -------- -Spawn dragon breath on each item attempt to contaminate wound: -:: +Spawn dragon breath on each item attempt to contaminate wound:: - b=require "plugins.eventful" + b=require "plugins.eventful" b.onItemContaminateWound.one=function(item,unit,un_wound,x,y) local flw=dfhack.maps.spawnFlow(unit.pos,6,0,0,50000) end -Reaction complete example: -:: +Reaction complete example:: + b=require "plugins.eventful" + b.onReactionComplete.one=function(reaction,unit,in_items,in_reag,out_items,call_native) local pos=copyall(unit.pos) - dfhack.timeout(100,"ticks",function() dfhack.maps.spawnFlow(pos,6,0,0,50000) end) -- spawn dragonbreath after 100 ticks - call_native.value=false --do not call real item creation code + -- spawn dragonbreath after 100 ticks + dfhack.timeout(100,"ticks",function() dfhack.maps.spawnFlow(pos,6,0,0,50000) end) + --do not call real item creation code + call_native.value=false end -Granade example: -:: +Granade example:: + b=require "plugins.eventful" b.onProjItemCheckImpact.one=function(projectile) -- you can check if projectile.item e.g. has correct material dfhack.maps.spawnFlow(projectile.cur_pos,6,0,0,50000) end -Integrated tannery: -:: +Integrated tannery:: + b=require "plugins.eventful" b.addReactionToShop("TAN_A_HIDE","LEATHERWORKS") diff --git a/NEWS b/NEWS index d9c184832..91eab0ec0 100644 --- a/NEWS +++ b/NEWS @@ -4,7 +4,8 @@ DFHack future - support for displaying active keybindings properly. - support for reusable widgets in lua screen library. - Maps::canStepBetween: returns whether you can walk between two tiles in one step. - - EventManager: monitors various in game events centrally so that individual plugins don't have to monitor the same things redundantly. + - EventManager: monitors various in game events centrally so that individual plugins + don't have to monitor the same things redundantly. Notable bugfixes: - autobutcher can be re-enabled again after being stopped. - stopped Dwarf Manipulator from unmasking vampires. @@ -28,6 +29,7 @@ DFHack future - stripcaged: mark items inside cages for dumping, eg caged goblin weapons. - soundsense-season: writes the correct season to gamelog.txt on world load. - create-items: spawn items + - fix/cloth-stockpile: fixes bug 5739; needs to be run after savegame load every time. New GUI scripts: - gui/guide-path: displays the cached path for minecart Guide orders. - gui/workshop-job: displays inputs of a workshop job and allows tweaking them. diff --git a/Readme.html b/Readme.html index d9a3d0602..8cd192f35 100644 --- a/Readme.html +++ b/Readme.html @@ -510,41 +510,42 @@ access DF memory and allow for easier development of new tools.

  • lever
  • stripcaged
  • create-items
  • +
  • soundsense-season
  • -
  • In-game interface tools
      -
    • Dwarf Manipulator
    • -
    • Search
    • -
    • AutoMaterial
    • -
    • gui/liquids
    • -
    • gui/mechanisms
    • -
    • gui/rename
    • -
    • gui/room-list
    • -
    • gui/choose-weapons
    • -
    • gui/guide-path
    • -
    • gui/workshop-job
    • -
    • gui/workflow
    • -
    • gui/assign-rack
    • -
    • gui/advfort
    • -
    • gui/gm-editor
    • +
    • In-game interface tools
    • -
    • Behavior Mods
        -
      • Siege Engine
        @@ -2847,9 +2854,18 @@ create-items bar CREATURE:CAT:SOAP create-items bar adamantine
        +
        +

        soundsense-season

        +

        It is a well known issue that Soundsense cannot detect the correct +current season when a savegame is loaded and has to play random +season music until a season switch occurs.

        +

        This script registers a hook that prints the appropriate string +to gamelog.txt on every map load to fix this. For best results +call the script from dfhack.init.

        +
        -

        In-game interface tools

        +

        In-game interface tools

        These tools work by displaying dialogs or overlays in the game window, and are mostly implemented by lua scripts.

        @@ -2862,7 +2878,7 @@ existing DF screens, they deliberately use red instead of green for the key.

        guideline because it arguably just fixes small usability bugs in the game UI.

        -

        Dwarf Manipulator

        +

        Dwarf Manipulator

        Implemented by the manipulator plugin. To activate, open the unit screen and press 'l'.

        images/manipulator.png @@ -2901,7 +2917,7 @@ cursor onto that cell instead of toggling it.
      • directly to the main dwarf mode screen.

        -

        AutoMaterial

        +

        AutoMaterial

        The automaterial plugin makes building constructions (walls, floors, fortifications, etc) a little bit easier by saving you from having to trawl through long lists of materials each time you place one.

        @@ -2958,14 +2974,27 @@ materials, it returns you back to this screen. If you use this along with severa enabled materials, you should be able to place complex constructions more conveniently.

        -

        gui/liquids

        +

        gui/liquids

        To use, bind to a key (the example config uses Alt-L) and activate in the 'k' mode.

        images/liquids.png -

        While active, use the suggested keys to switch the usual liquids parameters, and Enter -to select the target area and apply changes.

        +

        This script is a gui front-end to the liquids plugin and works similar to it, +allowing you to add or remove water & magma, and create obsidian walls & floors. +Note that there is no undo support, and that bugs in this plugin have been +known to create pathfinding problems and heat traps.

        +

        The b key changes how the affected area is selected. The default Rectangle +mode works by selecting two corners like any ordinary designation. The p +key chooses between adding water, magma, obsidian walls & floors, or just +tweaking flags.

        +

        When painting liquids, it is possible to select the desired level with +-, +and choose between setting it exactly, only increasing or only decreasing +with s.

        +

        In addition, f allows disabling or enabling the flowing water computations +for an area, and r operates on the "permanent flow" property that makes +rivers power water wheels even when full and technically not flowing.

        +

        After setting up the desired operations using the described keys, use Enter to apply them.

        -

        gui/mechanisms

        +

        gui/mechanisms

        To use, bind to a key (the example config uses Ctrl-M) and activate in the 'q' mode.

        images/mechanisms.png

        Lists mechanisms connected to the building, and their links. Navigating the list centers @@ -2975,7 +3004,7 @@ focus on the current one. Shift-Enter has an effect equivalent to pressing Enter re-entering the mechanisms ui.

        -

        gui/rename

        +

        gui/rename

        Backed by the rename plugin, this script allows entering the desired name via a simple dialog in the game ui.

          @@ -2998,7 +3027,7 @@ their species string.

          unit profession change to Ctrl-Shift-T.

        -

        gui/room-list

        +

        gui/room-list

        To use, bind to a key (the example config uses Alt-R) and activate in the 'q' mode, either immediately or after opening the assign owner page.

        images/room-list.png @@ -3006,7 +3035,7 @@ either immediately or after opening the assign owner page.

        list, and allows unassigning them.

        -

        gui/choose-weapons

        +

        gui/choose-weapons

        Bind to a key (the example config uses Ctrl-W), and activate in the Equip->View/Customize page of the military screen.

        Depending on the cursor location, it rewrites all 'individual choice weapon' entries @@ -3017,7 +3046,7 @@ only that entry, and does it even if it is not 'individual choice'.

        and may lead to inappropriate weapons being selected.

        -

        gui/guide-path

        +

        gui/guide-path

        Bind to a key (the example config uses Alt-P), and activate in the Hauling menu with the cursor over a Guide order.

        images/guide-path.png @@ -3025,7 +3054,7 @@ the cursor over a Guide order.

        computes it when the order is executed for the first time.

        -

        gui/workshop-job

        +

        gui/workshop-job

        Bind to a key (the example config uses Alt-A), and activate with a job selected in a workshop in the 'q' mode.

        images/workshop-job.png @@ -3061,7 +3090,7 @@ and then try to change the input item type, now it won't let you select plan you have to unset the material first.

        -

        gui/workflow

        +

        gui/workflow

        Bind to a key (the example config uses Alt-W), and activate with a job selected in a workshop in the 'q' mode.

        images/workflow.png @@ -3108,7 +3137,7 @@ the current stock value. The bright green dashed line is the target limit (maximum) and the dark green line is that minus the gap (minimum).

        -

        gui/assign-rack

        +

        gui/assign-rack

        Bind to a key (the example config uses P), and activate when viewing a weapon rack in the 'q' mode.

        images/assign-rack.png @@ -3132,7 +3161,7 @@ the intended user. In order to aid in the choice, it shows the number of currently assigned racks for every valid squad.

        -

        gui/advfort

        +

        gui/advfort

        This script allows to perform jobs in adventure mode. For more complete help press '?' while script is running. It's most confortable to use this as a keybinding. (e.g. keybinding set Ctrl-T gui/advfort). Possible arguments:

        @@ -3145,7 +3174,7 @@ implies -a
      -

      gui/gm-editor

      +

      gui/gm-editor

      There are three ways to open this editor:

      • using gui/gm-editor command/keybinding - opens editor on what is selected @@ -3160,7 +3189,7 @@ in-game help.

      -

      Behavior Mods

      +

      Behavior Mods

      These plugins, when activated via configuration UI or by detecting certain structures in RAWs, modify the game engine behavior concerning the target objects to add features not otherwise present.

      @@ -3171,20 +3200,20 @@ technical challenge, and do not represent any long-term plans to produce more similar modifications of the game.

      -

      Siege Engine

      +

      Siege Engine

      The siege-engine plugin enables siege engines to be linked to stockpiles, and aimed at an arbitrary rectangular area across Z levels, instead of the original four directions. Also, catapults can be ordered to load arbitrary objects, not just stones.

      -

      Rationale

      +

      Rationale

      Siege engines are a very interesting feature, but sadly almost useless in the current state because they haven't been updated since 2D and can only aim in four directions. This is an attempt to bring them more up to date until Toady has time to work on it. Actual improvements, e.g. like making siegers bring their own, are something only Toady can do.

      -

      Configuration UI

      +

      Configuration UI

      The configuration front-end to the plugin is implemented by the gui/siege-engine script. Bind it to a key (the example config uses Alt-A) and activate after selecting a siege engine in 'q' mode.

      @@ -3207,7 +3236,7 @@ menu.

      -

      Power Meter

      +

      Power Meter

      The power-meter plugin implements a modified pressure plate that detects power being supplied to gear boxes built in the four adjacent N/S/W/E tiles.

      The configuration front-end is implemented by the gui/power-meter script. Bind it to a @@ -3218,11 +3247,11 @@ in the build menu.

      configuration page, but configures parameters relevant to the modded power meter building.

      -

      Steam Engine

      +

      Steam Engine

      The steam-engine plugin detects custom workshops with STEAM_ENGINE in their token, and turns them into real steam engines.

      -

      Rationale

      +

      Rationale

      The vanilla game contains only water wheels and windmills as sources of power, but windmills give relatively little power, and water wheels require flowing water, which must either be a real river and thus immovable and @@ -3233,7 +3262,7 @@ it can be done just by combining existing features of the game engine in a new way with some glue code and a bit of custom logic.

      -

      Construction

      +

      Construction

      The workshop needs water as its input, which it takes via a passable floor tile below it, like usual magma workshops do. The magma version also needs magma.

      @@ -3257,7 +3286,7 @@ short axles that can be built later than both of the engines.

      -

      Operation

      +

      Operation

      In order to operate the engine, queue the Stoke Boiler job (optionally on repeat). A furnace operator will come, possibly bringing a bar of fuel, and perform it. As a result, a "boiling water" item will appear @@ -3288,7 +3317,7 @@ decrease it by further 4%, and also decrease the whole steam use rate by 10%.

      -

      Explosions

      +

      Explosions

      The engine must be constructed using barrel, pipe and piston from fire-safe, or in the magma version magma-safe metals.

      During operation weak parts get gradually worn out, and @@ -3297,7 +3326,7 @@ toppled during operation by a building destroyer, or a tantruming dwarf.

      -

      Save files

      +

      Save files

      It should be safe to load and view engine-using fortresses from a DF version without DFHack installed, except that in such case the engines won't work. However actually making modifications @@ -3308,7 +3337,7 @@ being generated.

      -

      Add Spatter

      +

      Add Spatter

      This plugin makes reactions with names starting with SPATTER_ADD_ produce contaminants on the items instead of improvements. The produced contaminants are immune to being washed away by water or destroyed by diff --git a/Readme.rst b/Readme.rst index 236eafb01..bc831e4a6 100644 --- a/Readme.rst +++ b/Readme.rst @@ -1773,6 +1773,12 @@ Scripts in this subdirectory fix various bugs and issues, some of them obscure. Diagnoses and fixes issues with nonexistant 'items occupying site', usually caused by autodump bugs or other hacking mishaps. +* fix/cloth-stockpile + + Fixes erratic behavior of cloth stockpiles by scanning material objects + in memory and patching up some invalid reference fields. Needs to be run + every time a save game is loaded; putting ``fix/cloth-stockpile enable`` + in ``dfhack.init`` makes it run automatically. gui/* ===== @@ -2032,6 +2038,17 @@ Exemples:: create-items bar CREATURE:CAT:SOAP create-items bar adamantine +soundsense-season +================= + +It is a well known issue that Soundsense cannot detect the correct +current season when a savegame is loaded and has to play random +season music until a season switch occurs. + +This script registers a hook that prints the appropriate string +to gamelog.txt on every map load to fix this. For best results +call the script from ``dfhack.init``. + ======================= In-game interface tools ======================= @@ -2185,8 +2202,25 @@ To use, bind to a key (the example config uses Alt-L) and activate in the 'k' mo .. image:: images/liquids.png -While active, use the suggested keys to switch the usual liquids parameters, and Enter -to select the target area and apply changes. +This script is a gui front-end to the liquids plugin and works similar to it, +allowing you to add or remove water & magma, and create obsidian walls & floors. +Note that there is **no undo support**, and that bugs in this plugin have been +known to create pathfinding problems and heat traps. + +The ``b`` key changes how the affected area is selected. The default *Rectangle* +mode works by selecting two corners like any ordinary designation. The ``p`` +key chooses between adding water, magma, obsidian walls & floors, or just +tweaking flags. + +When painting liquids, it is possible to select the desired level with ``+-``, +and choose between setting it exactly, only increasing or only decreasing +with ``s``. + +In addition, ``f`` allows disabling or enabling the flowing water computations +for an area, and ``r`` operates on the "permanent flow" property that makes +rivers power water wheels even when full and technically not flowing. + +After setting up the desired operations using the described keys, use ``Enter`` to apply them. gui/mechanisms From 03b91ca26c3e5eb82c51fa57ea6944c99e5dec19 Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Tue, 26 Feb 2013 12:29:02 +0400 Subject: [PATCH 06/20] Fix a problem in binpatch.lua and comment out debug messages in tweak. --- library/lua/binpatch.lua | 2 ++ plugins/tweak.cpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/library/lua/binpatch.lua b/library/lua/binpatch.lua index e957148f7..20d0869a4 100644 --- a/library/lua/binpatch.lua +++ b/library/lua/binpatch.lua @@ -1,5 +1,7 @@ -- Simple binary patch with IDA dif file support. +local _ENV = mkmodule('binpatch') + local function load_patch(name) local filename = name if not string.match(filename, '[./\\]') then diff --git a/plugins/tweak.cpp b/plugins/tweak.cpp index 433f8d197..751de4422 100644 --- a/plugins/tweak.cpp +++ b/plugins/tweak.cpp @@ -815,14 +815,18 @@ struct military_training_ct_hook : df::activity_event_combat_trainingst { spar++; } +#if 0 color_ostream_proxy out(Core::getInstance().getConsole()); +#endif // If the xp gap is low, sometimes replace with sparring if ((maxv - minv) < 64*15 && spar == units.size() && random_int(45) >= 30 + (maxv-minv)/64) { +#if 0 out.print("Replacing %s demonstration (xp %d-%d, gap %d) with sparring.\n", ENUM_KEY_STR(job_skill, sd->skill).c_str(), minv, maxv, maxv-minv); +#endif if (auto spar = df::allocate()) { @@ -844,18 +848,22 @@ struct military_training_ct_hook : df::activity_event_combat_trainingst { // If the teacher has less xp than somebody else, switch if (best >= 0 && maxv > cur_xp) { +#if 0 out.print("Replacing %s teacher %d (%d xp) with %d (%d xp); xp gap %d.\n", ENUM_KEY_STR(job_skill, sd->skill).c_str(), sd->unit_id, cur_xp, units[best], maxv, maxv-minv); +#endif sd->hist_figure_id = sd->participants.histfigs[best]; sd->unit_id = units[best]; } else { +#if 0 out.print("Not changing %s demonstration (xp %d-%d, gap %d).\n", ENUM_KEY_STR(job_skill, sd->skill).c_str(), minv, maxv, maxv-minv); +#endif } } } From f0b0378caf61b19d9800c1128eaa71bfa31b410e Mon Sep 17 00:00:00 2001 From: Quietust Date: Wed, 27 Feb 2013 08:08:49 -0600 Subject: [PATCH 07/20] Fix spelling errors --- Lua API.html | 6 +++--- Lua API.rst | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Lua API.html b/Lua API.html index 232bfc8e4..700506286 100644 --- a/Lua API.html +++ b/Lua API.html @@ -3070,10 +3070,10 @@ on DF world events.

      Is called when projectile hits something.

    • onWorkshopFillSidebarMenu(workshop,callnative)

      -

      Is called when viewing a workshop in 'q' mode, to populate reactions, usefull for custom viewscreens for shops.

      +

      Is called when viewing a workshop in 'q' mode, to populate reactions, useful for custom viewscreens for shops.

    • postWorkshopFillSidebarMenu(workshop)

      -

      Is called after calling (or not) native fillSidebarMenu(). Usefull for job button +

      Is called after calling (or not) native fillSidebarMenu(). Useful for job button tweaking (e.g. adding custom reactions)

    • @@ -3113,7 +3113,7 @@ b.onReactionComplete.one=function(reaction,unit,in_items,in_reag,out_items,call_ call_native.value=false end -

      Granade example:

      +

      Grenade example:

       b=require "plugins.eventful"
       b.onProjItemCheckImpact.one=function(projectile)
      diff --git a/Lua API.rst b/Lua API.rst
      index 19ba7132d..6d4e6b51b 100644
      --- a/Lua API.rst	
      +++ b/Lua API.rst	
      @@ -2993,11 +2993,11 @@ List of events
       
       7. ``onWorkshopFillSidebarMenu(workshop,callnative)``
       
      -   Is called when viewing a workshop in 'q' mode, to populate reactions, usefull for custom viewscreens for shops.
      +   Is called when viewing a workshop in 'q' mode, to populate reactions, useful for custom viewscreens for shops.
       
       8. ``postWorkshopFillSidebarMenu(workshop)``
       
      -   Is called after calling (or not) native fillSidebarMenu(). Usefull for job button
      +   Is called after calling (or not) native fillSidebarMenu(). Useful for job button
          tweaking (e.g. adding custom reactions)
       
       Functions
      @@ -3036,7 +3036,7 @@ Reaction complete example::
           call_native.value=false
         end
       
      -Granade example::
      +Grenade example::
       
         b=require "plugins.eventful"
         b.onProjItemCheckImpact.one=function(projectile)
      
      From f55030909f83c54b5b74d085d0dd1253b60e210e Mon Sep 17 00:00:00 2001
      From: Quietust 
      Date: Wed, 27 Feb 2013 11:09:06 -0600
      Subject: [PATCH 08/20] Add createItem plugin, spawns an item at the selected
       unit's feet
      
      ---
       plugins/CMakeLists.txt |   1 +
       plugins/createitem.cpp | 234 +++++++++++++++++++++++++++++++++++++++++
       2 files changed, 235 insertions(+)
       create mode 100644 plugins/createitem.cpp
      
      diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
      index f2bf4d4a4..65a550018 100644
      --- a/plugins/CMakeLists.txt
      +++ b/plugins/CMakeLists.txt
      @@ -136,6 +136,7 @@ if (BUILD_SUPPORTED)
           DFHACK_PLUGIN(autoSyndrome autoSyndrome.cpp)
           DFHACK_PLUGIN(trueTransformation trueTransformation.cpp)
           DFHACK_PLUGIN(infiniteSky infiniteSky.cpp)
      +    DFHACK_PLUGIN(createitem createitem.cpp)
       endif()
       
       
      diff --git a/plugins/createitem.cpp b/plugins/createitem.cpp
      new file mode 100644
      index 000000000..722932a99
      --- /dev/null
      +++ b/plugins/createitem.cpp
      @@ -0,0 +1,234 @@
      +// Create arbitrary items
      +
      +#include "Core.h"
      +#include "Console.h"
      +#include "Export.h"
      +#include "PluginManager.h"
      +#include "MiscUtils.h"
      +
      +#include "modules/Maps.h"
      +#include "modules/Gui.h"
      +#include "modules/Items.h"
      +#include "modules/Materials.h"
      +
      +#include "DataDefs.h"
      +#include "df/world.h"
      +#include "df/ui.h"
      +#include "df/unit.h"
      +#include "df/historical_entity.h"
      +#include "df/world_site.h"
      +#include "df/item.h"
      +#include "df/creature_raw.h"
      +#include "df/caste_raw.h"
      +#include "df/reaction_reagent.h"
      +#include "df/reaction_product_itemst.h"
      +
      +using namespace std;
      +using namespace DFHack;
      +
      +using df::global::world;
      +using df::global::ui;
      +
      +DFHACK_PLUGIN("createitem");
      +
      +command_result df_createitem (color_ostream &out, vector  & parameters);
      +
      +DFhackCExport command_result plugin_init (color_ostream &out, std::vector &commands)
      +{
      +    commands.push_back(PluginCommand("createitem", "Create arbitrary item at the selected unit's feet.", df_createitem));
      +    return CR_OK;
      +}
      +
      +DFhackCExport command_result plugin_shutdown ( color_ostream &out )
      +{
      +    return CR_OK;
      +}
      +
      +bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, int hand = 0)
      +{
      +    vector out_items;
      +    vector in_reag;
      +    vector in_items;
      +
      +    prod->produce(unit, &out_items, &in_reag, &in_items, 1, df::job_skill::NONE, ui->main.fortress_entity, df::world_site::find(ui->site_id));
      +    if (!out_items.size())
      +        return false;
      +    for (size_t i = 0; i < out_items.size(); i++)
      +    {
      +        out_items[i]->moveToGround(unit->pos.x, unit->pos.y, unit->pos.z);
      +        if (hand)
      +            out_items[i]->setGloveHandedness(hand);
      +    }
      +    return true;
      +}
      +
      +command_result df_createitem (color_ostream &out, vector  & parameters)
      +{
      +    string item_str, material_str;
      +    df::item_type item_type;
      +    int16_t item_subtype;
      +    int16_t mat_type;
      +    int32_t mat_index;
      +
      +    if (parameters.size() != 2)
      +    {
      +        out.print("Syntax: createitem ITEM_TYPE:ITEM_SUBTYPE MATERIAL:ETC\n");
      +        return CR_WRONG_USAGE;
      +    }
      +    item_str = parameters[0];
      +    material_str = parameters[1];
      +
      +    ItemTypeInfo item;
      +    MaterialInfo material;
      +    vector tokens;
      +
      +    if (!item.find(item_str))
      +    {
      +        out.printerr("Unrecognized item type!\n");
      +        return CR_FAILURE;
      +    }
      +    item_type = item.type;
      +    item_subtype = item.subtype;
      +    switch (item.type)
      +    {
      +    case df::item_type::INSTRUMENT:
      +    case df::item_type::TOY:
      +    case df::item_type::WEAPON:
      +    case df::item_type::ARMOR:
      +    case df::item_type::SHOES:
      +    case df::item_type::SHIELD:
      +    case df::item_type::HELM:
      +    case df::item_type::GLOVES:
      +    case df::item_type::AMMO:
      +    case df::item_type::PANTS:
      +    case df::item_type::SIEGEAMMO:
      +    case df::item_type::TRAPCOMP:
      +    case df::item_type::TOOL:
      +        if (item_subtype == -1)
      +        {
      +            out.printerr("You must specify a valid subtype!\n");
      +            return CR_FAILURE;
      +        }
      +    default:
      +        if (!material.find(material_str))
      +        {
      +            out.printerr("Unrecognized material!\n");
      +            return CR_FAILURE;
      +        }
      +        mat_type = material.type;
      +        mat_index = material.index;
      +        break;
      +
      +    case df::item_type::REMAINS:
      +    case df::item_type::FISH:
      +    case df::item_type::FISH_RAW:
      +    case df::item_type::VERMIN:
      +    case df::item_type::PET:
      +    case df::item_type::EGG:
      +        split_string(&tokens, material_str, ":");
      +        if (tokens.size() != 2)
      +        {
      +            out.printerr("You must specify a creature ID and caste for this item type!\n");
      +            return CR_FAILURE;
      +        }
      +
      +        mat_type = mat_index = -1;
      +        for (size_t i = 0; i < world->raws.creatures.all.size(); i++)
      +        {
      +            df::creature_raw *creature = world->raws.creatures.all[i];
      +            if (creature->creature_id == tokens[0])
      +            {
      +                for (size_t j = 0; j < creature->caste.size(); j++)
      +                {
      +                    df::caste_raw *caste = creature->caste[j];
      +                    if (creature->caste[j]->caste_id == tokens[1])
      +                    {
      +                        mat_type = i;
      +                        mat_index = j;
      +                        break;
      +                    }
      +                }
      +                if (mat_type == -1)
      +                {
      +                    out.printerr("The creature you specified has no such caste!\n");
      +                    return CR_FAILURE;
      +                }
      +            } 
      +        }
      +        if (mat_type == -1)
      +        {
      +            out.printerr("Unrecognized creature ID!\n");
      +            return CR_FAILURE;
      +        }
      +        break;
      +
      +    case df::item_type::CORPSE:
      +    case df::item_type::CORPSEPIECE:
      +    case df::item_type::FOOD:
      +        out.printerr("Cannot create that type of item!\n");
      +        return CR_FAILURE;
      +        break;
      +    }
      +
      +    CoreSuspender suspend;
      +
      +    df::unit *unit = Gui::getSelectedUnit(out, true);
      +    if (!unit)
      +    {
      +        out.printerr("No unit selected!\n");
      +        return CR_FAILURE;
      +    }
      +    if (!Maps::IsValid())
      +    {
      +        out.printerr("Map is not available.\n");
      +        return CR_FAILURE;
      +    }
      +    df::map_block *block = Maps::getTileBlock(unit->pos.x, unit->pos.y, unit->pos.z);
      +    if (block == NULL)
      +    {
      +        out.printerr("Unit does not reside in a valid map block, somehow?\n");
      +        return CR_FAILURE;
      +    }
      +
      +    df::reaction_product_itemst *prod = df::allocate();
      +    prod->item_type = item_type;
      +    prod->item_subtype = item_subtype;
      +    prod->mat_type = mat_type;
      +    prod->mat_index = mat_index;
      +    prod->probability = 100;
      +    prod->count = 1;
      +    switch (item_type)
      +    {
      +    case df::item_type::BAR:
      +    case df::item_type::POWDER_MISC:
      +    case df::item_type::LIQUID_MISC:
      +    case df::item_type::DRINK:
      +        prod->product_dimension = 150;
      +        break;
      +    case df::item_type::THREAD:
      +        prod->product_dimension = 15000;
      +        break;
      +    case df::item_type::CLOTH:
      +        prod->product_dimension = 10000;
      +        break;
      +    default:
      +        prod->product_dimension = 1;
      +        break;
      +    }
      +
      +    bool result;
      +#if 1
      +    // Workaround for DF issue #0006273
      +    if (item_type == df::item_type::GLOVES)
      +        result = makeItem(prod, unit, 1) && makeItem(prod, unit, 2);
      +    else
      +#endif
      +    result = makeItem(prod, unit);
      +
      +    if (!result)
      +    {
      +        out.printerr("Failed to create item!\n");
      +        return CR_FAILURE;
      +    }
      +    return CR_OK;
      +}
      
      From f418bce60e1a0dcdde216484b6d175ed7805ffb0 Mon Sep 17 00:00:00 2001
      From: Quietust 
      Date: Wed, 27 Feb 2013 11:20:49 -0600
      Subject: [PATCH 09/20] Document new createitem plugin
      
      ---
       Readme.html | 543 +++++++++++++++++++++++++++-------------------------
       Readme.rst  |  20 ++
       2 files changed, 303 insertions(+), 260 deletions(-)
      
      diff --git a/Readme.html b/Readme.html
      index 8cd192f35..a3a2ab9c1 100644
      --- a/Readme.html
      +++ b/Readme.html
      @@ -380,172 +380,173 @@ access DF memory and allow for easier development of new tools.

    • changevein
    • changeitem
    • colonies
    • -
    • deramp (by zilpin)
    • -
    • feature
    • -
    • liquids
    • -
    • liquids-here
    • -
    • tiletypes
    • -
    • tiletypes-commands
    • -
    • tiletypes-here
    • -
    • tiletypes-here-point
    • -
    • tubefill
    • -
    • extirpate
    • -
    • grow
    • -
    • immolate
    • -
    • regrass
    • -
    • weather
    • +
    • createitem
    • +
    • deramp (by zilpin)
    • +
    • feature
    • +
    • liquids
    • +
    • liquids-here
    • +
    • tiletypes
    • +
    • tiletypes-commands
    • +
    • tiletypes-here
    • +
    • tiletypes-here-point
    • +
    • tubefill
    • +
    • extirpate
    • +
    • grow
    • +
    • immolate
    • +
    • regrass
    • +
    • weather
  • -
  • Map inspection
      -
    • cursecheck
    • -
    • flows
    • -
    • probe
    • -
    • prospect
        -
      • Pre-embark estimate
      • +
      • Map inspection
      • -
      • Designations
          -
        • burrow
        • -
        • digv
        • -
        • digvx
        • -
        • digl
        • -
        • diglx
        • -
        • digexp
        • -
        • digcircle
        • -
        • digtype
        • -
        • filltraffic
        • -
        • alltraffic
        • -
        • getplants
        • +
        • Designations
        • -
        • Cleanup and garbage disposal
            -
          • clean
          • -
          • spotclean
          • -
          • autodump
          • -
          • autodump-destroy-here
          • -
          • autodump-destroy-item
          • -
          • cleanowned
          • +
          • Cleanup and garbage disposal
          • -
          • Bugfixes
              -
            • drybuckets
            • -
            • fixdiplomats
            • -
            • fixmerchants
            • -
            • fixveins
            • -
            • tweak
            • -
            • fix-armory
            • +
            • Bugfixes
            • -
            • Mode switch and reclaim
                -
              • lair
              • -
              • mode
              • +
              • Mode switch and reclaim
              • -
              • Visualizer and data export
                  -
                • ssense / stonesense
                • -
                • mapexport
                • -
                • dwarfexport
                • +
                • Visualizer and data export
                • -
                • Job management
                    -
                  • job
                  • -
                  • job-material
                  • -
                  • job-duplicate
                  • -
                  • workflow
                      -
                    • Function
                    • -
                    • Constraint format
                    • -
                    • Constraint examples
                    • +
                    • Job management
                    • -
                    • Fortress activity management
                        -
                      • seedwatch
                      • -
                      • zone
                          -
                        • Usage with single units
                        • -
                        • Usage with filters
                        • -
                        • Mass-renaming
                        • -
                        • Cage zones
                        • -
                        • Examples
                        • +
                        • Fortress activity management
                        • -
                        • Other
                        • -
                        • Scripts
                            -
                          • fix/*
                          • -
                          • gui/*
                          • -
                          • binpatch
                          • -
                          • quicksave
                          • -
                          • setfps
                          • -
                          • siren
                          • -
                          • growcrops
                          • -
                          • removebadthoughts
                          • -
                          • slayrace
                          • -
                          • magmasource
                          • -
                          • digfort
                          • -
                          • superdwarf
                          • -
                          • drainaquifer
                          • -
                          • deathcause
                          • -
                          • lua
                          • -
                          • embark
                          • -
                          • lever
                          • -
                          • stripcaged
                          • -
                          • create-items
                          • -
                          • soundsense-season
                          • +
                          • Scripts
                          • -
                          • In-game interface tools
                              -
                            • Dwarf Manipulator
                            • -
                            • Search
                            • -
                            • AutoMaterial
                            • -
                            • gui/liquids
                            • -
                            • gui/mechanisms
                            • -
                            • gui/rename
                            • -
                            • gui/room-list
                            • -
                            • gui/choose-weapons
                            • -
                            • gui/guide-path
                            • -
                            • gui/workshop-job
                            • -
                            • gui/workflow
                            • -
                            • gui/assign-rack
                            • -
                            • gui/advfort
                            • -
                            • gui/gm-editor
                            • +
                            • In-game interface tools
                            • -
                            • Behavior Mods
                                -
                              • Siege Engine
                                  -
                                • Rationale
                                • -
                                • Configuration UI
                                • +
                                • Behavior Mods @@ -1027,13 +1028,35 @@ crafters/haulers.

                                  +
                                  +

                                  createitem

                                  +

                                  Allows creating new items of arbitrary types and made of arbitrary materials. +Any items created are spawned at the feet of the selected unit.

                                  +

                                  Specify the item and material information as you would indicate them in custom reaction raws, with the following differences: +* Separate the item and material with a space rather than a colon +* If the item has no subtype, omit the :NONE +* If the item is REMAINS, FISH, FISH_RAW, VERMIN, PET, or EGG, specify a CREATURE:CASTE pair instead of a material token.

                                  +

                                  Corpses, body parts, and prepared meals cannot be created using this tool.

                                  +
                                  +
                                  Examples:
                                  +
                                  +
                                  createitem GLOVES:ITEM_GLOVES_GAUNTLETS INORGANIC:STEEL
                                  +
                                  Create a pair of steel gauntlets.
                                  +
                                  createitem WOOD PLANT_MAT:TOWER_CAP:WOOD
                                  +
                                  Create tower-cap logs.
                                  +
                                  createitem FISH FISH_SHAD:MALE
                                  +
                                  Create cleaned shad, ready to eat.
                                  +
                                  +
                                  +
                                  +
                                  -

                                  deramp (by zilpin)

                                  +

                                  deramp (by zilpin)

                                  Removes all ramps designated for removal from the map. This is useful for replicating the old channel digging designation. It also removes any and all 'down ramps' that can remain after a cave-in (you don't have to designate anything for that to happen).

                                  -

                                  feature

                                  +

                                  feature

                                  Enables management of map features.

                                  • Discovering a magma feature (magma pool, volcano, magma sea, or curious @@ -1058,7 +1081,7 @@ that cavern to grow within your fortress.
                                  -

                                  liquids

                                  +

                                  liquids

                                  Allows adding magma, water and obsidian to the game. It replaces the normal dfhack command line and can't be used from a hotkey. Settings will be remembered as long as dfhack runs. Intended for use in combination with the command @@ -1071,13 +1094,13 @@ temperatures (creating heat traps). You've been warned.

                                  -

                                  liquids-here

                                  +

                                  liquids-here

                                  Run the liquid spawner with the current/last settings made in liquids (if no settings in liquids were made it paints a point of 7/7 magma by default).

                                  Intended to be used as keybinding. Requires an active in-game cursor.

                                  -

                                  tiletypes

                                  +

                                  tiletypes

                                  Can be used for painting map tiles and is an interactive command, much like liquids.

                                  The tool works with two set of options and a brush. The brush determines which @@ -1138,27 +1161,27 @@ up.

                                  For more details, see the 'help' command while using this.

                                  -

                                  tiletypes-commands

                                  +

                                  tiletypes-commands

                                  Runs tiletypes commands, separated by ;. This makes it possible to change tiletypes modes from a hotkey.

                                  -

                                  tiletypes-here

                                  +

                                  tiletypes-here

                                  Apply the current tiletypes options at the in-game cursor position, including the brush. Can be used from a hotkey.

                                  -

                                  tiletypes-here-point

                                  +

                                  tiletypes-here-point

                                  Apply the current tiletypes options at the in-game cursor position to a single tile. Can be used from a hotkey.

                                  -

                                  tubefill

                                  +

                                  tubefill

                                  Fills all the adamantine veins again. Veins that were empty will be filled in too, but might still trigger a demon invasion (this is a known bug).

                                  -

                                  extirpate

                                  +

                                  extirpate

                                  A tool for getting rid of trees and shrubs. By default, it only kills a tree/shrub under the cursor. The plants are turned into ashes instantly.

                                  Options:

                                  @@ -1178,20 +1201,20 @@ a tree/shrub under the cursor. The plants are turned into ashes instantly.

                                  -

                                  grow

                                  +

                                  grow

                                  Makes all saplings present on the map grow into trees (almost) instantly.

                                  -

                                  immolate

                                  +

                                  immolate

                                  Very similar to extirpate, but additionally sets the plants on fire. The fires can and will spread ;)

                                  -

                                  regrass

                                  +

                                  regrass

                                  Regrows grass. Not much to it ;)

                                  -

                                  weather

                                  +

                                  weather

                                  Prints the current weather map by default.

                                  Also lets you change the current weather to 'clear sky', 'rainy' or 'snowing'.

                                  Options:

                                  @@ -1212,9 +1235,9 @@ can and will spread ;)

                                  -

                                  Map inspection

                                  +

                                  Map inspection

                                  -

                                  cursecheck

                                  +

                                  cursecheck

                                  Checks a single map tile or the whole map/world for cursed creatures (ghosts, vampires, necromancers, werebeasts, zombies).

                                  With an active in-game cursor only the selected tile will be observed. @@ -1269,17 +1292,17 @@ of curses, for example.

                                • -

                                  flows

                                  +

                                  flows

                                  A tool for checking how many tiles contain flowing liquids. If you suspect that your magma sea leaks into HFS, you can use this tool to be sure without revealing the map.

                                  -

                                  probe

                                  +

                                  probe

                                  Can be used to determine tile properties like temperature.

                                  -

                                  prospect

                                  +

                                  prospect

                                  Prints a big list of all the present minerals and plants. By default, only the visible part of the map is scanned.

                                  Options:

                                  @@ -1298,7 +1321,7 @@ the visible part of the map is scanned.

                                  -

                                  Pre-embark estimate

                                  +

                                  Pre-embark estimate

                                  If prospect is called during the embark selection screen, it displays an estimate of layer stone availability.

                                  @@ -1323,7 +1346,7 @@ that is actually present.

                                  -

                                  reveal

                                  +

                                  reveal

                                  This reveals the map. By default, HFS will remain hidden so that the demons don't spawn. You can use 'reveal hell' to reveal everything. With hell revealed, you won't be able to unpause until you hide the map again. If you really want @@ -1332,34 +1355,34 @@ to unpause with hell revealed, use 'reveal demons'.

                                  you move. When you use it this way, you don't need to run 'unreveal'.

                                  -

                                  unreveal

                                  +

                                  unreveal

                                  Reverts the effects of 'reveal'.

                                  -

                                  revtoggle

                                  +

                                  revtoggle

                                  Switches between 'reveal' and 'unreveal'.

                                  -

                                  revflood

                                  +

                                  revflood

                                  This command will hide the whole map and then reveal all the tiles that have a path to the in-game cursor.

                                  -

                                  revforget

                                  +

                                  revforget

                                  When you use reveal, it saves information about what was/wasn't visible before revealing everything. Unreveal uses this information to hide things again. This command throws away the information. For example, use in cases where you abandoned with the fort revealed and no longer want the data.

                                  -

                                  showmood

                                  +

                                  showmood

                                  Shows all items needed for the currently active strange mood.

                                  -

                                  Designations

                                  +

                                  Designations

                                  -

                                  burrow

                                  +

                                  burrow

                                  Miscellaneous burrow control. Allows manipulating burrows and automated burrow expansion while digging.

                                  Options:

                                  @@ -1407,17 +1430,17 @@ Digging 1-wide corridors with the miner inside the burrow is SLOW.
                                  -

                                  digv

                                  +

                                  digv

                                  Designates a whole vein for digging. Requires an active in-game cursor placed over a vein tile. With the 'x' option, it will traverse z-levels (putting stairs between the same-material tiles).

                                  -

                                  digvx

                                  +

                                  digvx

                                  A permanent alias for 'digv x'.

                                  -

                                  digl

                                  +

                                  digl

                                  Designates layer stone for digging. Requires an active in-game cursor placed over a layer stone tile. With the 'x' option, it will traverse z-levels (putting stairs between the same-material tiles). With the 'undo' option it @@ -1425,11 +1448,11 @@ will remove the dig designation instead (if you realize that digging out a 50 z-level deep layer was not such a good idea after all).

                                  -

                                  diglx

                                  +

                                  diglx

                                  A permanent alias for 'digl x'.

                                  -

                                  digexp

                                  +

                                  digexp

                                  This command can be used for exploratory mining.

                                  See: http://df.magmawiki.com/index.php/DF2010:Exploratory_mining

                                  There are two variables that can be set: pattern and filter.

                                  @@ -1492,7 +1515,7 @@ z-level deep layer was not such a good idea after all).

                                  -

                                  digcircle

                                  +

                                  digcircle

                                  A command for easy designation of filled and hollow circles. It has several types of options.

                                  Shape:

                                  @@ -1555,7 +1578,7 @@ repeats with the last selected parameters.

                                -

                                digtype

                                +

                                digtype

                                For every tile on the map of the same vein type as the selected tile, this command designates it to have the same designation as the selected tile. If the selected tile has no designation, they will be dig designated. If an argument is given, the designation of the selected tile is ignored, and all appropriate tiles are set to the specified designation.

                                Options:

                                @@ -1583,7 +1606,7 @@ If an argument is given, the designation of the selected tile is ignored, and al
                                -

                                filltraffic

                                +

                                filltraffic

                                Set traffic designations using flood-fill starting at the cursor.

                                Traffic Type Codes:

                                @@ -1622,7 +1645,7 @@ If an argument is given, the designation of the selected tile is ignored, and al 'filltraffic H' - When used in a room with doors, it will set traffic to HIGH in just that room.
                                -

                                alltraffic

                                +

                                alltraffic

                                Set traffic designations for every single tile of the map (useful for resetting traffic designations).

                                Traffic Type Codes:

                                @@ -1646,7 +1669,7 @@ If an argument is given, the designation of the selected tile is ignored, and al 'alltraffic N' - Set traffic to 'normal' for all tiles.
                                -

                                getplants

                                +

                                getplants

                                This tool allows plant gathering and tree cutting by RAW ID. Specify the types of trees to cut down and/or shrubs to gather by their plant names, separated by spaces.

                                @@ -1673,9 +1696,9 @@ all valid plant IDs will be listed.

                                -

                                Cleanup and garbage disposal

                                +

                                Cleanup and garbage disposal

                                -

                                clean

                                +

                                clean

                                Cleans all the splatter that get scattered all over the map, items and creatures. In an old fortress, this can significantly reduce FPS lag. It can also spoil your !!FUN!!, so think before you use it.

                                @@ -1709,12 +1732,12 @@ also spoil your !!FUN!!, so think before you use it.

                                -

                                spotclean

                                +

                                spotclean

                                Works like 'clean map snow mud', but only for the tile under the cursor. Ideal if you want to keep that bloody entrance 'clean map' would clean up.

                                -

                                autodump

                                +

                                autodump

                                This utility lets you quickly move all items designated to be dumped. Items are instantly moved to the cursor position, the dump flag is unset, and the forbid flag is set, as if it had been dumped normally. @@ -1741,17 +1764,17 @@ Be aware that any active dump item tasks still point at the item.

                                -

                                autodump-destroy-here

                                +

                                autodump-destroy-here

                                Destroy items marked for dumping under cursor. Identical to autodump destroy-here, but intended for use as keybinding.

                                -

                                autodump-destroy-item

                                +

                                autodump-destroy-item

                                Destroy the selected item. The item may be selected in the 'k' list, or inside a container. If called again before the game is resumed, cancels destroy.

                                -

                                cleanowned

                                +

                                cleanowned

                                Confiscates items owned by dwarfs. By default, owned food on the floor and rotten items are confistacted and dumped.

                                Options:

                                @@ -1785,13 +1808,13 @@ worn items with 'X' damage and above.
                                -

                                Bugfixes

                                +

                                Bugfixes

                                -

                                drybuckets

                                +

                                drybuckets

                                This utility removes water from all buckets in your fortress, allowing them to be safely used for making lye.

                                -

                                fixdiplomats

                                +

                                fixdiplomats

                                Up to version 0.31.12, Elves only sent Diplomats to your fortress to propose tree cutting quotas due to a bug; once that bug was fixed, Elves stopped caring about excess tree cutting. This command adds a Diplomat position to all Elven @@ -1800,19 +1823,19 @@ to violate them and potentially start wars) in case you haven't already modified your raws accordingly.

                                -

                                fixmerchants

                                +

                                fixmerchants

                                This command adds the Guild Representative position to all Human civilizations, allowing them to make trade agreements (just as they did back in 0.28.181.40d and earlier) in case you haven't already modified your raws accordingly.

                                -

                                fixveins

                                +

                                fixveins

                                Removes invalid references to mineral inclusions and restores missing ones. Use this if you broke your embark with tools like tiletypes, or if you accidentally placed a construction on top of a valuable mineral floor.

                                -

                                tweak

                                +

                                tweak

                                Contains various tweaks for minor bugs.

                                One-shot subcommands:

                                @@ -1918,7 +1941,7 @@ the units spar more.

                                -

                                fix-armory

                                +

                                fix-armory

                                Enables a fix for storage of squad equipment in barracks.

                                Specifically, it prevents your haulers from moving squad equipment to stockpiles, and instead queues jobs to store it on weapon racks, @@ -1972,9 +1995,9 @@ these rules is intended by Toady; the rest are invented by this plugin.

                                -

                                Mode switch and reclaim

                                +

                                Mode switch and reclaim

                                -

                                lair

                                +

                                lair

                                This command allows you to mark the map as 'monster lair', preventing item scatter on abandon. When invoked as 'lair reset', it does the opposite.

                                Unlike reveal, this command doesn't save the information about tiles - you @@ -1994,7 +2017,7 @@ won't be able to restore state of real monster lairs using 'lair reset'.

                                -

                                mode

                                +

                                mode

                                This command lets you see and change the game mode directly. Not all combinations are good for every situation and most of them will produce undesirable results. There are a few good ones though.

                                @@ -2014,9 +2037,9 @@ You just created a returnable mountain home and gained an adventurer.

                                -

                                Visualizer and data export

                                +

                                Visualizer and data export

                                -

                                ssense / stonesense

                                +

                                ssense / stonesense

                                An isometric visualizer that runs in a second window. This requires working graphics acceleration and at least a dual core CPU (otherwise it will slow down DF).

                                @@ -2029,19 +2052,19 @@ thread: http://df.magmawiki.com/index.php/Utility:Stonesense/Content_repository

                                -

                                mapexport

                                +

                                mapexport

                                Export the current loaded map as a file. This will be eventually usable with visualizers.

                                -

                                dwarfexport

                                +

                                dwarfexport

                                Export dwarves to RuneSmith-compatible XML.

                                -

                                Job management

                                +

                                Job management

                                -

                                job

                                +

                                job

                                Command for general job query and manipulation.

                                Options:
                                @@ -2060,7 +2083,7 @@ in a workshop, or the unit/jobs screen.
                                -

                                job-material

                                +

                                job-material

                                Alter the material of the selected job.

                                Invoked as:

                                @@ -2078,7 +2101,7 @@ over the first available choice with the matching material.
                              • -

                                job-duplicate

                                +

                                job-duplicate

                                Duplicate the selected job in a workshop:
                                  @@ -2089,7 +2112,7 @@ instantly duplicates the job.
                                -

                                workflow

                                +

                                workflow

                                Manage control of repeat jobs.

                                Usage:

                                @@ -2121,7 +2144,7 @@ this list can be copied to a file, and then reloaded using the
                                -

                                Function

                                +

                                Function

                                When the plugin is enabled, it protects all repeat jobs from removal. If they do disappear due to any cause, they are immediately re-added to their workshop and suspended.

                                @@ -2134,7 +2157,7 @@ the frequency of jobs being toggled.

                                in the game UI.

                                -

                                Constraint format

                                +

                                Constraint format

                                The contstraint spec consists of 4 parts, separated with '/' characters:

                                 ITEM[:SUBTYPE]/[GENERIC_MAT,...]/[SPECIFIC_MAT:...]/[LOCAL,<quality>]
                                @@ -2163,7 +2186,7 @@ be used to ignore imported items or items below a certain quality.

                              -

                              Constraint examples

                              +

                              Constraint examples

                              Keep metal bolts within 900-1000, and wood/bone within 150-200.

                               workflow amount AMMO:ITEM_AMMO_BOLTS/METAL 1000 100
                              @@ -2212,15 +2235,15 @@ workflow count CRAFTS///LOCAL,EXCEPTIONAL 100 90
                               
                              -

                              Fortress activity management

                              +

                              Fortress activity management

                              -

                              seedwatch

                              +

                              seedwatch

                              Tool for turning cooking of seeds and plants on/off depending on how much you have of them.

                              See 'seedwatch help' for detailed description.

                              -

                              zone

                              +

                              zone

                              Helps a bit with managing activity zones (pens, pastures and pits) and cages.

                              Options:

                              @@ -2319,7 +2342,7 @@ for war/hunt). Negatable.
                              -

                              Usage with single units

                              +

                              Usage with single units

                              One convenient way to use the zone tool is to bind the command 'zone assign' to a hotkey, maybe also the command 'zone set'. Place the in-game cursor over a pen/pasture or pit, use 'zone set' to mark it. Then you can select units @@ -2328,7 +2351,7 @@ and use 'zone assign' to assign them to their new home. Allows pitting your own dwarves, by the way.

                              -

                              Usage with filters

                              +

                              Usage with filters

                              All filters can be used together with the 'assign' command.

                              Restrictions: It's not possible to assign units who are inside built cages or chained because in most cases that won't be desirable anyways. @@ -2346,14 +2369,14 @@ are not properly added to your own stocks; slaughtering them should work).

                              Most filters can be negated (e.g. 'not grazer' -> race is not a grazer).

                              -

                              Mass-renaming

                              +

                              Mass-renaming

                              Using the 'nick' command you can set the same nickname for multiple units. If used without 'assign', 'all' or 'count' it will rename all units in the current default target zone. Combined with 'assign', 'all' or 'count' (and further optional filters) it will rename units matching the filter conditions.

                              -

                              Cage zones

                              +

                              Cage zones

                              Using the 'tocages' command you can assign units to a set of cages, for example a room next to your butcher shop(s). They will be spread evenly among available cages to optimize hauling to and butchering from them. For this to work you need @@ -2364,7 +2387,7 @@ would make no sense, but can be used together with 'nick' or 'remnick' and all the usual filters.

                              -

                              Examples

                              +

                              Examples

                              zone assign all own ALPACA minage 3 maxage 10
                              Assign all own alpacas who are between 3 and 10 years old to the selected @@ -2390,7 +2413,7 @@ on the current default zone.
                              -

                              autonestbox

                              +

                              autonestbox

                              Assigns unpastured female egg-layers to nestbox zones. Requires that you create pen/pasture zones above nestboxes. If the pen is bigger than 1x1 the nestbox must be in the top left corner. Only 1 unit will be assigned per pen, regardless @@ -2419,7 +2442,7 @@ frames between runs.

                              -

                              autobutcher

                              +

                              autobutcher

                              Assigns lifestock for slaughter once it reaches a specific count. Requires that you add the target race(s) to a watch list. Only tame units will be processed.

                              Named units will be completely ignored (to protect specific animals from @@ -2527,7 +2550,7 @@ autobutcher.bat

                              -

                              autolabor

                              +

                              autolabor

                              Automatically manage dwarf labors.

                              When enabled, autolabor periodically checks your dwarves and enables or disables labors. It tries to keep as many dwarves as possible busy but @@ -2541,14 +2564,14 @@ while it is enabled.

                              -

                              Other

                              +

                              Other

                              -

                              catsplosion

                              +

                              catsplosion

                              Makes cats just multiply. It is not a good idea to run this more than once or twice.

                              -

                              dfusion

                              +

                              dfusion

                              This is the DFusion lua plugin system by Warmist, running as a DFHack plugin. There are two parts to this plugin: an interactive script that shows a text based menu and lua modules. Some of the functionality of is intentionaly left out of the menu:
                              @@ -2573,7 +2596,7 @@ twice.

                              -

                              misery

                              +

                              misery

                              When enabled, every new negative dwarven thought will be multiplied by a factor (2 by default).

                              Usage:

                              @@ -2597,7 +2620,7 @@ twice.

                              -

                              Scripts

                              +

                              Scripts

                              Lua or ruby scripts placed in the hack/scripts/ directory are considered for execution as if they were native DFHack commands. They are listed at the end of the 'ls' command output.

                              @@ -2606,7 +2629,7 @@ only be listed by ls if called as 'ls -a'. This is intended as a way to hide scripts that are obscure, developer-oriented, or should be used as keybindings.

                              Some notable scripts:

                              -

                              fix/*

                              +

                              fix/*

                              Scripts in this subdirectory fix various bugs and issues, some of them obscure.

                              • fix/dead-units

                                @@ -2638,12 +2661,12 @@ in dfhack.init makes it run automatically.

                              -

                              gui/*

                              +

                              gui/*

                              Scripts that implement dialogs inserted into the main game window are put in this directory.

                              -

                              binpatch

                              +

                              binpatch

                              Checks, applies or removes binary patches directly in memory at runtime:

                               binpatch check/apply/remove <patchname>
                              @@ -2653,17 +2676,17 @@ script uses hack/patches/<df-v
                               the version appropriate for the currently loaded executable.

                              -

                              quicksave

                              +

                              quicksave

                              If called in dwarf mode, makes DF immediately auto-save the game by setting a flag normally used in seasonal auto-save.

                              -

                              setfps

                              +

                              setfps

                              Run setfps <number> to set the FPS cap at runtime, in case you want to watch combat in slow motion or something :)

                              -

                              siren

                              +

                              siren

                              Wakes up sleeping units, cancels breaks and stops parties either everywhere, or in the burrows given as arguments. In return, adds bad thoughts about noise, tiredness and lack of protection. Also, the units with interrupted @@ -2671,7 +2694,7 @@ breaks will go on break again a lot sooner. The script is intended for emergencies, e.g. when a siege appears, and all your military is partying.

                              -

                              growcrops

                              +

                              growcrops

                              Instantly grow seeds inside farming plots.

                              With no argument, this command list the various seed types currently in use in your farming plots. @@ -2683,7 +2706,7 @@ growcrops plump 40

                              -

                              removebadthoughts

                              +

                              removebadthoughts

                              This script remove negative thoughts from your dwarves. Very useful against tantrum spirals.

                              The script can target a single creature, when used with the him argument, @@ -2697,7 +2720,7 @@ but in the short term your dwarves will get much more joyful.

                              quickly after you unpause.

                              -

                              slayrace

                              +

                              slayrace

                              Kills any unit of a given race.

                              With no argument, lists the available races and count eligible targets.

                              With the special argument him, targets only the selected creature.

                              @@ -2725,7 +2748,7 @@ slayrace elve magma
                              -

                              magmasource

                              +

                              magmasource

                              Create an infinite magma source on a tile.

                              This script registers a map tile as a magma source, and every 12 game ticks that tile receives 1 new unit of flowing magma.

                              @@ -2740,7 +2763,7 @@ To remove all placed sources, call magmasource stop

                              With no argument, this command shows an help message and list existing sources.

                              -

                              digfort

                              +

                              digfort

                              A script to designate an area for digging according to a plan in csv format.

                              This script, inspired from quickfort, can designate an area for digging. Your plan should be stored in a .csv file like this:

                              @@ -2758,7 +2781,7 @@ To skip a row in your design, use a single ;.<

                              The script takes the plan filename, starting from the root df folder.

                              -

                              superdwarf

                              +

                              superdwarf

                              Similar to fastdwarf, per-creature.

                              To make any creature superfast, target it ingame using 'v' and:

                              @@ -2768,17 +2791,17 @@ superdwarf add
                               

                              This plugin also shortens the 'sleeping' and 'on break' periods of targets.

                              -

                              drainaquifer

                              +

                              drainaquifer

                              Remove all 'aquifer' tag from the map blocks. Irreversible.

                              -

                              deathcause

                              +

                              deathcause

                              Focus a body part ingame, and this script will display the cause of death of the creature. Also works when selecting units from the 'u'nitlist viewscreen.

                              -

                              lua

                              +

                              lua

                              There are the following ways to invoke this command:

                              1. lua (without any parameters)

                                @@ -2797,11 +2820,11 @@ directory. If the filename is not supplied, it loads "dfhack.lua".

                              -

                              embark

                              +

                              embark

                              Allows to embark anywhere. Currently windows only.

                              -

                              lever

                              +

                              lever

                              Allow manipulation of in-game levers from the dfhack console.

                              Can list levers, including state and links, with:

                              @@ -2815,7 +2838,7 @@ lever pull 42 --now
                               
                              -

                              stripcaged

                              +

                              stripcaged

                              For dumping items inside cages. Will mark selected items for dumping, then a dwarf may come and actually dump it. See also autodump.

                              With the items argument, only dumps items laying in the cage, excluding @@ -2833,7 +2856,7 @@ stripcaged weapons 25321 34228

                              -

                              create-items

                              +

                              create-items

                              Spawn arbitrary items under the cursor.

                              The first argument gives the item category, the second gives the material, and the optionnal third gives the number of items to create (defaults to 20).

                              @@ -2855,7 +2878,7 @@ create-items bar adamantine
                              -

                              soundsense-season

                              +

                              soundsense-season

                              It is a well known issue that Soundsense cannot detect the correct current season when a savegame is loaded and has to play random season music until a season switch occurs.

                              @@ -2865,7 +2888,7 @@ call the script from dfhack.init.

                              -

                              In-game interface tools

                              +

                              In-game interface tools

                              These tools work by displaying dialogs or overlays in the game window, and are mostly implemented by lua scripts.

                              @@ -2878,7 +2901,7 @@ existing DF screens, they deliberately use red instead of green for the key.

                              guideline because it arguably just fixes small usability bugs in the game UI.

                              -

                              Dwarf Manipulator

                              +

                              Dwarf Manipulator

                              Implemented by the manipulator plugin. To activate, open the unit screen and press 'l'.

                              images/manipulator.png @@ -2917,7 +2940,7 @@ cursor onto that cell instead of toggling it. directly to the main dwarf mode screen.

                              -

                              AutoMaterial

                              +

                              AutoMaterial

                              The automaterial plugin makes building constructions (walls, floors, fortifications, etc) a little bit easier by saving you from having to trawl through long lists of materials each time you place one.

                              @@ -2974,7 +2997,7 @@ materials, it returns you back to this screen. If you use this along with severa enabled materials, you should be able to place complex constructions more conveniently.

                              -

                              gui/liquids

                              +

                              gui/liquids

                              To use, bind to a key (the example config uses Alt-L) and activate in the 'k' mode.

                              images/liquids.png

                              This script is a gui front-end to the liquids plugin and works similar to it, @@ -2994,7 +3017,7 @@ rivers power water wheels even when full and technically not flowing.

                              After setting up the desired operations using the described keys, use Enter to apply them.

                              -

                              gui/mechanisms

                              +

                              gui/mechanisms

                              To use, bind to a key (the example config uses Ctrl-M) and activate in the 'q' mode.

                              images/mechanisms.png

                              Lists mechanisms connected to the building, and their links. Navigating the list centers @@ -3004,7 +3027,7 @@ focus on the current one. Shift-Enter has an effect equivalent to pressing Enter re-entering the mechanisms ui.

                              -

                              gui/rename

                              +

                              gui/rename

                              Backed by the rename plugin, this script allows entering the desired name via a simple dialog in the game ui.

                                @@ -3027,7 +3050,7 @@ their species string.

                                unit profession change to Ctrl-Shift-T.

                              -

                              gui/room-list

                              +

                              gui/room-list

                              To use, bind to a key (the example config uses Alt-R) and activate in the 'q' mode, either immediately or after opening the assign owner page.

                              images/room-list.png @@ -3035,7 +3058,7 @@ either immediately or after opening the assign owner page.

                              list, and allows unassigning them.

                              -

                              gui/choose-weapons

                              +

                              gui/choose-weapons

                              Bind to a key (the example config uses Ctrl-W), and activate in the Equip->View/Customize page of the military screen.

                              Depending on the cursor location, it rewrites all 'individual choice weapon' entries @@ -3046,7 +3069,7 @@ only that entry, and does it even if it is not 'individual choice'.

                              and may lead to inappropriate weapons being selected.

                              -

                              gui/guide-path

                              +

                              gui/guide-path

                              Bind to a key (the example config uses Alt-P), and activate in the Hauling menu with the cursor over a Guide order.

                              images/guide-path.png @@ -3054,7 +3077,7 @@ the cursor over a Guide order.

                              computes it when the order is executed for the first time.

                              -

                              gui/workshop-job

                              +

                              gui/workshop-job

                              Bind to a key (the example config uses Alt-A), and activate with a job selected in a workshop in the 'q' mode.

                              images/workshop-job.png @@ -3090,7 +3113,7 @@ and then try to change the input item type, now it won't let you select plan you have to unset the material first.

                              -

                              gui/workflow

                              +

                              gui/workflow

                              Bind to a key (the example config uses Alt-W), and activate with a job selected in a workshop in the 'q' mode.

                              images/workflow.png @@ -3137,7 +3160,7 @@ the current stock value. The bright green dashed line is the target limit (maximum) and the dark green line is that minus the gap (minimum).

                              -

                              gui/assign-rack

                              +

                              gui/assign-rack

                              Bind to a key (the example config uses P), and activate when viewing a weapon rack in the 'q' mode.

                              images/assign-rack.png @@ -3161,7 +3184,7 @@ the intended user. In order to aid in the choice, it shows the number of currently assigned racks for every valid squad.

                              -

                              gui/advfort

                              +

                              gui/advfort

                              This script allows to perform jobs in adventure mode. For more complete help press '?' while script is running. It's most confortable to use this as a keybinding. (e.g. keybinding set Ctrl-T gui/advfort). Possible arguments:

                              @@ -3174,7 +3197,7 @@ implies -a
                              -

                              gui/gm-editor

                              +

                              gui/gm-editor

                              There are three ways to open this editor:

                              • using gui/gm-editor command/keybinding - opens editor on what is selected @@ -3189,7 +3212,7 @@ in-game help.

                              -

                              Behavior Mods

                              +

                              Behavior Mods

                              These plugins, when activated via configuration UI or by detecting certain structures in RAWs, modify the game engine behavior concerning the target objects to add features not otherwise present.

                              @@ -3200,20 +3223,20 @@ technical challenge, and do not represent any long-term plans to produce more similar modifications of the game.

                              -

                              Siege Engine

                              +

                              Siege Engine

                              The siege-engine plugin enables siege engines to be linked to stockpiles, and aimed at an arbitrary rectangular area across Z levels, instead of the original four directions. Also, catapults can be ordered to load arbitrary objects, not just stones.

                              -

                              Rationale

                              +

                              Rationale

                              Siege engines are a very interesting feature, but sadly almost useless in the current state because they haven't been updated since 2D and can only aim in four directions. This is an attempt to bring them more up to date until Toady has time to work on it. Actual improvements, e.g. like making siegers bring their own, are something only Toady can do.

                              -

                              Configuration UI

                              +

                              Configuration UI

                              The configuration front-end to the plugin is implemented by the gui/siege-engine script. Bind it to a key (the example config uses Alt-A) and activate after selecting a siege engine in 'q' mode.

                              @@ -3236,7 +3259,7 @@ menu.

                              -

                              Power Meter

                              +

                              Power Meter

                              The power-meter plugin implements a modified pressure plate that detects power being supplied to gear boxes built in the four adjacent N/S/W/E tiles.

                              The configuration front-end is implemented by the gui/power-meter script. Bind it to a @@ -3247,11 +3270,11 @@ in the build menu.

                              configuration page, but configures parameters relevant to the modded power meter building.

                              -

                              Steam Engine

                              +

                              Steam Engine

                              The steam-engine plugin detects custom workshops with STEAM_ENGINE in their token, and turns them into real steam engines.

                              -

                              Rationale

                              +

                              Rationale

                              The vanilla game contains only water wheels and windmills as sources of power, but windmills give relatively little power, and water wheels require flowing water, which must either be a real river and thus immovable and @@ -3262,7 +3285,7 @@ it can be done just by combining existing features of the game engine in a new way with some glue code and a bit of custom logic.

                              -

                              Construction

                              +

                              Construction

                              The workshop needs water as its input, which it takes via a passable floor tile below it, like usual magma workshops do. The magma version also needs magma.

                              @@ -3286,7 +3309,7 @@ short axles that can be built later than both of the engines.

                              -

                              Operation

                              +

                              Operation

                              In order to operate the engine, queue the Stoke Boiler job (optionally on repeat). A furnace operator will come, possibly bringing a bar of fuel, and perform it. As a result, a "boiling water" item will appear @@ -3317,7 +3340,7 @@ decrease it by further 4%, and also decrease the whole steam use rate by 10%.

                              -

                              Explosions

                              +

                              Explosions

                              The engine must be constructed using barrel, pipe and piston from fire-safe, or in the magma version magma-safe metals.

                              During operation weak parts get gradually worn out, and @@ -3326,7 +3349,7 @@ toppled during operation by a building destroyer, or a tantruming dwarf.

                              -

                              Save files

                              +

                              Save files

                              It should be safe to load and view engine-using fortresses from a DF version without DFHack installed, except that in such case the engines won't work. However actually making modifications @@ -3337,7 +3360,7 @@ being generated.

                              -

                              Add Spatter

                              +

                              Add Spatter

                              This plugin makes reactions with names starting with SPATTER_ADD_ produce contaminants on the items instead of improvements. The produced contaminants are immune to being washed away by water or destroyed by diff --git a/Readme.rst b/Readme.rst index bc831e4a6..7e1a7bf51 100644 --- a/Readme.rst +++ b/Readme.rst @@ -449,6 +449,26 @@ Options: :bees: turn colonies into honey bee colonies +createitem +---------- +Allows creating new items of arbitrary types and made of arbitrary materials. +Any items created are spawned at the feet of the selected unit. + +Specify the item and material information as you would indicate them in custom reaction raws, with the following differences: +* Separate the item and material with a space rather than a colon +* If the item has no subtype, omit the :NONE +* If the item is REMAINS, FISH, FISH_RAW, VERMIN, PET, or EGG, specify a CREATURE:CASTE pair instead of a material token. + +Corpses, body parts, and prepared meals cannot be created using this tool. + +Examples: + ``createitem GLOVES:ITEM_GLOVES_GAUNTLETS INORGANIC:STEEL`` + Create a pair of steel gauntlets. + ``createitem WOOD PLANT_MAT:TOWER_CAP:WOOD`` + Create tower-cap logs. + ``createitem FISH FISH_SHAD:MALE`` + Create cleaned shad, ready to eat. + deramp (by zilpin) ------------------ Removes all ramps designated for removal from the map. This is useful for replicating the old channel digging designation. From 9bd999ebc1481b7d6e24ff49b1edea85272a6408 Mon Sep 17 00:00:00 2001 From: Quietust Date: Thu, 28 Feb 2013 09:23:48 -0600 Subject: [PATCH 10/20] Update createitem to allow specifying quantity, also allow it to auto-detect whether it needs to create extra gloves and assign handedness --- Readme.html | 8 +++--- Readme.rst | 8 +++--- plugins/createitem.cpp | 63 +++++++++++++++++++++++++++--------------- 3 files changed, 49 insertions(+), 30 deletions(-) diff --git a/Readme.html b/Readme.html index a3a2ab9c1..7b008a261 100644 --- a/Readme.html +++ b/Readme.html @@ -1040,12 +1040,12 @@ Any items created are spawned at the feet of the selected unit.

                              Examples:
                              -
                              createitem GLOVES:ITEM_GLOVES_GAUNTLETS INORGANIC:STEEL
                              -
                              Create a pair of steel gauntlets.
                              +
                              createitem GLOVES:ITEM_GLOVES_GAUNTLETS INORGANIC:STEEL 2
                              +
                              Create 2 pairs of steel gauntlets.
                              createitem WOOD PLANT_MAT:TOWER_CAP:WOOD
                              Create tower-cap logs.
                              -
                              createitem FISH FISH_SHAD:MALE
                              -
                              Create cleaned shad, ready to eat.
                              +
                              createitem FISH FISH_SHAD:MALE 5
                              +
                              Create a stack of 5 cleaned shad, ready to eat.
                              diff --git a/Readme.rst b/Readme.rst index 7e1a7bf51..14a11697e 100644 --- a/Readme.rst +++ b/Readme.rst @@ -462,12 +462,12 @@ Specify the item and material information as you would indicate them in custom r Corpses, body parts, and prepared meals cannot be created using this tool. Examples: - ``createitem GLOVES:ITEM_GLOVES_GAUNTLETS INORGANIC:STEEL`` - Create a pair of steel gauntlets. + ``createitem GLOVES:ITEM_GLOVES_GAUNTLETS INORGANIC:STEEL 2`` + Create 2 pairs of steel gauntlets. ``createitem WOOD PLANT_MAT:TOWER_CAP:WOOD`` Create tower-cap logs. - ``createitem FISH FISH_SHAD:MALE`` - Create cleaned shad, ready to eat. + ``createitem FISH FISH_SHAD:MALE 5`` + Create a stack of 5 cleaned shad, ready to eat. deramp (by zilpin) ------------------ diff --git a/plugins/createitem.cpp b/plugins/createitem.cpp index 722932a99..3382e0761 100644 --- a/plugins/createitem.cpp +++ b/plugins/createitem.cpp @@ -44,11 +44,12 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out ) return CR_OK; } -bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, int hand = 0) +bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, bool glove2 = false) { vector out_items; vector in_reag; vector in_items; + bool is_gloves = (prod->item_type == df::item_type::GLOVES); prod->produce(unit, &out_items, &in_reag, &in_items, 1, df::job_skill::NONE, ui->main.fortress_entity, df::world_site::find(ui->site_id)); if (!out_items.size()) @@ -56,28 +57,56 @@ bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, int hand = 0) for (size_t i = 0; i < out_items.size(); i++) { out_items[i]->moveToGround(unit->pos.x, unit->pos.y, unit->pos.z); - if (hand) - out_items[i]->setGloveHandedness(hand); + if (is_gloves) + { + // if the reaction creates gloves without handedness, then create 2 sets (left and right) + if (out_items[i]->getGloveHandedness() > 0) + is_gloves = false; + else + out_items[i]->setGloveHandedness(glove2 ? 2 : 1); + } } + if (is_gloves && !glove2) + return makeItem(prod, unit, true); + return true; } command_result df_createitem (color_ostream &out, vector & parameters) { string item_str, material_str; - df::item_type item_type; - int16_t item_subtype; - int16_t mat_type; - int32_t mat_index; + df::item_type item_type = df::item_type::NONE; + int16_t item_subtype = -1; + int16_t mat_type = -1; + int32_t mat_index = -1; + int count = 1; - if (parameters.size() != 2) + if ((parameters.size() < 2) || (parameters.size() > 3)) { - out.print("Syntax: createitem ITEM_TYPE:ITEM_SUBTYPE MATERIAL:ETC\n"); + out.print("Syntax: createitem [count]\n" + " - Item token for what you wish to create, as specified in custom\n" + " reactions. If the item has no subtype, omit the :NONE.\n" + " - The material you want the item to be made of, as specified\n" + " in custom reactions. For REMAINS, FISH, FISH_RAW, VERMIN,\n" + " PET, and EGG, replace this with a creature ID and caste.\n" + " [count] - How many of the item you wish to create.\n" + ); return CR_WRONG_USAGE; } item_str = parameters[0]; material_str = parameters[1]; + if (parameters.size() == 3) + { + stringstream ss(parameters[2]); + ss >> count; + if (count < 1) + { + out.printerr("You cannot produce less than one item!\n"); + return CR_FAILURE; + } + } + ItemTypeInfo item; MaterialInfo material; vector tokens; @@ -106,7 +135,7 @@ command_result df_createitem (color_ostream &out, vector & parameters) case df::item_type::TOOL: if (item_subtype == -1) { - out.printerr("You must specify a valid subtype!\n"); + out.printerr("You must specify a subtype!\n"); return CR_FAILURE; } default: @@ -132,7 +161,6 @@ command_result df_createitem (color_ostream &out, vector & parameters) return CR_FAILURE; } - mat_type = mat_index = -1; for (size_t i = 0; i < world->raws.creatures.all.size(); i++) { df::creature_raw *creature = world->raws.creatures.all[i]; @@ -196,7 +224,7 @@ command_result df_createitem (color_ostream &out, vector & parameters) prod->mat_type = mat_type; prod->mat_index = mat_index; prod->probability = 100; - prod->count = 1; + prod->count = count; switch (item_type) { case df::item_type::BAR: @@ -216,16 +244,7 @@ command_result df_createitem (color_ostream &out, vector & parameters) break; } - bool result; -#if 1 - // Workaround for DF issue #0006273 - if (item_type == df::item_type::GLOVES) - result = makeItem(prod, unit, 1) && makeItem(prod, unit, 2); - else -#endif - result = makeItem(prod, unit); - - if (!result) + if (!makeItem(prod, unit)) { out.printerr("Failed to create item!\n"); return CR_FAILURE; From b07f2fc33fa21222841757df53a93ffc7a5cc29b Mon Sep 17 00:00:00 2001 From: Quietust Date: Thu, 28 Feb 2013 10:00:00 -0600 Subject: [PATCH 11/20] Get entity from unit->civ_id instead of from ui (so it works in advmode), and only get site in fortress mode --- plugins/createitem.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/createitem.cpp b/plugins/createitem.cpp index 3382e0761..8764f6ae2 100644 --- a/plugins/createitem.cpp +++ b/plugins/createitem.cpp @@ -12,6 +12,7 @@ #include "modules/Materials.h" #include "DataDefs.h" +#include "df/game_type.h" #include "df/world.h" #include "df/ui.h" #include "df/unit.h" @@ -28,6 +29,7 @@ using namespace DFHack; using df::global::world; using df::global::ui; +using df::global::gametype; DFHACK_PLUGIN("createitem"); @@ -51,7 +53,9 @@ bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, bool glove2 = vector in_items; bool is_gloves = (prod->item_type == df::item_type::GLOVES); - prod->produce(unit, &out_items, &in_reag, &in_items, 1, df::job_skill::NONE, ui->main.fortress_entity, df::world_site::find(ui->site_id)); + prod->produce(unit, &out_items, &in_reag, &in_items, 1, df::job_skill::NONE, + df::historical_entity::find(unit->civ_id), + ((*gametype == df::game_type::DWARF_MAIN) || (*gametype == df::game_type::DWARF_RECLAIM)) ? df::world_site::find(ui->site_id) : NULL); if (!out_items.size()) return false; for (size_t i = 0; i < out_items.size(); i++) From 54046c74dac9aef8deb1e600c7764497bfef3887 Mon Sep 17 00:00:00 2001 From: Warmist Date: Sun, 3 Mar 2013 17:33:07 +0200 Subject: [PATCH 12/20] advfort: added site name display. --- scripts/gui/advfort.lua | 73 ++++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/scripts/gui/advfort.lua b/scripts/gui/advfort.lua index f58735361..532330b16 100644 --- a/scripts/gui/advfort.lua +++ b/scripts/gui/advfort.lua @@ -73,6 +73,31 @@ function showHelp() Disclaimer(helptext) dialog.showMessage("Help!?!",helptext) end +--[[ Util functions ]]-- +function advGlobalPos() + local map=df.global.world.map + local wd=df.global.world.world_data + local adv=df.global.world.units.active[0] + --wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y + --return wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y + --return wd.adv_region_x*16+wd.adv_emb_x+adv.pos.x/16,wd.adv_region_y*16+wd.adv_emb_y+adv.pos.y/16 + --print(map.region_x,map.region_y,adv.pos.x,adv.pos.y) + --print(map.region_x+adv.pos.x/48, map.region_y+adv.pos.y/48,wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y) + return math.floor(map.region_x+adv.pos.x/48), math.floor(map.region_y+adv.pos.y/48) +end +function inSite() + local tx,ty=advGlobalPos() + --print(tx,ty) + + for k,v in pairs(df.global.world.world_data.sites) do + local tp={v.pos.x,v.pos.y} + if tx>=tp[1]*16+v.rgn_min_x and tx<=tp[1]*16+v.rgn_max_x and + ty>=tp[2]*16+v.rgn_min_y and ty<=tp[2]*16+v.rgn_max_y then + --print(k) + return v + end + end +end --[[ low level job management ]]-- function getLastJobLink() local st=df.global.world.job_list @@ -827,8 +852,17 @@ function usetool:init(args) visible=false, text={ {id="text1",gap=1,key=keybinds.workshop.key,key_sep="()", text="Workshop menu",pen=dfhack.pen.parse{fg=COLOR_YELLOW,bg=0}}} + }, + + wid.Label{ + view_id="siteLabel", + frame = {t=1,xalign=-1,yalign=0}, + visible=false, + text={ + {id="text1", text="Site:"},{id="site", text="name"} } } + } end function usetool:onIdle() @@ -948,7 +982,7 @@ function usetool:openPutWindow(building) local adv=df.global.world.units.active[0] local items=EnumItems{pos=adv.pos,unit=adv, - inv={[df.unit_inventory_item.T_mode.Hauled]=true,[df.unit_inventory_item.T_mode.Worn]=true, + inv={[df.unit_inventory_item.T_mode.Hauled]=true,--[df.unit_inventory_item.T_mode.Worn]=true, [df.unit_inventory_item.T_mode.Weapon]=true,},deep=true} local choices={} for k,v in pairs(items) do @@ -1040,7 +1074,12 @@ function usetool:armCleanTrap(building) LoadStoneTrap, LoadWeaponTrap, ]] - + if building.trap_type==df.trap_type.Lever then + --link + return + end + --building.trap_type==df.trap_type.PressurePlate then + --settings/link local args={unit=adv,post_actions={AssignBuildingRef,AssignJobItems},pos=adv.pos,from_pos=adv.pos,job_type=df.job_type.CleanTrap} if building.trap_type==df.trap_type.CageTrap then args.job_type=df.job_type.LoadCageTrap @@ -1157,7 +1196,7 @@ MODES={ input=usetool.operatePump, }, [df.building_type.Trap]={ - name="Arm/Clean Trap", + name="Interact", input=usetool.armCleanTrap, }, [df.building_type.Hive]={ @@ -1168,8 +1207,8 @@ MODES={ function usetool:shopMode(enable,mode,building) self.subviews.shopLabel.visible=enable if mode then - self.subviews.shopLabel:itemById("text1").text=mode.name - self.building=building + self.subviews.shopLabel:itemById("text1").text=mode.name + self.building=building end self.mode=mode end @@ -1178,20 +1217,7 @@ function usetool:shopInput(keys) self:openShopWindowButtoned(self.in_shop) end end -function advGlobalPos() - local wd=df.global.world.world_data - return wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y -end -function inSite() - local tx,ty=advGlobalPos() - for k,v in pairs(df.global.world.world_data.sites) do - local tp={v.pos.x,v.pos.y} - if tx>=tp[1]*16+v.rgn_min_x and tx<=tp[1]*16+v.rgn_max_x and - ty>=tp[2]*16+v.rgn_min_y and ty<=tp[2]*16+v.rgn_max_y then - return v - end - end -end + function usetool:setupFields() local adv=df.global.world.units.active[0] local civ_id=df.global.world.units.active[0].civ_id @@ -1271,6 +1297,7 @@ function usetool:fieldInput(keys) end function usetool:onInput(keys) local adv=df.global.world.units.active[0] + if keys.LEAVESCREEN then if df.global.cursor.x~=-30000 then self:sendInputToParent("LEAVESCREEN") @@ -1298,6 +1325,14 @@ function usetool:onInput(keys) self:fieldInput(keys) end end + local site=inSite() + + if site then + self.subviews.siteLabel.visible=true + self.subviews.siteLabel:itemById("site").text=dfhack.TranslateName(site.name) + else + self.subviews.siteLabel.visible=false + end end function usetool:isOnBuilding() local adv=df.global.world.units.active[0] From 0afffe77c004e91019c1e4ab4e1cb7636f80c61d Mon Sep 17 00:00:00 2001 From: Warmist Date: Tue, 5 Mar 2013 00:25:25 +0200 Subject: [PATCH 13/20] Some help for companion-order --- Readme.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Readme.rst b/Readme.rst index 236eafb01..35e675600 100644 --- a/Readme.rst +++ b/Readme.rst @@ -2430,6 +2430,21 @@ keybinding. (e.g. keybinding set Ctrl-T gui/advfort). Possible arguments: * job - selects that job (e.g. Dig or FellTree) +gui/companion-order.lua +======================= + +A script to issue orders for companions. Select companions with lower case chars, issue orders with upper +case. Must be in look or talk mode to issue command on tile. + +* move - orders selected companions to move to location. If companions are following they will move no more than 3 tiles from you. +* equip - try to equip items on the ground. +* pick-up - try to take items into hand (also wield) +* unequip - remove and drop equipment +* unwield - drop held items +* wait - temporarely remove from party +* follow - rejoin the party after "wait" +* leave - remove from party (can be rejoined by talking) + gui/gm-editor ============= @@ -2442,7 +2457,7 @@ There are three ways to open this editor: * using gui/gm-editor - executes lua command and opens editor on it's results (e.g. gui/gm-editor "df.global.world.items.all" shows all items) -* using gui/gm-edito dialog - shows an in game dialog to input lua command. Works +* using gui/gm-editor dialog - shows an in game dialog to input lua command. Works the same as version above. This editor allows to change and modify almost anything in df. Press '?' for an From 5884fad5c6df85bb32291fb4c1cd441395a04d9e Mon Sep 17 00:00:00 2001 From: Warmist Date: Tue, 5 Mar 2013 00:28:30 +0200 Subject: [PATCH 14/20] no .lua needed for Readme.rst --- Readme.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.rst b/Readme.rst index 35e675600..41d7a7426 100644 --- a/Readme.rst +++ b/Readme.rst @@ -2430,7 +2430,7 @@ keybinding. (e.g. keybinding set Ctrl-T gui/advfort). Possible arguments: * job - selects that job (e.g. Dig or FellTree) -gui/companion-order.lua +gui/companion-order ======================= A script to issue orders for companions. Select companions with lower case chars, issue orders with upper From 5be2ecb08075b4bdc38329478549ebe4ae68d227 Mon Sep 17 00:00:00 2001 From: Warmist Date: Wed, 6 Mar 2013 00:22:59 +0200 Subject: [PATCH 15/20] advfort.lua: added BuildLast for mass building of e.g. walls etc. --- scripts/gui/advfort.lua | 64 +++++++++++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/scripts/gui/advfort.lua b/scripts/gui/advfort.lua index 532330b16..b4744930e 100644 --- a/scripts/gui/advfort.lua +++ b/scripts/gui/advfort.lua @@ -43,7 +43,7 @@ for k,v in ipairs({...}) do --setting parsing end mode=mode or 0 - +last_building=last_building or {} function Disclaimer(tlb) local dsc={"The Gathering Against ",{text="Goblin ",pen=dfhack.pen.parse{fg=COLOR_GREEN,bg=0}}, "Oppresion ", @@ -368,7 +368,12 @@ function BuildingChosen(inp_args,type_id,subtype_id,custom_id) if inp_args then args.pos=inp_args.pos or args.pos end + last_building.type=args.type + last_building.subtype=args.subtype + last_building.custom=args.custom + if chooseBuildingWidthHeightDir(args) then + return end --if settings.build_by_items then @@ -736,35 +741,51 @@ function AssignJobItems(args) return true --]=] end +function CheckAndFinishBuilding(args,bld) + for idx,job in pairs(bld.jobs) do + if job.job_type==df.job_type.ConstructBuilding then + args.job=job + break + end + end + + if args.job~=nil then + local ok,msg=AssignJobItems(args) + if not ok then + return false,msg + else + AssignUnitToJob(args.job,args.unit,args.from_pos) + end + else + local t={items=buildings.getFiltersByType({},bld:getType(),bld:getSubtype(),bld:getCustomType())} + args.pre_actions={dfhack.curry(setFiltersUp,t),AssignJobItems,AssignBuildingRef} + local ok,msg=makeJob(args) + return ok,msg + end +end function AssignJobToBuild(args) local bld=dfhack.buildings.findAtTile(args.pos) args.job_type=df.job_type.ConstructBuilding if bld~=nil then - for idx,job in pairs(bld.jobs) do - if job.job_type==df.job_type.ConstructBuilding then - args.job=job - break - end - end - - if args.job~=nil then - local ok,msg=AssignJobItems(args) - if not ok then - return false,msg - else - AssignUnitToJob(args.job,args.unit,args.from_pos) - end - else - local t={items=buildings.getFiltersByType({},bld:getType(),bld:getSubtype(),bld:getCustomType())} - args.pre_actions={dfhack.curry(setFiltersUp,t),AssignJobItems,AssignBuildingRef} - local ok,msg=makeJob(args) - return ok,msg - end + CheckAndFinishBuilding(args,bld) else bdialog.BuildingDialog{on_select=dfhack.curry(BuildingChosen,args),hide_none=true}:show() end return true end +function BuildLast(args) + local bld=dfhack.buildings.findAtTile(args.pos) + args.job_type=df.job_type.ConstructBuilding + if bld~=nil then + CheckAndFinishBuilding(args,bld) + else + --bdialog.BuildingDialog{on_select=dfhack.curry(BuildingChosen,args),hide_none=true}:show() + if last_building and last_building.type then + BuildingChosen(args,last_building.type,last_building.subtype,last_building.custom) + end + end + return true +end function CancelJob(unit) local c_job=unit.job.current_job if c_job then @@ -814,6 +835,7 @@ actions={ {"RemoveStairs" ,df.job_type.RemoveStairs,{IsStairs,NotConstruct}}, --{"HandleLargeCreature" ,df.job_type.HandleLargeCreature,{isUnit},{SetCreatureRef}}, {"Build" ,AssignJobToBuild,{NoConstructedBuilding}}, + {"BuildLast" ,BuildLast,{NoConstructedBuilding}}, {"Clean" ,df.job_type.Clean,{}}, } From 3ed5f06f498428778c547148832bfbd0edc31673 Mon Sep 17 00:00:00 2001 From: Warmist Date: Sat, 9 Mar 2013 12:54:07 +0200 Subject: [PATCH 16/20] Fix for eventful and a advfort not to show worn items. --- plugins/eventful.cpp | 2 +- scripts/gui/advfort.lua | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/plugins/eventful.cpp b/plugins/eventful.cpp index 00b764ad1..58079bacf 100644 --- a/plugins/eventful.cpp +++ b/plugins/eventful.cpp @@ -60,7 +60,7 @@ struct ProductInfo { MaterialSource material; bool isValid() { - return (material.mat_type >= 0 || material.reagent); + return true;//due to mat_type being -1 = any } }; diff --git a/scripts/gui/advfort.lua b/scripts/gui/advfort.lua index b4744930e..2ed4b9502 100644 --- a/scripts/gui/advfort.lua +++ b/scripts/gui/advfort.lua @@ -488,8 +488,10 @@ function getItemsUncollected(job) end return ret end -function AddItem(tbl,item,recurse) - table.insert(tbl,item) +function AddItem(tbl,item,recurse,skip_add) + if not skip_add then + table.insert(tbl,item) + end if recurse then local subitems=dfhack.items.getContainedItems(item) if subitems~=nil then @@ -518,6 +520,8 @@ function EnumItems(args) for k,v in pairs(args.unit.inventory) do if args.inv[v.mode] then AddItem(ret,v.item,args.deep) + elseif args.deep then + AddItem(ret,v.item,args.deep,true) end end end From c5aa80873754beb9586401d8617533edaea4baab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 14 Mar 2013 05:07:30 +0100 Subject: [PATCH 17/20] Sync submodules --- library/xml | 2 +- plugins/stonesense | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/xml b/library/xml index c7e2c28fe..4d2afc3a0 160000 --- a/library/xml +++ b/library/xml @@ -1 +1 @@ -Subproject commit c7e2c28febd6dca06ff7e9951090982fbbee12b5 +Subproject commit 4d2afc3a0bcebdb17415dc2827b44fd35986a368 diff --git a/plugins/stonesense b/plugins/stonesense index 37f6e626b..bbbda97c1 160000 --- a/plugins/stonesense +++ b/plugins/stonesense @@ -1 +1 @@ -Subproject commit 37f6e626b054571b72535e2ac0ee3957e07432f1 +Subproject commit bbbda97c1cdd3d2456097eca799cfc7cf3410aaf From 27f23746bd8304df5cde91c1c5c8f913ab4e8cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 14 Mar 2013 06:43:38 +0100 Subject: [PATCH 18/20] Do not use autocompletion to second-guess the user. --- library/Core.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/Core.cpp b/library/Core.cpp index 9df7c1be4..2021a8bc5 100644 --- a/library/Core.cpp +++ b/library/Core.cpp @@ -373,7 +373,8 @@ static bool try_autocomplete(color_ostream &con, const std::string &first, std:: if (possible.size() == 1) { completed = possible[0]; - fprintf(stderr, "Autocompleted %s to %s\n", first.c_str(), completed.c_str()); + //fprintf(stderr, "Autocompleted %s to %s\n", , ); + con.printerr("%s is not recognized. Did you mean %s?\n", first.c_str(), completed.c_str()); return true; } @@ -382,7 +383,8 @@ static bool try_autocomplete(color_ostream &con, const std::string &first, std:: std::string out; for (size_t i = 0; i < possible.size(); i++) out += " " + possible[i]; - con.print("Possible completions:%s\n", out.c_str()); + con.printerr("%s is not recognized. Possible completions:%s\n", first.c_str(), out.c_str()); + return true; } return false; @@ -717,7 +719,7 @@ command_result Core::runCommand(color_ostream &con, const std::string &first, ve else if (plug_mgr->eval_ruby && fileExists(filename + ".rb")) res = runRubyScript(con, plug_mgr, first, parts); else if (try_autocomplete(con, first, completed)) - return runCommand(con, completed, parts); + return CR_NOT_IMPLEMENTED;// runCommand(con, completed, parts); else con.printerr("%s is not a recognized command.\n", first.c_str()); } From b487d78c740ccbbf6c7b7b9a613a69eef6cc29d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 14 Mar 2013 06:48:31 +0100 Subject: [PATCH 19/20] Update NEWS file --- NEWS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NEWS b/NEWS index 91eab0ec0..9c1cf6676 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ DFHack future + Is not yet known. + +DFHack v0.34.11-r3 + Internals: - support for displaying active keybindings properly. - support for reusable widgets in lua screen library. From e7c102646c36c78a9b983347158918da73e2a5ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 14 Mar 2013 06:59:31 +0100 Subject: [PATCH 20/20] Change cmakelists to r3 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d8813635..95b80f50c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ endif() # set up versioning. set(DF_VERSION "0.34.11") -SET(DFHACK_RELEASE "r2" CACHE STRING "Current release revision.") +SET(DFHACK_RELEASE "r3" CACHE STRING "Current release revision.") set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") add_definitions(-DDFHACK_VERSION="${DFHACK_VERSION}")