WIP: Fix ipairs() for enum attrs
Fixes #1860
(Note: I had put this together but evidently never finished it - need to investigate what is missing)
Edit: looks like I didn't make the test pass - that sounds familiar to me now.
this does address a legitimate issue. do you think you will be able to get this done within the release cycle?
Looking at this again. The Lua layer here is a bit complicated, so no promises.
I looked into this some. Turns out this is broken because I'm calling an existing ipairs() implementation that uses rawget():
https://github.com/DFHack/dfhack/blob/f290b1c804f6207afc786b3a3ca83e8cd87c44d9/library/LuaWrapper.cpp#L1343
but the attrs table is not actually populated, and instead uses the __index method to return values, which rawget() ignores:
https://github.com/DFHack/dfhack/blob/f290b1c804f6207afc786b3a3ca83e8cd87c44d9/library/LuaWrapper.cpp#L1534-L1536
so a solution would likely involve a custom ipairs() implementation or changing attrs so that it is populated for all valid enum items.
By the way, the reason for this implementation is probably because indexing attrs with an invalid index returns a table of the default attribute values. So I am leaning towards the former as a solution (a custom ipairs() instead of reusing wtype_ipairs()).