Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

Why is this undefined? What am I missing?

When I run this: on('change:attribute', function(obj) { log('-----'); log(obj); log(obj.name); }); I should be getting in the last log message, the name of the attribute changed, but I get this: "-----" {"name":"Endurance","current":"18","max":"25","_id":"-JLQBakpbPC9YIUXPWN3","_type":"attribute","_characterid":"-JLQ9M6znWs1Wh1R7Us_"} undefined What am I doing wrong here?
1398741523

Edited 1398741608
Try obj.get("name"). From <a href="https://wiki.roll20.net/API:Objects#Types_of_Objects" rel="nofollow">https://wiki.roll20.net/API:Objects#Types_of_Objects</a>
Derp! That works. So the object I'm given is not actually an object? Weird. Thanks!
But then when I get the previes 'current' value, .get() doesn't work, I have to use dot notation, because it's an INT for some reason. i r so confus.
1398755787
Lithl
Pro
Sheet Author
API Scripter
Roll20 objects are specialized, and you need to use the get function to get any of the attributes except id. However, the previous state of an object which is passed to the change event handler callback is not a Roll20 object, because it is no longer representing anything that's actually on the VTT.