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 {
Does not export any native functions as of now. Instead, it calls lua code to perform the actual ordering of list items.
+This plugin exports some events to lua thus allowing to run lua functions +on DF world events.
+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.
+onItemContaminateWound(item,unit,wound,number1,number2)
+Is called when item tries to contaminate wound (e.g. stuck in).
+onProjItemCheckMovement(projectile)
+Is called when projectile moves.
+onProjItemCheckImpact(projectile,somebool)
+Is called when projectile hits something.
+onProjUnitCheckMovement(projectile)
+Is called when projectile moves.
+onProjUnitCheckImpact(projectile,somebool)
+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.
+postWorkshopFillSidebarMenu(workshop)
+Is called after calling (or not) native fillSidebarMenu(). Usefull for job button +tweaking (e.g. adding custom reactions)
+registerReaction(reaction_name,callback)
+Simplified way of using onReactionComplete; the callback is function (same params as event).
+removeNative(shop_name)
+Removes native choice list from the building.
+addReactionToShop(reaction_name,shop_name)
+Add a custom reaction to the building.
+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") ++
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.
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.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.
+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.
+These tools work by displaying dialogs or overlays in the game window, and are mostly implemented by lua scripts.
Implemented by the manipulator plugin. To activate, open the unit screen and press 'l'.
@@ -2901,7 +2917,7 @@ cursor onto that cell instead of toggling it. directly to the main dwarf mode screen.The search plugin adds search to the Stocks, Animals, Trading, Stockpile, Noble (assignment candidates), Military (position candidates), Burrows (unit list), Rooms, Announcements, Job List and Unit List screens.
@@ -2931,7 +2947,7 @@ only fat or tallow by forbidding fats, then searching for fat/tallow, and using Permit Fats again while the list is filtered.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.To use, bind to a key (the example config uses Alt-L) and activate in the 'k' mode.
-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.
To use, bind to a key (the example config uses Ctrl-M) and activate in the 'q' mode.
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.
Backed by the rename plugin, this script allows entering the desired name via a simple dialog in the game ui.
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.
@@ -3006,7 +3035,7 @@ either immediately or after opening the assign owner page. list, and allows unassigning them.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.Bind to a key (the example config uses Alt-P), and activate in the Hauling menu with the cursor over a Guide order.
@@ -3025,7 +3054,7 @@ the cursor over a Guide order. computes it when the order is executed for the first time.Bind to a key (the example config uses Alt-A), and activate with a job selected in a workshop in the 'q' mode.
@@ -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.Bind to a key (the example config uses Alt-W), and activate with a job selected in a workshop in the 'q' mode.
@@ -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).Bind to a key (the example config uses P), and activate when viewing a weapon rack in the 'q' mode.
@@ -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.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 -aThere are three ways to open this editor:
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.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.
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.
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.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.The steam-engine plugin detects custom workshops with STEAM_ENGINE in their token, and turns them into real steam engines.
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.
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.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%.
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.
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.
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