第 1 卷第 1 章:1–9 年

This commit is contained in:
Chen Yi
2026-10-05 17:30:11 +08:00
parent c56394afdd
commit 3468433c9a
34 changed files with 2564 additions and 4 deletions
+56
View File
@@ -0,0 +1,56 @@
--@ module = true
-- 把当前界面状态写入 dfannals-probe.txt,供 WSL 侧读取。
-- 用法(在 WSL 里):"Dwarf Fortress.exe" 所在目录的 dfhack-run.exe dfannals/probe
local function safe_type(obj)
if not obj then return '?' end
local ok, t = pcall(function() return obj._type end)
if ok and t then return tostring(t) end
return '?'
end
local function viewstack()
local out = {}
local scr = dfhack.gui.getCurViewscreen()
local depth = 0
while scr and depth < 15 do
out[#out + 1] = string.format('[%d] %s', depth, safe_type(scr))
local ok, parent = pcall(function() return scr.parent end)
if not ok then break end
scr = parent
depth = depth + 1
end
return out
end
local function world_info()
local lines = {}
local ok, folder = pcall(dfhack.world.ReadWorldFolder)
lines[#lines + 1] = 'world_folder=' .. (ok and tostring(folder) or '?')
local ok2, year = pcall(dfhack.world.ReadCurrentYear)
lines[#lines + 1] = 'current_year=' .. (ok2 and tostring(year) or '?')
local ok3, legends = pcall(dfhack.world.isLegends)
lines[#lines + 1] = 'is_legends=' .. (ok3 and tostring(legends) or '?')
local ok4, fort = pcall(dfhack.world.isFortressMode)
lines[#lines + 1] = 'is_fortress=' .. (ok4 and tostring(fort) or '?')
local ok5, name = pcall(function() return dfhack.translation.translateName(df.global.world.world_data.name) end)
lines[#lines + 1] = 'world_name=' .. (ok5 and tostring(name) or '?')
return lines
end
function dump()
local lines = {}
local ok, focus = pcall(dfhack.gui.getCurFocus)
lines[#lines + 1] = 'focus=' .. ((ok and focus) and table.concat(focus, '/') or '?')
for _, l in ipairs(world_info()) do lines[#lines + 1] = l end
lines[#lines + 1] = 'viewstack:'
for _, l in ipairs(viewstack()) do lines[#lines + 1] = ' ' .. l end
local f = io.open('dfannals-probe.txt', 'w')
if f then
f:write(table.concat(lines, '\n') .. '\n')
f:close()
end
end
dump()