第 1 卷第 1 章:1–9 年
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
--@ module = true
|
||||
-- 向当前界面发送按键。用法:dfhack-run "dfannals/act SELECT"
|
||||
-- 多个按键按顺序发送:dfhack-run "dfannals/act STANDARDSCROLL_DOWN SELECT"
|
||||
local gui = require('gui')
|
||||
|
||||
local args = {...}
|
||||
local scr = dfhack.gui.getCurViewscreen()
|
||||
local sent = {}
|
||||
|
||||
for _, name in ipairs(args) do
|
||||
local key = df.interface_key[name]
|
||||
if key then
|
||||
scr:feed_key(key)
|
||||
sent[#sent + 1] = name
|
||||
else
|
||||
sent[#sent + 1] = '?未知按键:' .. name
|
||||
end
|
||||
end
|
||||
|
||||
local f = io.open('dfannals-act.log', 'a')
|
||||
if f then
|
||||
f:write(string.format('%s\t%s\tfocus=%s\n', os.date('%H:%M:%S'),
|
||||
table.concat(sent, ' '), table.concat(dfhack.gui.getCurFocus(), '/')))
|
||||
f:close()
|
||||
end
|
||||
|
||||
print('sent: ' .. table.concat(sent, ' '))
|
||||
Reference in New Issue
Block a user