Closed RealAntithesis closed 5 years ago
Code examples? Lua is mist to me, but I think the JC objects there are some wrapped anonymous structs containing only void*
. So maybe you just have to dump around what you find there and see which ones match.
Why do you need the Id?
the ___id field is a raw void* pointer to C++ JContainers object (jmap or jarray). It's not an ID
My use case was in sorting arrays of jobjects in lua (using table.sort with custom sorting functions), with the 'no sort' option being the order in which the objects were created (which the object id would be). It's not really critical though if the ID isn't exposed to lua easily. I can sort by other criteria.
Probably is better to use other criteria anyway. That ID, while descriptive, may jump around considering the user mods and code. It could be interesting for debugging purposes, however you can enable the verbose debug log and you will see the same void*
again. Let me know if you think there is more...
How would I get access to a JC object id in lua (i.e. the same number that is returned to papyrus as the object id number)? The .___id field for each object appears to be CData and not a number? Thanks.