|
80 | 80 |
|
81 | 81 | local log = getFileHandle()
|
82 | 82 |
|
| 83 | +local gps = df.global.gps |
| 84 | +local mi = df.global.game.main_interface |
| 85 | + |
83 | 86 | if item then
|
84 | 87 | -- Item processing
|
85 | 88 | local itemRawName = dfhack.items.getDescription(item, 0, true)
|
86 |
| - local itemRawDescription = df.global.game.main_interface.view_sheets.raw_description |
| 89 | + local itemRawDescription = mi.view_sheets.raw_description |
87 | 90 | log:write('### ' ..
|
88 | 91 | dfhack.df2utf(itemRawName) .. '\n\n#### Description: \n' .. reformat(dfhack.df2utf(itemRawDescription)) .. '\n')
|
89 | 92 | print('Exporting description of the ' .. itemRawName)
|
90 | 93 | elseif unit then
|
91 | 94 | -- Unit processing
|
92 | 95 | -- Simulate UI interactions to load data into memory (click through tabs). Note: Constant might change with DF updates/patches
|
| 96 | + local is_adv = dfhack.world.isAdventureMode() |
93 | 97 | local screen = dfhack.gui.getDFViewscreen()
|
94 | 98 | local windowSize = dfhack.screen.getWindowSize()
|
95 | 99 |
|
96 | 100 | -- Click "Personality"
|
97 |
| - local personalityWidthConstant = 48 |
98 |
| - local personalityHeightConstant = 11 |
| 101 | + local personalityWidthConstant = is_adv and 68 or 48 |
| 102 | + local personalityHeightConstant = is_adv and 13 or 11 |
99 | 103 |
|
100 |
| - df.global.gps.mouse_x = windowSize - personalityWidthConstant |
101 |
| - df.global.gps.mouse_y = personalityHeightConstant |
| 104 | + gps.mouse_x = windowSize - personalityWidthConstant |
| 105 | + gps.mouse_y = personalityHeightConstant |
102 | 106 |
|
103 | 107 | gui.simulateInput(screen, '_MOUSE_L')
|
104 | 108 |
|
105 | 109 | -- Click "Health"
|
106 | 110 | local healthWidthConstant = 74
|
107 |
| - local healthHeightConstant = 13 |
| 111 | + local healthHeightConstant = is_adv and 15 or 13 |
108 | 112 |
|
109 |
| - df.global.gps.mouse_x = windowSize - healthWidthConstant |
110 |
| - df.global.gps.mouse_y = healthHeightConstant |
| 113 | + gps.mouse_x = windowSize - healthWidthConstant |
| 114 | + gps.mouse_y = healthHeightConstant |
111 | 115 |
|
112 | 116 | gui.simulateInput(screen, '_MOUSE_L')
|
113 | 117 |
|
114 | 118 | -- Click "Health/Description"
|
115 |
| - local healthDescriptionWidthConstant = 51 |
116 |
| - local healthDescriptionHeightConstant = 15 |
| 119 | + local healthDescriptionWidthConstant = is_adv and 74 or 51 |
| 120 | + local healthDescriptionHeightConstant = is_adv and 17 or 15 |
117 | 121 |
|
118 |
| - df.global.gps.mouse_x = windowSize - healthDescriptionWidthConstant |
119 |
| - df.global.gps.mouse_y = healthDescriptionHeightConstant |
| 122 | + gps.mouse_x = windowSize - healthDescriptionWidthConstant |
| 123 | + gps.mouse_y = healthDescriptionHeightConstant |
120 | 124 |
|
121 | 125 | gui.simulateInput(screen, '_MOUSE_L')
|
122 | 126 |
|
123 |
| - local unit_description_raw = df.global.game.main_interface.view_sheets.unit_health_raw_str[0].value |
124 |
| - local unit_personality_raw = df.global.game.main_interface.view_sheets.personality_raw_str |
| 127 | + local unit_description_raw = #mi.view_sheets.unit_health_raw_str > 0 and mi.view_sheets.unit_health_raw_str[0].value or '' |
| 128 | + local unit_personality_raw = mi.view_sheets.personality_raw_str |
125 | 129 |
|
126 | 130 | log:write('### ' ..
|
127 | 131 | dfhack.df2utf(getNameRaceAgeProf(unit)) ..
|
128 |
| - '\n\n#### Description: \n' .. reformat(dfhack.df2utf(unit_description_raw)) .. '\n\n#### Personality: \n') |
129 |
| - for _, unit_personality in ipairs(unit_personality_raw) do |
130 |
| - log:write(reformat(dfhack.df2utf(unit_personality.value)) .. '\n') |
| 132 | + '\n\n#### Description: \n' .. reformat(dfhack.df2utf(unit_description_raw)) .. '\n') |
| 133 | + if #unit_personality_raw > 0 then |
| 134 | + log:write('\n#### Personality: \n') |
| 135 | + for _, unit_personality in ipairs(unit_personality_raw) do |
| 136 | + log:write(reformat(dfhack.df2utf(unit_personality.value)) .. '\n') |
| 137 | + end |
131 | 138 | end
|
132 | 139 | print('Exporting Health/Description & Personality/Traits data for: \n' .. dfhack.df2console(getNameRaceAgeProf(unit)))
|
133 | 140 | end
|
| 141 | + |
134 | 142 | closeFileHandle(log)
|
0 commit comments