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

Unable to use character attributes in Roll20 API sendChat() rolls

Hi, I'm trying to work with the Roll20 API scripts (specifically, I am trying to write some). &nbsp;The Roll20 API documentation explicitly sets out under the sendChat &nbsp;documentation (&nbsp; <a href="https://wiki.roll20.net/API:Chat" rel="nofollow">https://wiki.roll20.net/API:Chat</a> ) that you are able to pass in character attributes, using the format: /roll @{CharacterName|AttributeName} This does not work. &nbsp;Attempting to utilize this results in a NodeJS SyntaxError that looks similar to this: /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ SyntaxError: Expected "[" or [ |\t] but "6" found. This is blocking a lot of things that I am trying to accomplish -- for example, AutoCalc fields on character sheets are not populated with values. Roll20's documentation says to use this functionality (via "/roll @{CharacterName|AttributeName}") to generate the "correct" value for those fields, but since it is broken there doesn't appear to be any reasonable way to fetch the values of one of these AutoCalc fields from the API. I'd appreciate it if this got some love/attention, it is really frustrating to be so close &nbsp;to being able to do interesting things with the API, just to have it all fall apart at the last step because I'm unable to touch character attributes in /roll commands. Thanks! Remi
1442730707

Edited 1442761118
To be clear, the sendChat() die rolling functionality itself does &nbsp;work, generally -- i.e. trivial examples like "/roll 1d20" work. &nbsp;It is only when character attributes get involved that the API begins to throw arrows. Please see&nbsp; my post in the API forum (right at the bottom) for more examples of rolls that fail.
1442750560
The Aaron
Roll20 Production Team
API Scripter
Can you post the output of sending just the attribute to chat via sendChat? sendChat(' would roll @{CharacterName|AttributeName}'); I suspect this is actually a re-presentment of this regression:&nbsp; <a href="https://app.roll20.net/forum/post/2217884/api-regr" rel="nofollow">https://app.roll20.net/forum/post/2217884/api-regr</a>...
1442760509

Edited 1442761015
Hi Aaron, When I pass a message to sendChat that has an @-expression that does not equate to a "real" character, it works: // Code: var module = 'Custodian'; var roll_string = 'TEST: would roll @{CharacterName|AttributeName}'; log('Testing: ' + roll_string); sendChat(module, roll_string); // API Log Output: "Testing: TEST: would roll @{CharacterName|AttributeName}" "ERROR: Unable to find character CharacterName in chat command." // Chat Output: Custodian:&nbsp;TEST: would roll CharacterName|AttributeName When I pass it with a valid character, however, it dies with exactly the same error: // Code: var module = 'Custodian'; var roll_string = 'TEST: would roll @{Nil|level}'; log('Testing: ' + roll_string); sendChat(module, roll_string); // API Log Output: "Testing: TEST: would roll @{Nil|level}" /home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1 orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v ^ SyntaxError: Expected "[" or [ |\t] but "0" found. // Chat Output: NONE Thanks! Remi
1442767422
The Aaron
Roll20 Production Team
API Scripter
What do you get if you just put that @{Nil|level} in the chat of the game?
If I just "/roll @{Nil|level}" in the chat, I get a correct/proper response: Thanks, Remi
1442771650
The Aaron
Roll20 Production Team
API Scripter
The Aaron said: What do you get if you just put that @{Nil|level} in the chat of the game? I mean without the /roll, just seeing what it expands to&nbsp;
Hi Aaron, Ah -- OK. &nbsp;Without "/roll" (i.e. just "@{Nil|level}"), it expands to the same as after the "rolling" text in the above screenshot, which is:&nbsp;(1 + 0 + 0 + 0 + 0). Thanks, Remi
1442780250
vÍnce
Pro
Sheet Author
Very curious for a solution on this since the PF sheet is riddled with auto-calc attributes. &nbsp;This has been a major limitation for api scripts that manipulate sheet attributes.