#1 something like this can be run from dfhack.init and listen for the embark screen
-- listen for embark
gui = require 'gui'
TIMER_ID = TIMER_ID
STARTDWARF_DONE = false
TRADEGOODS_DONE = false
function wait_for_embark_vs()
local vs = dfhack.gui.getCurViewscreen()
if df.viewscreen_choose_start_sitest:is_instance(vs) and not STARTDWARF_DONE then
-- startdwarf question?
print("at choose a site, time to ask about startdwarf")
STARTDWARF_DONE = true
elseif df.viewscreen_setupdwarfgamest:is_instance(vs) and not TRADEGOODS_DONE then
-- fix trade goods?
-- dfhack.run_script("filter_tradegoods", param1, param2, etc) -- possible way of calling a lua script to do the work
print("at choose embark profile, or configure embark, time to fix tradegoods?")
TRADEGOODS_DONE = true
end
dfhack.timeout(10,'frames',wait_for_embark_vs)
end
dfhack.onStateChange.embark = function(code)
if code == SC_WORLD_LOADED then
-- might be starting embark, starting adventure, starting legends, or loading a game
-- listen for embark
STARTDWARF_DONE = false
TRADEGOODS_DONE = false
TIMER_ID = dfhack.timeout(10,'frames',wait_for_embark_vs)
print("listening for embark")
elseif code == SC_MAP_LOADED then
-- game loaded, stop listening
dfhack.timeout_active(TIMER_ID, nil)
print("listen for embark canceled: map loaded")
elseif code == SC_WORLD_UNLOADED then
-- game unloaded, or embark canceled
dfhack.timeout_active(TIMER_ID, nil)
print("listen for embark canceled: world unloaded")
end
end
Listening for the embark profile select/modify screen might be useful for adjusting the embark points according to the number of extra dwarfs given by startdwarf (number of dwarfs over 7 might be easier to detect)
#2 a problem with the popup question for startdwarf is trying to run startdwarf (a ruby script) from a lua script, or translating startdwarf to lua. Also, if you get to the embark profile screen, it is too late to ask about startdwarf. Running startdwarf at the site selector seems to be fine.
#3 I think that filtering the trade goods probably ought to happen at the site selector also.
#5 I haven't noticed any improved response times for marking a unit for recovery/diagnosis as the dwarf in question usually has those flags already set to true. I have thought about trying to force the unit to have a resting state/job but haven't tested that yet.