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

findObj does not find repeating attribute but it is accesible in chat

1457099510

Edited 1457099963
var spellname = "repeating_preparations_-kc0muupybttztwjz1zj_preparations_name"; var x = findObjs({_type: 'attribute',_characterid:character.id,name: spellname},{caseInsensitive: true})[0]; log(x); /*returns undefined */ This returns undefined.&nbsp;However, @{Basis|repeating_preparations_-kc0muupybttztwjz1zj_preparations_name} Does work. What am I doing wrong? I already made sure that the character.id is correct log(character); {"name":"Basis","bio":"","gmnotes":"","_defaulttoken":1449143182195,"archived":false,"inplayerjournals":"","controlledby":"","_id":"-K19xgZ3xvBkGPm-gcnl","_type":"character","avatar":"<a href="https://s3.amazonaws.com/files.d20.io/images/7161616/2bf-VdRHlIPT2cOWT9RHQA/max.png?1421333900" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/7161616/2bf-VdRHlIPT2cOWT9RHQA/max.png?1421333900</a>"} I also made sure the attribute exists by logging all attributes var alla = findObjs({_type: 'attribute',characterid:character.id}); log(alla); /*other attributes*/{"name":"repeating_preparations_-KC0muUpYBTtZTWjz1ZJ_preparations_name","current":"Beeinflussen","max":"","_id":"-KC0muWQf9Yy2bhOLgCg","_type":"attribute","_characterid":"-K19xgZ3xvBkGPm-gcnl"}/*other attributes*/ Any ideas?
1457099705
The Aaron
Pro
API Scripter
Try: var spellname = "repeating_preparations_-kc0muupybttztwjz1zj_preparations_name"; var x = findObjs({_type: 'attribute',_characterid:character.id,name: spellname} ,{caseInsensitive: true} )[0]; log(x); IDs are case-insensitive (unfortunately) and are returned as lower case in getSectionIDs(). &nbsp;I'm assuming you are storing or reporting the ID from a sheet worker, and so getting the lower cased version.
1457099992

Edited 1457100561
I already did that, forgot to include it in the original post. Edit: Damn. Found it. The code above is valid but by making a short and simple example I also removed the error... The spellname variable simply was wrong. Edit2: Investigating the problem further.... this was EXACTLY the problem.
1457100219
The Aaron
Pro
API Scripter
Is it possible you have the wrong character id? &nbsp;Try: var spellname = "repeating_preparations_-kc0muupybttztwjz1zj_preparations_name"; var x = findObjs({_type: 'attribute',name: spellname},{caseInsensitive: true}); _.each(x,function(a){ log('Attr: '+a.get('name') +' character ID: '+a.get('characterid')); }); and see if it shows up?
1457100369
The Aaron
Pro
API Scripter
Also, try: var spellname = "repeating_preparations_-kc0muupybttztwjz1zj_preparations_name"; var x = findObjs({type: 'attribute',characterid:character.id,name: spellname},{caseInsensitive: true})[0]; log(x); The _ are optional and tell you that the attribute is read only. &nbsp;The only place I know of that they are required is in registering for an event like on('change:player:_online',...). &nbsp;Generally, I think it's better to leave them off where you can but YMMV.
Ok! Thanks. The caseInsensitive flag was exactly the problem. The example code above did work but my own function didn't because in the example above I did use it but in my own function I didn't.... grrrr :D And thank you for the additional informations!
1457100748
The Aaron
Pro
API Scripter
SWEET! &nbsp;No problem, glad we got it solved! &nbsp;=D