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

ChatSetAttr custom API question

I'm using this custom API&nbsp; <a href="https://app.roll20.net/forum/post/5362387/slug%7D" rel="nofollow">https://app.roll20.net/forum/post/5362387/slug%7D</a> &nbsp;and I am running into a snag. I tested with the following,&nbsp; !setability --name M1 --W-1-Detect-Undead &nbsp;and have a character journal named M1, I get it to create the ability W-1-Detect-Undead with an empty abilitytext field, expected behavior. Getting that to work, I add the ability text to the string and get the following error code: You attempted to use a roll command looking for the value of a selected token, but no tokens are selected: So I select a token, Bob the Mage, run the following script command; !setability --name M1 --W-1-Detect-Undead#&amp;{template:2Espell}{{title= @{selected|token_name} casts Detect Undead}} {{splevel=Wizard level 1}} {{school=Divination, Necromancy}}{{components=V, S, M}}{{time=1round}}{{range=0 yards/feet}}{{duration=3 Turns}}{{aoe=[[({@{selected|3EquivalentWizardLevel}}*10+60)]] feet long x 10 feet wide }}{{save=None}}{{reference=PHB, page 133}}{{effects=Real text deleted to shorten the post.}} Referencing the above spell macro, with the token Bob the Mage selected, it replaces @selected_token_name with the actual tokens name, ie {{title=Bob the Mage casts Detect Undead}} and deletes the preceding &amp;{template:2Espell} I know it's custom, but if anyone can point out what I'm doing wrong, or if the script itself is the issue, I'd appreciate it. *edit* Renaming Bob the Mage to M1 gives the same results. *edit2* pasted correct code into the above, -- was the wrong string needed between undead and &amp;. Still not working, however. Thanks.
1586047116
Dumbhuman
Pro
Marketplace Creator
The game is trying to the run the commands in the ability you're trying to write so you need to use some character replacements in order to have them get written as abilities rather than executed immediately.&nbsp; The thread you linked to has a list of the replacements already included in setAbility and how to use them.&nbsp; As a relatively simple example, if the ability you want to write should ultimately look like this: /em rolls [[1d20+@{selected|dexterity_mod}]] for initiative! Then your setAbility command should look like this (I bolded the replacements): !setAbility {{ --sel --initiative#/em rolls \[ 1d20+ \at {selected|dexterity_mod} \] for initiative! }} So there's a little bit of user error on your part, but there is also a little bit of an issue with the script itself as written, because it needs a few more replacers defined to do what you want it to do.&nbsp; I added \beg as a replacer for {{ and \end as a replacer for }}, as well as \new as a replacer for \n and \til as a replacer for ~.&nbsp; You might not need the latter pair of replacers just yet, but you will need the first two to include templates in abilities, so you can add the bolded part of the code below to your script to get that functionality: replacers = [ ['[[', /\\\[/g], [']]', /\\\]/g], ['-', /\~/g], ['?', /\\q/g], ['@', /\\at/g], ['%', /\\p/g], ['&amp;', /\\amp/g], ['#', /\\h/g], ['{{', /\\beg/g], ['}}', /\\end/g], ["\n", /\\new/g], ['~', /\\til/g], ], Then you'll need to use those replacers when the abilities you want to write include any of those listed characters.&nbsp; Here's a more complicated example from my files.&nbsp; To write this ability which I call WS_Tools: /w "@{selected|character_name}" &amp;{template:default} {{name=Wild Shape Tools}} {{[AddImg](~WS|AddImg)=**[SaveToken](~WS|SaveToken)**}} {{[PrevImg](~WS|PrevImg)=**[NextImg](~WS|NextImg)**}} {{[AddStats](~WS|AddStats})=**[Help&amp;Setup](~WS|WildShapeHelp)**}} The setAbility command looks like this: !setAbility --sel --WS_Tools#/w "\at{selected|character_name}" \amp{template:default} \begname=Wild Shape Tools\end \beg[SetDruidName](\p{WS|SetDruidName})=**[SetVision](\p{WS|SetVision})**\end \beg[AddImg](\p{WS|AddImg})=**[SaveToken](\p{WS|SaveToken})**\end \beg[PrevImg](\p{WS|PrevImg})=**[NextImg](\p{WS|NextImg})**\end \beg[AddShapeStats](\p{WS|AddStats})=**[1stHelp](\p{WS|WildShapeHelp})**\end Now there's one more problem with the script, which is that HTML replacements don't actually work so if you have a drop down macro menu you'd like to use setAbility to write, you're unfortunately out of luck if that code would need to be written with HTML replacements.&nbsp; I've tried reaching out to Jakob and others about that problem , because it's not something I have the skills to solve, but so far I haven't had any luck getting that help.
Thanks, I tried some of those, but I obviously missed a step or three along the way, I'll jump back on this tomorrow morning when I'm fresh. Thank you for your comments.