Hmmm, I'm probably a tard because I couldn't find more info on the script.sleep stuff in any of the docs, but it gave me a reason to learn more about timeouts which let me get questport working even if you're not in travel mode when you pull up the quest log and use it, had to fiddle with the timing some but the brief flicker when it is first used on foot is a small price to pay for zooping around the quest log and ending up where you're looking. Dunno why I thought I could just put myself into travel mode and do an hour wait, can't pull up the log that way, and incidentally yes I do know about the dfhack.screen and sendInput options, call it superstitious but the timing on those didn't work as well as just slapping in the simulated inputs, and when I tried to clean up the code a bit I lost the ability to use it without being in travel mode first so I had to roll it back and figure it out again.
local gui=require 'gui'
local qp=df.global.gview.view.child
local qmap=dfhack.gui.getCurViewscreen()
local qarm=df.global.world.armies.all
if df.viewscreen_adventure_logst:is_instance(qmap) then
local qx=qmap.cursor_x*48
local qy=qmap.cursor_y*48
local rx=qmap.player_region_x*48
local ry=qmap.player_region_y*48
df.global.ui_advmode.unk_1=qx
df.global.ui_advmode.unk_2=qy
if df.global.ui_advmode.menu==0 then
gui.simulateInput(qp.child,'LEAVESCREEN')
df.global.ui_advmode.menu=26
df.global.ui_advmode.travel_not_moved=true
gui.simulateInput(qp,'CURSOR_DOWN')
dfhack.timeout(15,'frames',function()
gui.simulateInput(qp,'A_TRAVEL_LOG') end)
-- print('Ready to teleport!') end)
elseif df.global.ui_advmode.menu==26 then
for k,v in ipairs(qarm) do
if v.flags[0] then
local my_arm=df.global.world.armies.all[k].pos
if (rx~=qx or ry~=qy) then do
my_arm.x=qx
my_arm.y=qy
qmap.player_region_x=qmap.cursor_x
qmap.player_region_y=qmap.cursor_y
end
end
end
end
end
end
Only bug I know of atm is that you can't use it if you've gotten the "you cannot travel til you leave this site" message, not sure which flag or whatnot has to be flipped to fix that, but assuming you don't try to travel out before using it, the script will zoop you out just fine.