DFHack / dfhack

Memory hacking library for Dwarf Fortress and a set of tools that use it
Other
1.87k stars 472 forks source link

exportlegends fails with "must be run from the main legends view" #2936

Closed hrantzsch closed 1 year ago

hrantzsch commented 1 year ago

exportlegends custom (or any other subcommand) exports nothing and only creates an empty folder on DFHack 50.07-alpha1 with Steam DF v50.07. It prints

Writing all files in: legends-region4-[...]
exportlegends must be run from the main legends view

I'm pretty sure the main legends view is where I am. Opening a category like "Historical figures" doesn't help either.

I saw that https://github.com/DFHack/scripts/commit/ec85750330cffd381d82d5ad300d81be86996762 updated the script saying it seems to work for v50, so I'm wondering if I'm just holding it wrong. FWIW, running open-legends claims "legends screen already displayed".

lethosor commented 1 year ago

Could you run :lua ~dfhack.gui.getCurFocus() with the legends screen open and paste its output?

open-legends is intended for when you don't have the legends screen opened, so that makes sense.

hrantzsch commented 1 year ago

Sure:

> :lua ~dfhack.gui.getCurFocus()

table: 0000000008E1A5B0
1                        = legends
drewbuschhorn commented 1 year ago

Dunno if it helps at all, but I'm seeing the same behavior: (folder "SteamLibrary\steamapps\common\Dwarf Fortress\legends-region2-00119-12-11" created, no files)

[DFHack]# exportlegends all
Writing all files in: legends-region2-00119-12-11
exportlegends must be run from the main legends view
[DFHack]# :lua ~dfhack.gui.getCurFocus()
table: 00000171D697AE30
1                        = legends
drewbuschhorn commented 1 year ago

Hmm, fwiw, maybe the screenfinder is behaving differently in premium? Seems like this is the currently unhappy line https://github.com/DFHack/scripts/blob/master/exportlegends.lua#L1187 but I've never compiled dfhack.

@lethosor Lemme know if you think you won't be able to get to it anytime soon and I'll educate myself / see if I can't make a working PR for your consideration.

[DFHack]# :lua ~dfhack.gui.getCurFocus() == "legends"
false
[DFHack]# :lua ~dfhack.gui.getCurFocus()[0] == "legends"
false
[DFHack]# :lua ~dfhack.gui.getCurFocus()[1] == "legends"
true

no idea what the previous behavior was.

ITKozak commented 1 year ago

So by trying to change https://github.com/DFHack/scripts/blob/master/exportlegends.lua#L1187 localy inside hack folder as noted by @drewbuschhorn I got next results:

exportlegends info ```lua Invoking: exportlegends info ...e\Steam\steamapps\common\Dwarf Fortress\hack\lua\gui.lua:35: Invalid keycode: LEGENDS_EXPORT_MAP stack traceback: [C]: in function 'error' ...e\Steam\steamapps\common\Dwarf Fortress\hack\lua\gui.lua:35: in local 'push_key' ...e\Steam\steamapps\common\Dwarf Fortress\hack\lua\gui.lua:55: in function 'gui.simulateInput' ...ps\common\Dwarf Fortress//hack/scripts/exportlegends.lua:1071: in global 'export_legends_info' ...ps\common\Dwarf Fortress//hack/scripts/exportlegends.lua:1194: in local 'script_code' ...team\steamapps\common\Dwarf Fortress\hack\lua\dfhack.lua:810: in function 'dfhack.run_script_with_env' (...tail calls...) ```
exportlegends maps ```lua Invoking: exportlegends maps ...team\steamapps\common\Dwarf Fortress\hack\lua\dfhack.lua:533: attempt to index a nil value (local 'scr_type') stack traceback: ...team\steamapps\common\Dwarf Fortress\hack\lua\dfhack.lua:533: in field 'getViewscreenByType' ...ps\common\Dwarf Fortress//hack/scripts/exportlegends.lua:1098: in function <...ps\common\Dwarf Fortress//hack/scripts/exportlegends.lua:1094> [C]: in function 'dfhack.call_with_finalizer' ...team\steamapps\common\Dwarf Fortress\hack\lua\dfhack.lua:72: in function 'dfhack.with_finalize' ...ps\common\Dwarf Fortress//hack/scripts/exportlegends.lua:1084: in function <...ps\common\Dwarf Fortress//hack/scripts/exportlegends.lua:1082> ```
exportlegends sites ```lua Invoking: exportlegends sites exportlegends: this command can only be used in Legends mode ```
exportlegends all ```lua Invoking: exportlegends all ...e\Steam\steamapps\common\Dwarf Fortress\hack\lua\gui.lua:35: Invalid keycode: LEGENDS_EXPORT_MAP stack traceback: [C]: in function 'error' ...e\Steam\steamapps\common\Dwarf Fortress\hack\lua\gui.lua:35: in local 'push_key' ...e\Steam\steamapps\common\Dwarf Fortress\hack\lua\gui.lua:55: in function 'gui.simulateInput' ...ps\common\Dwarf Fortress//hack/scripts/exportlegends.lua:1071: in global 'export_legends_info' ...ps\common\Dwarf Fortress//hack/scripts/exportlegends.lua:1190: in local 'script_code' ...team\steamapps\common\Dwarf Fortress\hack\lua\dfhack.lua:810: in function 'dfhack.run_script_with_env' (...tail calls...) ```

Also after exportlegends info dfhack's ingame gui starting to behave unstable (some menus wont open, or crush).

I don't have any lua background but still will continue to poke around trying to do something.

ITKozak commented 1 year ago
Invoking: exportlegends maps
...team\steamapps\common\Dwarf Fortress\hack\lua\dfhack.lua:533: attempt to index a nil value (local 'scr_type')
stack traceback:

Okay so I tried to find what can I do about index nil value (because it was kinda same error from the beginning) and changed ~/DF/hack/lua/dfhack.lua#L533 to if not scr == nil and scr_type:is_instance(scr) then by adding not scr == nil. My reasoning was the fact that by looks of function dfhack iterate over attributes scr and the first attribute is a child = nil

Invoking: :lua ~dfhack.gui.getCurViewscreen()
<viewscreen_legendsst: 000000000763AE50>
child                    = nil
parent                   = <viewscreen: 000000014131A928>
breakdown_level          = 0
option_key_pressed       = 0
unhid_sum                = 1738
init_stage               = -1
init_cur_era             = 1
init_cur_era_num         = 0
init_cur_era_denom       = 0
init_sub_stage           = 0
histfigs                 = <vector<int32_t>[859]: 000000000763AE88>
sites                    = <vector<int32_t>[99]: 000000000763AEA0>
artifacts                = <vector<int32_t>[0]: 000000000763AEB8>
...more input

In my mind this check should allow us to get some expected result. And by doing so and retyping exportlegends maps i got

[DFHack]# exportlegends maps
Writing all files in: legends-region3-00005-07-19
    Done exporting.
Could not find legends screen
Exported files can be found in the "legends-region3-00005-07-19" folder.

And now folder consists of errorlog.txt and empty legends dir. Hooray?

errorlog.txt ```errorlog.txt Failed to find vanilla text header. Failed to find vanilla languages header. Failed to find vanilla descriptors header. Failed to find vanilla materials header. Failed to find vanilla environment header. Failed to find vanilla plants header. Failed to find vanilla items header. Failed to find vanilla buildings header. Failed to find vanilla bodies header. Failed to find vanilla creatures header. Failed to find vanilla entities header. Failed to find vanilla reactions header. Failed to find vanilla interactions header. Failed to find vanilla descriptors graphics header. Failed to find vanilla plants graphics header. Failed to find vanilla items graphics header. Failed to find vanilla buildings graphics header. Failed to find vanilla creatures graphics header. Failed to find vanilla world map header. Failed to find vanilla interface header. Failed to find vanilla music header. Failed to find vanilla text header. Failed to find vanilla languages header. Failed to find vanilla descriptors header. Failed to find vanilla materials header. Failed to find vanilla environment header. Failed to find vanilla plants header. Failed to find vanilla items header. Failed to find vanilla buildings header. Failed to find vanilla bodies header. Failed to find vanilla creatures header. Failed to find vanilla entities header. Failed to find vanilla reactions header. Failed to find vanilla interactions header. Failed to find vanilla descriptors graphics header. Failed to find vanilla plants graphics header. Failed to find vanilla items graphics header. Failed to find vanilla buildings graphics header. Failed to find vanilla creatures graphics header. Failed to find vanilla world map header. Failed to find vanilla interface header. Failed to find vanilla music header. ```
ITKozak commented 1 year ago

After some more code tracing and manual commands I decided to try to manually export XML from Legends mode inside the game. None of legacy keybinds (x,d,p) doesn't work for me. It may be due to me using Linux but also wiki for Legends mode and XML dumps have a unknown tags indicating that those commands may currently be non functional.

Anyway will continue to pocking around.

myk002 commented 1 year ago

You won't be able to trigger vanilla legends export until it's back in the vanilla game. It might come with 50.08, but no guarantees.

Until then, the most useful thing to get working is the export of the extra info that DFHack itself is responsible for writing.

If you're feeling ambitious, the next thing exportlegends needs is a status GUI that shows live progress.