Add research-info script#1454
Conversation
|
I haven't moved forward to review this PR because the pre-commit check hasn't been resolved. Is the OP still interested in pursuing this PR? |
chdoc
left a comment
There was a problem hiding this comment.
Since this tool can be invoked on its own from the command-line, it needs documentation. Without having a good understanding what this tool is supposed to do, it is hard to give good feedback. Please have a look at the .rst files in the docs folder. And then, of course, this also needs a changelog entry like every other PR.
research-info.lua
Outdated
| goto continue | ||
| end | ||
|
|
||
| local historical_figure = researchInfo.getHistoricalFigure(unit.id) |
There was a problem hiding this comment.
| local historical_figure = researchInfo.getHistoricalFigure(unit.id) | |
| local historical_figure = df.historical_figure.find(unit.hist_figure_id) |
There are two observations here: units have a historical figure id field, and the idiomatic way to turn a numeric field into the corresponding structure is to use df.<structure_name>.find(id). This makes functions like your getHistoricalFigure basically useless. Please revisit your code and see whether this same pattern can be applied elsewhere.
| local unit = dfhack.units.getCitizens() | ||
| local selected_unit = dfhack.gui.getSelectedUnit() | ||
|
|
||
| if unit then |
There was a problem hiding this comment.
dfhack.units.getCitizens returns a table, and even the empty table (which this will never return in an active fort) is a "truthy" value in lua. So this condition can never evaluate to false.
internal/research-info/overlay.lua
Outdated
|
|
||
| local parts = {} | ||
| for part in str:gmatch("[^_]+") do | ||
| -- Первую букву делаем заглавной, остальные - строчными |
There was a problem hiding this comment.
If you add comments, please add them in English.
internal/research-info/info.lua
Outdated
| local goal_info = "" | ||
| for i = 0, 31 do | ||
| if goal[i] then | ||
| local global_flag_index = category * 32 + i -- wizards move | ||
| goal_info = string.format("%s", df.dfhack_knowledge_scholar_flag[global_flag_index]) or string.format("Unknown Flag: %s", i) | ||
| end | ||
| end | ||
| return goal_info |
There was a problem hiding this comment.
I don't understand what you're doing here. Please explain, so that we can see whether there is a better way.
There was a problem hiding this comment.
This func returns name of researchable topic
it takes data from https://github.com/DFHack/df-structures/blob/e4993ceef7907351fd2ac6f9bd3a9e5ff24699db/df.history_figure.xml#L308 and match value with name from https://github.com/DFHack/df-structures/blob/e4993ceef7907351fd2ac6f9bd3a9e5ff24699db/df.dfhack.xml#L221 there is a trouble in relations between these structures and these is doesnt match directrly. So, i use some magic.
The script to show more information about scholars activities, adapted for use with spectate-overlay or dfhack-console