Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: DFHack script: unblockmeetings  (Read 44 times)


  • Bay Watcher
    • View Profile
DFHack script: unblockmeetings
« on: July 19, 2017, 07:03:03 am »

I think I've finally found a way to unblock stalled meetings (due to position holder replacements) without killing or driving away petitioners.

Code: [Select]
--  Work around for blocked meetings where a change of position holder causes the meeting activities to
--  stall. The somewhat heavy handed approch wipes all meeting activities from the participants and the
--  internal store and relies on DF's ability to rebuild the ones that should actually be there.
function unblockmeetings ()
  if not dfhack.isWorldLoaded () or not dfhack.isMapLoaded () then
    dfhack.printerr ("Error: This script requires an embark to be loaded.")

  dfhack.println ("Deleting " .. tostring ( .. " meeting requests")
  for i = - 1, 0, -1 do (i)
  dfhack.println ("Deleting " .. tostring ( .. " activities")
  for i = - 1, 0, -1 do
    for k = [i].unit_actor.specific_refs - 1, 0, -1 do
  if [i].unit_actor.specific_refs [k].type == 4 then  -- ACTIVITY
    dfhack.println ("Removing actor ACTIVITY from " .. dfhack.TranslateName ( [i], true)) [i].unit_actor.specific_refs:erase (k)

    for k = [i].unit_noble.specific_refs - 1, 0, -1 do
  if [i].unit_noble.specific_refs [k].type == 4 then  -- ACTIVITY
    dfhack.println ("Removing noble ACTIVITY from " .. dfhack.TranslateName ( [i], true)) [i].unit_noble.specific_refs:erase (k)
end (i)

unblockmeetings ()

The script has only been tested to a limited extent (I've had a petitioner on route to a meeting, swapped out the expedition leader, ran the script, verified that the visitor did petition, dismissed the petitioner, waited until another petitioner showed up on the petitioner screen). I haven't tried it with diplomats. It may possibly remove things that should be retained in the data structures (I didn't have anything extra in my test case), but I don't know if there are other things that can show up there.

The code is stored in a "text" file called unblockmeetings.lua in the <DF>\hacks\scripts folder and is invoked by typing "unblockmeetings" in the DFHack command console.