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

Help using ChatSetAttr to store roll result

Once again it seems I'm in over my head! Can anyone help me work out why the following sheet button won't work? It's not setting the attribute, nor is the PowerCards call generating anything. The goal is to display and save a dice roll, then plug the result into an equation to produce the desired system result. Any help is most welcome! Here's the code: <button type='roll' style="width:15px; height:15px" value='!setattr {{ --charid @{character_id} --silent --savedroll1|[[2d10!!cf0cs0]] }} !power {{ --name|@{character_name}: Dexterity --leftsub|@{tdexterity} AP --rightsub|TN ?{Target Number|11} --Roll|[[@{savedroll1}]] --Result|[[@{tdexterity}-?{Target Number}+(@{savedroll1}-11+floor(@{tdexterity}/6))]].}}' name='roll_dexterity'></button>
1564188048
The Aaron
Roll20 Production Team
API Scripter
You definitely need to make sure there is a carriage return before the !power.  Maybe put 
 there? ...]] }} 
!power {{ --name... When you try this, how does it fail?  Is it creating/setting an attribute?  Is there any output?  Any errors in the Javascript Console, or API Console?
At present (even with your suggestion, unfortunately) it just isn't writing the attribute at all. I get the "attribute not found" error from the !power call. (Thanks for the quick reply!)
1564191537
The Aaron
Roll20 Production Team
API Scripter
So, if you check the character's attributes list, 'savedroll1' isn't there?  One thing of note, all @{} references, ?{} commands, and inline [[ ]] rolls are resolved before anything is sent to the API, so you'll start with: !setattr {{ --charid @{character_id} --silent --savedroll1|[[2d10!!cf0cs0]] }} !power {{ --name|@{character_name}: Dexterity --leftsub|@{tdexterity} AP --rightsub|TN ?{Target Number|11} --Roll|[[@{savedroll1}]] --Result|[[@{tdexterity}-?{Target Number}+(@{savedroll1}-11+floor(@{tdexterity}/6))]].}} Which becomes this when the @{} and ?{} are resolved: !setattr {{ --charid -K12ads4513412 --silent --savedroll1|[[2d10!!cf0cs0]] }} !power {{ --name|Bob the Slayer: Dexterity --leftsub|18 AP --rightsub|TN 11 --Roll|[[]] --Result|[[18-15+(-11+floor(18/6))]].}} and then this when the [[ ]] are resolved (and replaced with placeholders for the API to reference) !setattr {{ --charid -K12ads4513412 --silent --savedroll1|$[[0]]}} !power {{ --name|Bob the Slayer: Dexterity --leftsub|18 AP --rightsub|TN 11 --Roll|$[[1]] --Result|$[[2]].}} which is what the API finally sees.  That means you're trying to resolve @{savedroll1} before the API even runs, resulting in an "attribute not found" the first time you run it, and an outdated number on each subsequent run (assuming it actually creates the savedroll1 attribute).
The "savderoll1" attribute doesn't seem to be storing at all, no. Any idea if any version of this might be workable, or should I just abandon it?
1564198241

Edited 1564198301
The Aaron
Roll20 Production Team
API Scripter
For this to work, you'd have to have the attribute stored by a single command to the API that also displays it, possibly by calling another API command.&nbsp; Something of that nature is technically possible, but would require some API script writing.&nbsp; Easiest would be if you could convince the current maintainer of PowerCards to add a syntax to either store a value to an attribute, or force a lookup for an attribute on the API side... which reminds me, I actually wrote something for exactly that purpose for PowerCards about 4-5 years ago... Here's that script, in it's most recent form:&nbsp; <a href="https://app.roll20.net/forum/post/6559169/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/6559169/slug%7D</a> You'd change your script to be something like this: !setattr {{ --charid @{character_id} --silent --savedroll1|[[2d10!!cf0cs0]] }} !pcpp {{ --name|@{character_name}: Dexterity --leftsub|@{tdexterity} AP --rightsub|TN ?{Target Number|11} --Roll|[[ @#{savedroll1} ]] --Result|[[@{tdexterity}-?{Target Number}+(@{savedroll1}-11+floor(@{tdexterity}/6))]].}} I don't know if that will fix the problem, but it's worth a try maybe... First you need to track down why the attribute isn't being created.&nbsp; Try creating an ability on the character with just the first line and make sure that works.
I'll put that on my list of things to try! Though, I keep hearing that PowerCards can do this, too? I tried that, though, and got an error message. If anyone has any idea what I'm doing wrong, here, please just let me know! &lt;button type='roll' style="width:15px; height:15px" value='!power {{ --name|@{character_name}: Physical Action --leftsub|AV @{tdexterity}/EV @{tstrength} --rightsub|OV ?{OV|11}/RV ?{RV|11} --TN|[[@{tdexterity}-?{OV}+11]] --Roll|[[ [$Roll] 2d10!!cf0cs0]] --Result|[[@{tstrength}-?{RV}+([^Roll]-11+floor((@{tstrength})/6))]] RAPs}}' name='roll_physical'&gt;&lt;/button&gt; Currently, this outputs: PowerCards: "Could not determine result type of: [{\"type\":\"M\",\"expr\":\"3+0-11+(\"},{\"type\":\"L\",\"text\":\"^Roll\"},{\"type\":\"M\",\"expr\":\"-11+floor((3+0)/6))\"}]"