These are chat archives for highfidelity/hifi

2nd
Feb 2018
jetbond
@jetbond
Feb 02 2018 04:36
I've got an array of entity ids. I want to sort them by userData values. Any idea?
Midnight
@MidnightRift
Feb 02 2018 04:37
what kind of user data values
jetbond
@jetbond
Feb 02 2018 04:37
integers
Midnight
@MidnightRift
Feb 02 2018 04:42
you probably want osmehting like this
yourKeys.sort(function(a, b) { return Entities.getEntityData(a) -Entities.getEntityData(b) ; }); its not compleate code but you should get the idea
jetbond
@jetbond
Feb 02 2018 04:45
wait is getEntityData a thing or, like you said, it's just incomplete code
Midnight
@MidnightRift
Feb 02 2018 04:47
Entities.getEntityProperties(entityID,['userdata']).userData should be what gets you the userdata
jetbond
@jetbond
Feb 02 2018 04:48
Right that's what I'm using
well actually im trying to do this
Entities.getEntityProperties(a, "userData").userData.moduleData.pageID
I'm getting pageID, which is in moduleData.
This doesnt seem to be working
Midnight
@MidnightRift
Feb 02 2018 04:50
It should look simlar to this then yourKeys.sort(function(a, b) { return Entities.getEntityProperties(a,['userdata']).userData.moduleData.pageID - Entities.getEntityProperties(b,['userdata']).userData.moduleData.pageID; });
jetbond
@jetbond
Feb 02 2018 04:51
looks very similar yes
'Entities.getEntityProperties(a, ["userData"]).userData.moduleData' [undefined] is not an object.
That would usually mean that that userData does not exist right?
Midnight
@MidnightRift
Feb 02 2018 04:52
no it exists. Need to parse the user data
JSON.pasre(Entities.getEntityProperties(a,['userdata']).userData).moduleData.pageID I think it shoould look like that. For a moment i forgot its returned as astring
jetbond
@jetbond
Feb 02 2018 04:54
Yep
Works great. Thanks
Or maybe not? It seemed like it worked 90% of the time
Midnight
@MidnightRift
Feb 02 2018 05:02
Debuging time XD. check to see if theres a value present in the entity.
jetbond
@jetbond
Feb 02 2018 05:05
oh nevermind. Printing it out shows that it is indeed working 100% of the time
Must be a problem with some other code that i need to look into. Thanks!
Yep all works great
Midnight
@MidnightRift
Feb 02 2018 05:10
Glad it works :)
jetbond
@jetbond
Feb 02 2018 05:10
Thanks for the help