Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: New script: knowledge-progress.lua, for seeing how much knowledge a unit has  (Read 1019 times)

Tachytaenius

  • Bay Watcher
    • View Profile

Copy the script to one of your df(hack) installation's scripts folders (likely just hack/scripts/, but separating the standard library from scripts you install is recommended! Check dfhack-config/script-paths.txt).

Code: (knowledge-progress.lua) [Select]
local knowledge = df.historical_figure.find(dfhack.gui.getSelectedUnit().hist_figure_id).info.known_info.knowledge

local keys = {
"philosophy", "philosophy2",
"math", "math2",
"history",
"astronomy",
"naturalist",
"chemistry",
"geography",
"medicine", "medicine2", "medicine3",
"engineering", "engineering2"
}

local knownThings, thingsToKnow = 0, 0

for _, key in ipairs(keys) do
for knowledge, known in pairs(knowledge[key]) do
if not tonumber(knowledge) then -- skip unnamed bits
thingsToKnow = thingsToKnow + 1
if known then
knownThings = knownThings + 1
end
end
end
end

print("Knowledge: " .. knownThings .. "/" .. thingsToKnow)

Example output for my (no-aging syndrome) hermit: "Knowledge: 81/312"
Logged