ryobg / JContainers

JSON-based data structures for Papyrus - the TESV Skyrim SE scripting language
MIT License
107 stars 23 forks source link

Get JC object id in lua? #64

Closed RealAntithesis closed 5 years ago

RealAntithesis commented 5 years ago

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.

ryobg commented 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.

SilverIce commented 5 years ago

Why do you need the Id?

SilverIce commented 5 years ago

the ___id field is a raw void* pointer to C++ JContainers object (jmap or jarray). It's not an ID

RealAntithesis commented 5 years ago

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.

ryobg commented 5 years ago

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...