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

[Script] ScriptCards - My "Spiritual Successor" to PowerCards

1639614072
David M.
Pro
API Scripter
To build on Kurt's comment regarding reentrant settings, here's a cheesy example of what I was talking about with hardcoding the selected ID within the button itself. This example uses token-mod because I'm more familiar with it that ChatSetAttr, but the same idea should be applicable. It assigns the parameters (including token_id) to the button itself to change some Aura settings for a given token. In this case, it uses  _ids [&tokID]  syntax. While the ids assigned to the buttons are variable based on the selected token when the parent chat menu is created, they are hardcoded within the button for later activation.  !script {{ --#reentrant|@{selected|character_id} ​ ​ --#title|Hardcoded ID in Button Example ​ --&tokID|@{selected|token_id} --#leftsub|@{selected|token_name} --+Aura Radius|[rbutton]OFF::AURA_OFF;_ignore-selected _set aura1_radius| _ids [&tokID][/rbutton][rbutton]5ft Aura::AURA_5ft;_ignore-selected _set aura1_radius|5ft _ids [&tokID][/rbutton][rbutton]10ft Aura::AURA_10ft;_ignore-selected _set aura1_radius|10ft _ids [&tokID][/rbutton] ​ --+Aura Color|[rbutton]Blue::SET_BLUE;_ignore-selected _set aura1_color|#0000ff _ids [&tokID][/rbutton][rbutton]Red::SET_RED;_ignore-selected _set aura1_color|#ff0000 _ids [&tokID][/rbutton] --X| ​--:AURA_OFF| --#title|I selected "OFF" ​ --@token-mod|[&reentryval] ​ --+Aura turned OFF| ​ --X| ​ --:AURA_5ft| --#title|5ft Aura, yo! ​ --@token-mod|[&reentryval] ​ --+Aura set to 5ft| ​ --X| ​ --:AURA_10ft| --#title|10ft pole ​ --@token-mod|[&reentryval] ​ --+Aura set to 10ft| ​ --X| ​ --:SET_BLUE| --#title|Sad Aura ​ --@token-mod|[&reentryval] ​ --+Aura color set to Blue| ​ --X| ​ --:SET_RED| --#title|Angry Aura ​ --@token-mod|[&reentryval] ​ --+Aura color set to Red| ​ --X| }} Of course, I realize that this token-mod example explicitly ignores selected tokens on button click, but I think it should still work for you with CSA and avoid possibilities of any weird selection timing problems.
1639736573

Edited 1639844255
timmaugh said: And... just so I understand... is this the order of things (without regard to concurrency, just the order of how tasks are managed in scripts): A player runs the ScriptCards macro ScriptCards builds a menu of buttons That player clicks a button from the menu, which runs the ChatSetAttr call ? Because in that case I wonder when ScriptCards is stripping off the deferral character. In fact, if Valerio has ZeroFrame installed, s/he could drop a {&log} in the original ScriptCard. The "Loop 1" entry should show how command line was rendered after Roll20 parsing. We could see if the @{select|character_id} is resolving correctly. Also, you could drop a deferred log command in the ChatSetAttr line: {^&log} So that we get a separate log for what THAT script will see. Yes, that's correct ! That's the order of things. This is the simplest "repeating" macro that shows this issue. I'll post this one so we can focus on the actual problem. The other macros are a bit longer and deal with items, abilities, etc...but they all show the same issue (Pathfinder 1 Community Sheet) !script {{ --#sourceToken|@{selected|token_id} --#reentrant|@{selected|token_id} --#title|[*S:character_name] --#oddRowBackground|#000000 --#evenRowBackground|#17202a --#oddRowFontColor|#FFFFFF --#evenRowFontColor|#FFFFFF --#titleCardBackground|#000000 --#leftsub|Potenziamenti --#rightsub|Modifica --#buttonFontSize|11px --#buttonBackground|#000000 --#bodyFontFace|Sans --#whisper|self --Rfirst|[*S:character_id];repeating_buff2 --=n|0 --:Loop| --?"[*R:name]" -eq NoRepeatingAttributeLoaded|Done --=Value|[*R:enable_toggle] --+[rbutton][*R:name]::MOD_BUFF;[$n.Raw][/rbutton]|[r][$Value][/r] --=n|[$n] + 1 --Rnext| -->Loop| --:Done| --X| --:MOD_BUFF| --#whisper| --=R|[&reentryval] --Rfirst|[*S:character_id];repeating_buff2 --=n1|0 --:Loop1| --?"[*R:name]" -eq NoRepeatingAttributeLoaded|Done1 --?[$n1] -eq [$R]|Done1 --=n1|[$n1] + 1 --Rnext| -->Loop1| --:Done1| --=Mod|1 - [*R:enable_toggle] --@setattr|_charid [*S:character_id] _silent _repeating_buff2_$[&reentryval]_enable_toggle|[$Mod] {^& select @{selected|token_id} } {^&log} --?[$Mod] -eq 0|DISABLED --+[*R:name]|Enabled --^End| --:DISABLED| --+[*R:name]|Disabled --:End| --X| }} As you can see, it creates a button for each buff in the sheet and allows you to toggle that buff. A note about the second loop in the reentrant part, I have to "find the buff again" as I can't really use anything like @{selected|repeating_buff2_$[$anyvariablehere]_enable_toggle}, as I asked in this same thread a while ago. But I think that's beyond the point. This works correctly when no concurrency between players occurs. timmaugh said: Also, can you confirm that the second user only has to click on their token to make this work? The API doesn't know that you clicked on a token until you run a script command. Just because someone clicked on a token shouldn't change anything about an API message's set of selected tokens. There is no interaction with the API (or changing a state that the API cares about) without running an API command. So is Player B doing more than selecting their token? Yes. The only thing is that Player B could have used the same macro (with no issues) before Player A. That's why I mentioned the fact that the API gets buggy after a "couple of times that this sequence happens" David M. said: What about this: Can you just have the original scriptcard (the one that creates the buttons) hardcode the character_id into each button when they are created (using a string variable like [&charID]), rather than the button content relying on @{selected...}? Hi David, thank you for your answer. I've read your code, it's actually a brilliant solution, and it might work I'm gonna try this one too! timmaugh said: Because in that case I wonder when ScriptCards is stripping off the deferral character. In fact, if Valerio has ZeroFrame installed, s/he could drop a {&log} in the original ScriptCard. The "Loop 1" entry should show how command line was rendered after Roll20 parsing. We could see if the @{select|character_id} is resolving correctly. Also, you could drop a deferred log command in the ChatSetAttr line: {^&log} So that we get a separate log for what THAT script will see. Valerio can you do that and post your logged results for both (they will appear in chat)? I've installed ZeroFrame as you suggested and this is the result for the macro I've posted, (toggling the first buff) I'm going to try David's and Kurt's solutions and I'll report here the results! Thank you all guys, you're awesome!
1640263888

Edited 1640263991
WE DID IT GUYS! It works! David's "hardcode" solution + Kurt's smarter use of reentrant (not only dynamic but with the actual name of the specific macro to add something different beteen them) actually work! Now even if they run the most complex ScriptCard with reentrant and InformationRequest (--i) not in order bethween players, they work as expected!!!! I'm SO GLAD that I do not have to leave this path to deal with "repeating" attributes! Just to be clear for other users, all I had to do is to: change this --#reentrant|@{selected|token_id} into this (Kurt's trick) --#reentrant|MACRO RELATED NAME @{selected|token_id} So that the SAME character has nothing to do with other macros called by himself; this wasn't the actual problem in the first place but I run some tests about this one, and it HELPS A LOT in this scenario Player calls MACRO-A An Information Request pops up (--i) He ignores the request and calls MACRO B He answers the previous Information Request But with his little trick this mess is avoided. then i added (David's hardcode trick) --&chID|@{selected|character_id} as soon as the ScriptCard starts. From there on, I've used this variable in any ScriptCall inside Scriptcards i.e. I changed this line --@setattr|_charid [*S:character_id] _silent _repeating_buff2_$[&reentryval]_enable_toggle|[$Mod] into this --@setattr|_charid [&chID] _silent _repeating_buff2_$[&reentryval]_enable_toggle|[$Mod] I hope this helps. THANK YOU ALL!
@Kurt - Were you able to incorporate that {Round,2} command in the most recent update?
I think I may have mentioned an issue before but it has expanded a bit and thought I would revisit it.  I created an Initiative macro which has been having two random seeming events: 1.  A repeating infinite decimal (that is generated for at most one player) by the tie-breaker, all other players being a 2 decimal number; 2.  Not all players (a minority such as 2 out of 6) are listed in the tracker when macro initiated. (I eliminated failure to click token first as issue.) The script (minus graphic commands and header/footer):     --&AdvRoll|?{Advantage or Disadvantage?|Normal,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1}     --=Init|[&AdvRoll] + @{selected|dexterity_mod} + @{selected|initiative_bonus} [TIE]     --+|[b] @{selected|character_name} rolled a [$Init]! [/b]     --~|turnorder;addtoken;@{selected|token_id};[$Init]
1640355745
Kurt J.
Pro
API Scripter
Michael C. said: @Kurt - Were you able to incorporate that {Round,2} command in the most recent update? I just pushed 1.4.11 to the GitHub with the updated {ROUND} modifier. It now supports an optional precision, so {ROUND:2} for 2 places, etc. Supports up to 6 decimal places.
@Kurt - Awesome, thanks!
1640577719

Edited 1640579479
Hi, I am new to Roll20, and am trying to write a ScriptCards macro for D&amp;D 4E to automate Area attacks with multiple targets, using the Magic Missile script as a starting pattern. When I try to resolve the target defence using the *TokenID syntax it seems to be returning the formula instead of the calculated value. So the Roll variable for "will" defence contains 0 and the String variable contains something resembling the formula. &nbsp; --:Attack|(Target Token ID) &nbsp; &nbsp; --+Token ID|[%1%] &nbsp; &nbsp; --=TokenDef|[*[%1%]:will] &nbsp; &nbsp; --+Token Def|[$TokenDef] &nbsp; &nbsp; --&amp;TokenDefTxt|[*[%1%]:will] &nbsp; &nbsp; --+Token Def Text|[&amp;TokenDefTxt] &nbsp; --&lt;| Area Test Token ID &nbsp;-Mmg-8Wh2-lpjV-cnlwM Token Def &nbsp;<span class="userscript-userscript-showtip userscript-tipsy" title="Roll: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 Result: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 " style="min-width: 1.75em ; font-family: &quot;undefined&quot; ; text-align: center ; display: inline-block ; font-weight: bold ; height: 1em ; margin-top: -1px ; margin-bottom: 1px ; padding: 0px 2px ; border: 1px solid rgb( 135 , 133 , 10 ) ; border-radius: 3px ; background-color: rgb( 255 , 254 , 162 )">0 Token Def Text &nbsp;will-ten+will-ability+will-armor+will-class+will-feat+will-enh+will-misc+will-misc2 Token ID &nbsp;-MKZdhO5duzkWfYxTrLO Token Def &nbsp;<span class="userscript-userscript-showtip userscript-tipsy" title="Roll: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 Result: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 " style="min-width: 1.75em ; font-family: &quot;undefined&quot; ; text-align: center ; display: inline-block ; font-weight: bold ; height: 1em ; margin-top: -1px ; margin-bottom: 1px ; padding: 0px 2px ; border: 1px solid rgb( 135 , 133 , 10 ) ; border-radius: 3px ; background-color: rgb( 255 , 254 , 162 )">0 Token Def Text &nbsp;will-ten+will-ability+will-armor+will-class+will-feat+will-enh+will-misc+will-misc2 I can see that several hundred lines are generated in the API Console for each target: "ERROR: Did not specify an attribute name when referencing attribute using @{will - ten}" "Error &nbsp; &nbsp; at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:172:1), &lt;anonymous&gt;:575:11) &nbsp; &nbsp; at String.replace (&lt;anonymous&gt;) &nbsp; &nbsp; at Object.d20.textchat.doChatInput (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:172:1), &lt;anonymous&gt;:549:29) &nbsp; &nbsp; at sendChat (/home/node/d20-api-server/api.js:1894:16) &nbsp; &nbsp; at apiscript.js:17876:9 &nbsp; &nbsp; at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:168:1), &lt;anonymous&gt;:65:16) &nbsp; &nbsp; at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:168:1), &lt;anonymous&gt;:70:8) &nbsp; &nbsp; at /home/node/d20-api-server/api.js:1736:12 &nbsp; &nbsp; at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 &nbsp; &nbsp; at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147)" and so on for each component of the will formula. [[ @{selected|will} ]] Works correctly when used in chat or macros. Any advice would be appreciated - I couldn't find anything in the forum like this. Edit to add: Game is using the DnD4e character sheet.
1640651510
@Nic S. I'm not certain, but my initial thought is not to use the token_id but the character_id.
1640653307
I'm trying to set something up where the players choose an Ability as a roll query.&nbsp; I want to be able to take that ability and add that as a portion of an attribute.&nbsp;&nbsp; Example:&nbsp; If the player chooses Agility from the query it can be put into @{selected| agility } or @{selected| agility bonus} Is this even possible?
Colin C. said: @Nic S. I'm not certain, but my initial thought is not to use the token_id but the character_id. Thanks, Colin, but I have tried that and I got the same result. I expect it would already be going to the character sheet as the token wouldn't contain that sort of information. &nbsp; --:Attack|(Target Token ID) &nbsp; &nbsp; --+Token ID|[%1%] &nbsp; &nbsp; --&amp;CharID|[*[%1%]:t-represents] &nbsp; &nbsp; --+Char ID|[&amp;CharID] &nbsp; &nbsp; --=TokenDef|[*[&amp;CharID]:will] &nbsp; &nbsp; --+Token Def|[$TokenDef] &nbsp; &nbsp; --&amp;TokenDefTxt|[*[&amp;CharID]:will] &nbsp; &nbsp; --+Token Def Text|[&amp;TokenDefTxt] &nbsp; --&lt;| Area Test Token ID &nbsp;-Mmg-8Wh2-lpjV-cnlwM Char ID &nbsp;-Mm2dkrxowAeQqfSa1Ca Token Def &nbsp;<span class="userscript-showtip userscript-tipsy" title="Roll: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 Result: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 " style="box-sizing: content-box; min-width: 1.75em; font-family: undefined; text-align: center; display: inline-block; font-weight: bold; height: 1em; margin-top: -1px; margin-bottom: 1px; padding: 0px 2px; border: 1px solid rgb(135, 133, 10); border-radius: 3px; background-color: rgb(255, 254, 162);">0 Token Def Text &nbsp;will-ten+will-ability+will-armor+will-class+will-feat+will-enh+will-misc+will-misc2 Token ID &nbsp;-MKZdhO5duzkWfYxTrLO Char ID &nbsp;-MKJiU3n33rUpffBoFYC Token Def &nbsp;<span class="userscript-showtip userscript-tipsy" title="Roll: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 Result: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 " style="box-sizing: content-box; min-width: 1.75em; font-family: undefined; text-align: center; display: inline-block; font-weight: bold; height: 1em; margin-top: -1px; margin-bottom: 1px; padding: 0px 2px; border: 1px solid rgb(135, 133, 10); border-radius: 3px; background-color: rgb(255, 254, 162);">0 Token Def Text &nbsp;will-ten+will-ability+will-armor+will-class+will-feat+will-enh+will-misc+will-misc2 (:id gives the same result as :t-represents)
1640694384
Kurt J.
Pro
API Scripter
Nic S. said: Colin C. said: @Nic S. I'm not certain, but my initial thought is not to use the token_id but the character_id. Thanks, Colin, but I have tried that and I got the same result. I expect it would already be going to the character sheet as the token wouldn't contain that sort of information. &nbsp; --:Attack|(Target Token ID) &nbsp; &nbsp; --+Token ID|[%1%] &nbsp; &nbsp; --&amp;CharID|[*[%1%]:t-represents] &nbsp; &nbsp; --+Char ID|[&amp;CharID] &nbsp; &nbsp; --=TokenDef|[*[&amp;CharID]:will] &nbsp; &nbsp; --+Token Def|[$TokenDef] &nbsp; &nbsp; --&amp;TokenDefTxt|[*[&amp;CharID]:will] &nbsp; &nbsp; --+Token Def Text|[&amp;TokenDefTxt] &nbsp; --&lt;| Area Test Token ID &nbsp;-Mmg-8Wh2-lpjV-cnlwM Char ID &nbsp;-Mm2dkrxowAeQqfSa1Ca Token Def &nbsp;<span class="userscript-userscript-showtip userscript-tipsy" title="Roll: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 Result: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 " style="min-width: 1.75em ; font-family: &quot;undefined&quot; ; text-align: center ; display: inline-block ; font-weight: bold ; height: 1em ; margin-top: -1px ; margin-bottom: 1px ; padding: 0px 2px ; border: 1px solid rgb( 135 , 133 , 10 ) ; border-radius: 3px ; background-color: rgb( 255 , 254 , 162 )">0 Token Def Text &nbsp;will-ten+will-ability+will-armor+will-class+will-feat+will-enh+will-misc+will-misc2 Token ID &nbsp;-MKZdhO5duzkWfYxTrLO Char ID &nbsp;-MKJiU3n33rUpffBoFYC Token Def &nbsp;<span class="userscript-userscript-showtip userscript-tipsy" title="Roll: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 Result: will - ten + will - ability + will - armor + will - class + will - feat + will - enh + will - misc + will - misc2 " style="min-width: 1.75em ; font-family: &quot;undefined&quot; ; text-align: center ; display: inline-block ; font-weight: bold ; height: 1em ; margin-top: -1px ; margin-bottom: 1px ; padding: 0px 2px ; border: 1px solid rgb( 135 , 133 , 10 ) ; border-radius: 3px ; background-color: rgb( 255 , 254 , 162 )">0 Token Def Text &nbsp;will-ten+will-ability+will-armor+will-class+will-feat+will-enh+will-misc+will-misc2 (:id gives the same result as :t-represents) I took a look at the 4E sheet, and because it uses floor() inside it, it won't be possible for ScriptCards to process it directly. (Note that it is technically possible by using the "eval" statement in Java, but given that a malicious person could erase the entire game by creating a macro that contains bad code that might be processed by eval, I don't/won't include support for that in the script). That said, after looking at what the saving throw attributes are actually doing, it was fairly simple to come up with a subrouting to calculate a save/defense based on the individual pieces: !script {{ &nbsp; --&gt;CalcSave|@{selected|token_id};will;TokenWill &nbsp; --&gt;CalcSave|@{selected|token_id};fort;TokenFort &nbsp; --&gt;CalcSave|@{selected|token_id};ref;TokenRef &nbsp; --+Token Will|[$TokenWill] &nbsp; --+Token Fort|[$TokenFort] &nbsp; --+Token Ref|[$TokenRef] &nbsp; --X| &nbsp; --:CalcSave|token_id;savetype;returnval - savetype can be "will", "fort", or "ref" &nbsp; --=[%3%]|[*[%1%]:level] \ 2 + 10 + [*[%1%]:[%2%]-ability] + [*[%1%]:[%2%]-armor] + [*[%1%]:[%2%]-class] + [*[%1%]:[%2%]-feat] + [*[%1%]:[%2%]-enh] + [*[%1%]:[%2%]-misc] + [*[%1%]:[%2%]-misc2] &nbsp; --&lt;| }} If you include the "CalcSave" subroutine in your script and then call it as indicated above you should get back a variable with the equivalent calculation.
1640748255
You need to use Fetch for this. Something like: !?{What ability?|Agility|Other options...} @\(selected|?{What ability?} @\(selected|?{What ability?}bonus) Brien V. said: I'm trying to set something up where the players choose an Ability as a roll query.&nbsp; I want to be able to take that ability and add that as a portion of an attribute.&nbsp;&nbsp; Example:&nbsp; If the player chooses Agility from the query it can be put into @{selected| agility } or @{selected| agility bonus} Is this even possible?
1641169052

Edited 1641169238
Kurt J.
Pro
API Scripter
ScriptCards 1.5.0 - Object Modification A new development release of ScriptCards is now available on the GitHub repo . Object modification support is now available in ScriptCards. As of 1.5.0, you can use the --! command to modify object properties in the game. This may help reduce the reliance on the --@ command to run other API commands to modify token/character values. The biggest benefit of this is that the changes happen as the script is processing, so the new values are available right away.&nbsp; The format of the command is: &nbsp; --!&lt;objectType&gt;:&lt;objectId&gt;|setting:value|setting:value|setting:value... objectType can be one of "t" for token, "c" for character, or "a" for character attribute objectId can be a token id or a character id (or "S"/"T" for the Source/Target token/char defined with --#sourcetoken and --#targettoken) setting&nbsp; and value pairs can be chained in a single statement separated by | to impact more than one property/attribute with a single line Values can be prefixed with += or -= to add/subtract from the current value (no bounds checking is done). Using [*X] notation, the updated values can be read immediately. Using += or -= on non-numeric data will simply result in a string append. For "a" types, setting names can be prefixed with a ! to create the attribute if it doesn't exist (by default, it will not be created), and postfixed with ^ to set the max value instead of the current value. Note that there are VERY few attributes associated with a character object, and there are likely few cases where you would want to set anything on the character object, but it is still possible. Examples : Set the value of bar1_value for the selected token to 5: &nbsp; --!t:@{selected|token_id}|bar1_value:5 Add 1 to the bar3_value for the selected token: &nbsp; --!t:@{selected|token_id}|bar3_value:+=1 Set bar2_value to 5 and bar2_max to 10 for the selecte token &nbsp; --!t:@{selected|token_id}|bar2_value:5|bar2_max:10 For the character the selected token represents, set "dndstying" attribute on, set "size" to enormous, and set "attitude" to epic. The attitude attribute will be created if it doesn't exist on the character already. The same is not true for dndstying and size: &nbsp; --!a:@{selected|token_id}|dndstyling:on|size:enormous|!attitude:epic Adds 50 to the npc_xp attribute for the character represented by the selected token, displaying the value before and after the update: &nbsp; !script {{ &nbsp; &nbsp; --+XP|[*@{selected|token_id}:npc_xp] &nbsp; &nbsp; --!a:@{selected|token_id}|npc_xp:+=50 &nbsp; &nbsp; --+XP|[*@{selected|token_id}:npc_xp] &nbsp; }} Note that asynchronous read/update fields (bio, notes, gmnotes) are not currently supported.
1641216042
David M.
Pro
API Scripter
Nice, Kurt! I was actually going to do something nearly identical for the Spawn script, with similar syntax in mind. I'll try to keep the user syntax as similar as possible to minimize confusion.&nbsp;
1641599954
Kurt J.
Pro
API Scripter
ScriptCards 1.5.1 - Wild Die support ScriptCards 1.5.1 has been uploaded to the repo . This adds a new die formula for "Wild Dice" rolls for games like d6 system. Optionally, can include "S" to drop an initial 1 on the wild die and/or a "X" to drop the highest die rolled if the Wild die is a 1. For example: 4d6W - Roll 3d6 and 1d6 as a wild die. If the Wild Die acts as an exploding die, rerolling and increasing the total for every 6 rolled. 4d6WS - As above, but if the Wild Die's first roll is a 1, it will be treated as a 0. 4d6WX - As above, but if the Wild Die's first roll is a 1, it will replace the highest die among the 3d6. 4D6WSX - As above, but if the Wild Die's first roll is a 1, it will be treated as a 0 and the highest die among the 3d6 will be eliminated.
1641868631
Has anyone identified a way for ScriptCards to output a roll template? For example, I want to use the &amp;{template:atkdmg} construction, feeding in the values obtained from the card to populate the fields.
1641874211
timmaugh
Pro
API Scripter
Colin C. &nbsp;said: Has anyone identified a way for ScriptCards to output a roll template? For example, I want to use the &amp;{template:atkdmg} construction, feeding in the values obtained from the card to populate the fields. What if you send it as an outbound script call: &nbsp; --@tmp|{^&amp;template:default}@^(Kokoro.Braces)name=Volcano Man@^(Kokoro|Braces.max) @^(Kokoro|Braces)Part=Works?@^(Kokoro|Braces.max)({^&amp;simple}) Several things going on, there. 1. I have an attribute on the "Kokoro" character (could be any macro mule) named "Braces". That attribute has a base value of {{ and a max value of: }} I use the base/max value as necessary to set the boundaries of the outbound-template part without interfering with the ScriptCard macro. 2. The actual script handle doesn't matter (I use "tmp"). It doesn't even have to be a real script because the line will never reach it. 3. {&amp;template:default} might look like a backward formation (the ampersand and brace are backward from Roll20 standard syntax). This is actually a ZeroFrame construction -- one way to designate that you want a template. 4. The simple tag is wrapped in parentheses so that it doesn't interact with any double braces enclosing the ScriptCards macro. It still works like this. 5. The various constructions are deferred until ScriptCards issues this outbound command. Currently, the deferral replacement operations are limited to some particular character strings common to meta constructions (perhaps a few others). If Kurt expanded them to include standard roll20 constructions, I *think* this would work with deferring just a standard attribute call: @^{Kokoro|Braces}. Until then, we'll have to use a deferred Fetch construction. REQUIRED SCRIPTS: ScriptCards, ZeroFrame, Fetch
1641952722
This is great, thank you.&nbsp; I do have a couple questions or requests.&nbsp;&nbsp; In the D6 games, the wild die determines your crit.&nbsp; When you use this function, though, you get green or red for any die that rolls min or max.&nbsp; Is it possible to only get the red or green when the wild die rolls min or max?&nbsp; That would allow the players and GM to know, without rolling over the text, what just happened.&nbsp;&nbsp; Kurt J. said: ScriptCards 1.5.1 - Wild Die support ScriptCards 1.5.1 has been uploaded to the repo . This adds a new die formula for "Wild Dice" rolls for games like d6 system. Optionally, can include "S" to drop an initial 1 on the wild die and/or a "X" to drop the highest die rolled if the Wild die is a 1. For example: 4d6W - Roll 3d6 and 1d6 as a wild die. If the Wild Die acts as an exploding die, rerolling and increasing the total for every 6 rolled. 4d6WS - As above, but if the Wild Die's first roll is a 1, it will be treated as a 0. 4d6WX - As above, but if the Wild Die's first roll is a 1, it will replace the highest die among the 3d6. 4D6WSX - As above, but if the Wild Die's first roll is a 1, it will be treated as a 0 and the highest die among the 3d6 will be eliminated.
1641965236
timmaugh said: Colin C. &nbsp;said: Has anyone identified a way for ScriptCards to output a roll template? For example, I want to use the &amp;{template:atkdmg} construction, feeding in the values obtained from the card to populate the fields. What if you send it as an outbound script call: &nbsp; --@tmp|{^&amp;template:default}@^(Kokoro.Braces)name=Volcano Man@^(Kokoro|Braces.max) @^(Kokoro|Braces)Part=Works?@^(Kokoro|Braces.max)({^&amp;simple}) Several things going on, there. 1. I have an attribute on the "Kokoro" character (could be any macro mule) named "Braces". That attribute has a base value of {{ and a max value of: }} I use the base/max value as necessary to set the boundaries of the outbound-template part without interfering with the ScriptCard macro. This breaks. For some reason, the deferred&nbsp; fetch &nbsp;call fails, but only within &nbsp;the outbound call. --@as|[*[%1%]:character_name] {^&amp;template:atkdmg} @(Macros|Braces)mod=[*[%1%]:spell_attack_bonus]@(Macros|Braces.max) @(Macros|Braces)rname=Spiritual Weapon@(Macros|Braces.max) @(Macros|Braces)r1=[$Roll1]@(Macros|Braces.max) @(Macros|Braces)r2=[$Roll2]@(Macros|Braces.max) @(Macros|Braces)always=1@(Macros|Braces.max) @(Macros|Braces)attack=1@(Macros|Braces.max) @(Macros|Braces)damage=1@(Macros|Braces.max) @(Macros|Braces)dmg1flag=1@(Macros|Braces.max) @(Macros|Braces)dmg1=[$DamRoll]@(Macros|Braces.max) @(Macros|Braces)dmg1type=Force@(Macros|Braces.max) @(Macros|Braces)crit1=[$CritDam]@(Macros|Braces.max) @(Macros|Braces)hldmg=[$HLDam]@(Macros|Braces.max) @(Macros|Braces)charname=[*[%1%]:character_name]@(Macros|Braces.max) @(Macros|Braces)spelllevel=[&amp;Slot]@(Macros|Braces.max) @(Macros|Braces)desc=[Show Spell Description](`<a href="https://app.roll20.net/editor/~[%1%]%7C[*R&gt;spelldesc_link])@(Macros|Braces.max" rel="nofollow">https://app.roll20.net/editor/~[%1%]%7C[*R&gt;spelldesc_link])@(Macros|Braces.max</a>) This works though! It does not &nbsp;work with the simple &nbsp;tag, though.&nbsp; ([%1%] is the character_id of the PC using the spell.) Note: Requires emas script I'm running into a different problem: desc=[Show Spell Description](`<a href="https://app.roll20.net/editor/~[&amp;reentryval]%7C[*R&gt;spelldesc_link]" rel="nofollow">https://app.roll20.net/editor/~[&amp;reentryval]%7C[*R&gt;spelldesc_link]</a>) The link doesn't work! I'm trying to replicate what the 5E OGL sheet does with Spiritual Weapon, but adding in some other stuff. When you cast the spell using the character sheet (either from the spells tab or the core tab under the attacks section) you get this: <span class="inlinerollresult showtip tipsy-n-right" title=" Rolling 1d20cs>20 + 4[WIS] + 5[PROF] = ( 18 )+4+5" style="box-sizing: content-box; font-size: 1.2em; line-height: 12px; background-color: transparent; border: 0px; padding: 0px; cursor: help;">27 60 feet Spiritual Weapon&nbsp; (+9) Thodin Show Spell Description <span class="inlinerollresult showtip tipsy-n-right" original-title=" Rolling 1d8 + 4[WIS] = ( 3 )+4" style="box-sizing: content-box; font-size: 1.2em; line-height: 12px; background-color: transparent; border: 0px; padding: 0px; cursor: help;">7 Force My version yields this, which is pretty close: 17 &nbsp; &nbsp; 12 60 feet Spiritual Weapon&nbsp; (+9 ) Thodin Show Spell Description 8 Force Except: The spot where the link appears is different and the link doesn't work.
1642036275
Can I trigger and API AND a macro using a button?
1642038697
Should be able to, yes. I think something like this should work: [button]Button Label::!&amp;#13;!apicommandstuff&amp;#13;macrostuff[/button] Brien V. said: Can I trigger and API AND a macro using a button?
1642077447
Kurt J.
Pro
API Scripter
ScriptCards 1.5.3 Two new updates on the Repo : Updated the Wild Die support to color-code based on the Wild Die. Red=1 rolled on first die, Green=Ace rolled on first die, yellow for any other value on the wild die. Thanks&nbsp;Brien V. for clarifying how the Wild Die is normally used. I haven't played a d6 game in decades :) (From 1.5.2) : Added the --a statement, which will play a jukebox track (specified by the Content of the statement). No external APIs are needed for this statement to function. Example: &nbsp; &nbsp; --a|SwordHitSound Tracks need to exist in your Roll20 jukebox, and the name of the track is case senstivie. If the track does not exist in your game, a warning message will be sent to the API console log.
1642085074
Crossposting: <a href="https://app.roll20.net/forum/permalink/10602031/" rel="nofollow">https://app.roll20.net/forum/permalink/10602031/</a>
1642180978
I've been flailing and trying everything I can to get scriptcards to work with Smart AoE and I'm having a bad time with it. David M. put up an example on the SmartAoE forum , but I've copied it and I can't get it to work in my game. I've changed all the 5e specific terms to just numbers so I can get a solid base and tinker with it, but still nothing. Here's the dream I've been grappling with for about 3 days: Alchemist throws bomb. Attack roll vs target token. Variable output for Crit, Hit, Miss, and Critical Miss.Damage applied based on attack result. Splash damage in the form of a SmartAoE token. Apply conditions via SmartAoE token and Combat Master. I've got the script for most of that except how to mesh with other macros. I haven't gotten to CM yet, but that part doesn't seem too terrible. SmartAoE is destroying me though. Here is the working scrpit for throwing the bomb at a target: !scriptcard&nbsp; {{ &nbsp; --#title|Lesser Alchemist's Fire &nbsp; --#leftsub|Ranged Bomb Attack &nbsp; --#sourceToken|@{selected|token_id} &nbsp; --#targetToken|@{target|token_id} &nbsp; --#emoteText|@{selected|token_name} hurls a bomb at @{target|token_name} &nbsp; &nbsp; --=TargetAC|[*T:t-bar2_value] &nbsp; --?[$TargetAC.Total] -gt 0|DoneWithAC &nbsp; --=TargetAC|[*T:t-bar2_value] &nbsp; --:DoneWithAC| &nbsp; &nbsp; --=AttackRoll|1d20 + @{Alchemist|bomb_attack} &nbsp; --+Attack|@{selected|token_name} rolls [$AttackRoll] vs AC [$TargetAC]. &nbsp; --?[$AttackRoll.Base] -eq 20|Crit &nbsp; --?[$AttackRoll] -ge (10 + [$TargetAC])|Crit &nbsp; --?[$AttackRoll.Base] -eq 1|Critical Miss &nbsp; --?[$AttackRoll] -le [$TargetAC]-10|Critical Miss &nbsp; --?[$AttackRoll] -ge [$TargetAC] |Hit &nbsp; --+Miss|The attack missed; the target and all creatures within 5 feet take only @{selected|intelligence_modifier} damage. &nbsp; --^Final| &nbsp; --:Critical Miss| &nbsp; --+Critical Miss!|No damage is dealt. &nbsp; --^Final| &nbsp; --:Hit| &nbsp; --vtoken|@{target|token_id} burst-fire &nbsp; --=Bomb_Damage|1d8 &nbsp; --=Splash_Damage|@{selected|intelligence_modifier} &nbsp; --=Persistant_Damage|2 &nbsp; --+Hit!|The attack hit @{target|token_name} for [$Bomb_Damage] direct fire damage. Creatures within 5' are hit with [$Splash_Damage] fire damage. &nbsp; --@alter|_target|@{target|token_id} _bar|1 _amount|-[$Bomb_Damage]-[$Splash_Damage] &nbsp; --^Final| &nbsp; --:Crit| &nbsp; --vtoken|@{target|token_id} burst-fire &nbsp; --=Bomb_Damage|2d8 &nbsp; --=Splash_Damage|@{selected|intelligence_modifier} &nbsp; --=Persistant_Damage|4 &nbsp; --+Critical Hit!|The attack hit @{target|token_name} for [$Bomb_Damage] fire damage. Creatures within 5' are hit with [$Splash_Damage] fire damage. &nbsp; --@alter|_target|@{target|token_id} _bar|1 _amount|-[$Bomb_Damage]-[$Splash_Damage] &nbsp; --:Final| }} I don't know how to call the SmartAoE macro. Experimenting with --@ has given me nothing promising.
1642183474
David M.
Pro
API Scripter
Zack, when I mentioned looking into a scriptcard solution, I meant instead &nbsp;of using SmartAoE for your application. So, something like a scriptcard macro that uses an information request to build a target string for the correct number of targets in range, then loops through attacking all the targets, applying damage via tokenmod. SmartAoE&nbsp; is just not currently well suited for a multiattacking application.&nbsp;
1642183898
David M. said: Zack, when I mentioned looking into a scriptcard solution, I meant instead &nbsp;of using SmartAoE for your application. So, something like a scriptcard macro that uses an information request to build a target string for the correct number of targets in range, then loops through attacking all the targets, applying damage via tokenmod. SmartAoE&nbsp; is just not currently well suited for a multiattacking application.&nbsp; Sorry to be a bother. But this time it is! I'm using ScriptCards to actually do the attack, and SmartAoE to do the splash damage. The splash damage is just a flat 4 fire damage to creatures in a 5-foot radius. I set the DC to 5 and the save to 0 so they always fail. (I'll come back to finding if they're resistant or immune to fire damage later). Unless ScriptCards can make a token that is movable by players that can target and apply damage. Which I'm sure it can, but that feels like several more hours of study and practice to make. But I have the SmartAoE macro working and the ScriptCards macro working, just not together. I have a button on the scriptcard menu that calls the smartaoe macro, but that's pretty clunky and the token doing the attack has to be selected twice. I would rather one button do everything.&nbsp; If I can just get the script to call the macro on a miss, hit, or critical hit then I'm golden.
1642184061
timmaugh
Pro
API Scripter
Colin C. said: This breaks. For some reason, the deferred&nbsp; fetch &nbsp;call fails, but only within &nbsp;the outbound call. --@as|[*[%1%]:character_name] {^&amp;template:atkdmg} @(Macros|Braces)mod=[*[%1%]:spell_attack_bonus]@(Macros|Braces.max) @(Macros|Braces)rname=Spiritual Weapon@(Macros|Braces.max) @(Macros|Braces)r1=[$Roll1]@(Macros|Braces.max) @(Macros|Braces)r2=[$Roll2]@(Macros|Braces.max) @(Macros|Braces)always=1@(Macros|Braces.max) @(Macros|Braces)attack=1@(Macros|Braces.max) @(Macros|Braces)damage=1@(Macros|Braces.max) @(Macros|Braces)dmg1flag=1@(Macros|Braces.max) @(Macros|Braces)dmg1=[$DamRoll]@(Macros|Braces.max) @(Macros|Braces)dmg1type=Force@(Macros|Braces.max) @(Macros|Braces)crit1=[$CritDam]@(Macros|Braces.max) @(Macros|Braces)hldmg=[$HLDam]@(Macros|Braces.max) @(Macros|Braces)charname=[*[%1%]:character_name]@(Macros|Braces.max) @(Macros|Braces)spelllevel=[&amp;Slot]@(Macros|Braces.max) @(Macros|Braces)desc=[Show Spell Description](`<a href="https://app.roll20.net/editor/~[%1%]%7C[*R&gt;spelldesc_link])@(Macros|Braces.max" rel="nofollow">https://app.roll20.net/editor/~[%1%]%7C[*R&gt;spelldesc_link])@(Macros|Braces.max</a>) Sorry I didn't see this before, Colin. I don't think you've deferred those Fetch calls at all... In my example, I broke up the syntax with the ^ to make sure they weren't detected until the outbound call was sent. So not: @(Macros|Braces) ...but... @^(Macros|Braces) If you get a chance, see if that works better.
1642217123
I was unclear: I used the ^ deferral, and *that* didn't work, although taking out did. The comment about breaking was in reference to using the ^ deferral.&nbsp; I got an error message on my log indicating that @(Macros|Braces) could not be found (or whatever that error is). But that only happened even using the ^ deferral. I think that it works ok without deferral because, by the time the fetch happens, the double braces have already been read out of the overall script. timmaugh said: Colin C. said: This breaks. For some reason, the deferred&nbsp; fetch &nbsp;call fails, but only within &nbsp;the outbound call. --@as|[*[%1%]:character_name] {^&amp;template:atkdmg} @(Macros|Braces)mod=[*[%1%]:spell_attack_bonus]@(Macros|Braces.max) @(Macros|Braces)rname=Spiritual Weapon@(Macros|Braces.max) @(Macros|Braces)r1=[$Roll1]@(Macros|Braces.max) @(Macros|Braces)r2=[$Roll2]@(Macros|Braces.max) @(Macros|Braces)always=1@(Macros|Braces.max) @(Macros|Braces)attack=1@(Macros|Braces.max) @(Macros|Braces)damage=1@(Macros|Braces.max) @(Macros|Braces)dmg1flag=1@(Macros|Braces.max) @(Macros|Braces)dmg1=[$DamRoll]@(Macros|Braces.max) @(Macros|Braces)dmg1type=Force@(Macros|Braces.max) @(Macros|Braces)crit1=[$CritDam]@(Macros|Braces.max) @(Macros|Braces)hldmg=[$HLDam]@(Macros|Braces.max) @(Macros|Braces)charname=[*[%1%]:character_name]@(Macros|Braces.max) @(Macros|Braces)spelllevel=[&amp;Slot]@(Macros|Braces.max) @(Macros|Braces)desc=[Show Spell Description](`<a href="https://app.roll20.net/editor/~[%1%]%7C[*R&gt;spelldesc_link])@(Macros|Braces.max" rel="nofollow">https://app.roll20.net/editor/~[%1%]%7C[*R&gt;spelldesc_link])@(Macros|Braces.max</a>) Sorry I didn't see this before, Colin. I don't think you've deferred those Fetch calls at all... In my example, I broke up the syntax with the ^ to make sure they weren't detected until the outbound call was sent. So not: @(Macros|Braces) ...but... @^(Macros|Braces) If you get a chance, see if that works better.
1642259732
Kurt J.
Pro
API Scripter
ScriptCards 1.5.4 (EXPERIMENTAL) PLEASE READ THIS BEFORE UPDATING! This release will not be pushed to OneClick. A new version of ScriptCards has been uploaded to the GitHub Repo . This version includes a complete rewrite of the dice roll parsing system, improving the flexibility of the roll parser and correcting a few bugs. Among the roll parser improvements are: Roll components are no longer case sensitive for any that previously were. Rolls utilizing "khX" or "klX" are no longer sorted prior to being output - the order of the rolls is now unchanged. Eliminated rolls (either via kh/kl or wild dice removal) are now included in the hover-over text surrounded by [x x] (ie. [x5x] to indicate what the roll was that was eliminated from the total. Rolls that count successes (i.e., 5d6&gt;4) no longer highlight the roll with red/blue/green since that doesn't really make sense. Appending a # to any dice formula will eliminate that roll from contributing to the highlighting check (For example, if you have a 5E to hit roll of "1d20 + 1d4 [Bless] + 5 [Str] + 2 [Prof]" the old system would highlight the roll as a crit if either the d20 was a 20 or the d4 was a 4, and the same for a fumble and 1s. In 1.5.4, appending # to the 1d4 roll ("1d20 + 1d4# [Bless] +5 [Str] + 2 [Prof]") will only highlight the roll based off of the d20 roll and not the d4. In the next release, the # specifier will also prevent the roll from being included in the "Base" value for the roll, meaning that things like "1d4 [Bless]" will no longer interfere with detecting critical hits/fumbles by checking [$Roll.Base] The code is much cleaner, more consistent, and more easily expandable. The rewrite eliminated about 240 lines of code in the script. This is marked as experimental because, although I haven't run into any issues with what I have tested so far, that doesn't mean there aren't things I have missed. If you update to this version and encounter strangeness with rolls, please let me know and post the roll that is causing trouble so I can make any required adjustments to the roll parser. If you update and find you need to roll back, here is a direct link to Version 1.5.3 on the history on GitHub .
1642306224

Edited 1642306246
Hi how can I add the advantage and disadvantage option on a 5e attack script?
1642319125
I'm trying to get an aura to appear for a character to demonstrate their range of attack. For whatever reason, the target is getting called before the aura is being applied. This is my last major hurdle before I can move on and not be stuck trying to work on this one token for more days. Also if anyone knows if auras can be transparent with a border that'd be cool, but my searching has yielded nothing promising. !scriptcard {{ --@token-mod|{&amp; select Alchemist} _on showplayers_aura1 _set aura1_radius|20 aura1_color #fffff --#title|Lesser Alchemist's Fire --#leftsub|Ranged Bomb Attack --#sourceToken|@{selected|token_id} --#^targetToken|@{target|token_id} --#emoteText|@{selected|token_name} hurls a bomb at @{target|token_name} --=TargetAC|[*T:t-bar2_value] --=CritAC|[$TargetAC]+10 --=CritMissAC|[$TargetAC]-10 --?[$TargetAC.Total] -gt 0|DoneWithAC --=TargetAC|[*T:t-bar2_value] --:DoneWithAC| --=Splash_Damage|@{selected|intelligence_modifier} --=AttackRoll|1d20 + @{selected|bomb_attack} --+Attack|@{selected|token_name} rolls [$AttackRoll] vs AC [$TargetAC]. --?[$AttackRoll.Base] -eq 20|Crit --?[$AttackRoll] -ge [$CritAC]|Crit --?[$AttackRoll.Base] -eq 1|Critical Miss --?[$AttackRoll] -le [$CritMissAC]|Critical Miss --?[$AttackRoll] -ge [$TargetAC] -and -lt [$CritAC]|Hit --+Miss|The attack missed;the target and all creatures within 5 feet take only [$Splash_Damage] fire damage. --{&amp; select Alchemist} --@forselected|smartAoE _controlTokName|AoEControlToken _controlTokSize|1 _aoeColor|#00ccff50 _aoeOutlineColor|#0099ff _aoeType|circle, float _radius|5ft _minGridArea|0.5 _forceIntersection|1 _minTokArea|0.25 _fx|burst-fire _dc|5 _saveFormula|0 _damageFormula1|@{Alchemist|intelligence_modifier} _damageType1|Fire _instant|1 _autoApply|yes _bar|1 _zeroHPmarker|dead --^Final| --:Critical Miss| --+Critical Miss!|No damage is dealt. No persistant damage is applied. --^Final| --:Hit| --vtoken|@{target|token_id} burst-fire --=Bomb_Damage|1d8 --@token-mod| _set bar1_value|-[$Bomb_Damage] _ids @{target|token_id} --=Persistant_Damage|2 --+Hit!|The attack hit @{target|token_name} for [$Bomb_Damage] direct fire damage. Creatures within 5' are hit with [$Splash_Damage] fire damage. --{&amp; select Alchemist} --@forselected|smartAoE _controlTokName|AoEControlToken _controlTokSize|1 _aoeColor|#00ccff50 _aoeOutlineColor|#0099ff _aoeType|circle, float _radius|5ft _minGridArea|0.5 _forceIntersection|1 _minTokArea|0.25 _fx|burst-fire _dc|5 _saveFormula|0 _damageFormula1|@{Alchemist|intelligence_modifier} _damageType1|Fire _instant|1 _autoApply|yes _bar|1 _zeroHPmarker|dead --^Final| --:Crit| --vtoken|@{target|token_id} burst-fire --=Bomb_Damage|2d8 --=Persistant_Damage|4 --+Critical Hit!|The attack hit @{target|token_name} for [$Bomb_Damage] fire damage. Creatures within 5' are hit with [$Splash_Damage] fire damage. --{&amp; select Alchemist} --@forselected|smartAoE _controlTokName|AoEControlToken _controlTokSize|1 _aoeColor|#00ccff50 _aoeOutlineColor|#0099ff _aoeType|circle, float _radius|5ft _minGridArea|0.5 _forceIntersection|1 _minTokArea|0.25 _fx|burst-fire _dc|5 _saveFormula|0 _damageFormula1|@{Alchemist|intelligence_modifier} _damageType1|Fire _instant|1 _autoApply|yes _bar|1 _zeroHPmarker|dead --:Final| }}
@Zack B - you might see if the Radar script meets your needs
@Frederick D. -&nbsp;&nbsp; &nbsp; --&amp;RollType|?{Advantage or Disadvantage?|Normal,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1}
1642342045
@Zach B. The problem is order of processing operations. Roll20 processes all @{whatever|whatever} structures before &nbsp;any APIs can process. If you don't mind adding a click to your process, you could put your targeting statement behind a --i call, and then use the string variable in place of your targeting calls.
I am sorry if this question has been asked before but I did look and I could not find an answer.&nbsp;&nbsp; I am trying to figure out how to use a button to call a procedure and pass a&nbsp; parameter, but everything that I have tried so far will not pass the parameter. I can post the full code if that is helpful but here is the basic piece that I am having issues with, any help would be appreciated. !script {{ --+|[rbutton][*R:atkname]::AddAttack|[*R:atkname][/rbutton] --X| --:AddAttack| --+test: |[%1%] --~dummy|array;add;AttackList;[%1%] --&gt;NextStep| }}
1642383531
Colin C. said: @Zach B. The problem is order of processing operations. Roll20 processes all @{whatever|whatever} structures before &nbsp;any APIs can process. If you don't mind adding a click to your process, you could put your targeting statement behind a --i call, and then use the string variable in place of your targeting calls. So the way it would work is trigger scriptcard, use --i and produce a button to click in the chat menu that prompts the player to click the target, then the rest is performed? Hm. I think I'll go with when the chat menu for bomb selection is opened it activates the range.Which is working for my needs. Thanks!
1642390689
--+|[rbutton][*R:atkname]::AddAttack|[*R:atkname][/rbutton] Should be this: --+|[rbutton][*R:atkname]::AddAttack ; [*R:atkname][/rbutton] With a ; in place of the second |
1642390758
Correct. Good luck! Zack B. said: So the way it would work is trigger scriptcard, use --i and produce a button to click in the chat menu that prompts the player to click the target, then the rest is performed?
1642420256
In using the version of magic missile that allows for multiple targets, I'm finding that the damage applied to target hit point bars doesn't work correctly if less targets than the number of missiles are selected. For example, if I select 2 targets on a level 1 cast, the first missile's damage isn't applied to either target. If I select 1 target on a level 1 cast, only the third missile's damage is applied to the target. The body of the code version I'm using is printed below. Does anyone know how to fix this problem? &nbsp; --#title|Magic Missile &nbsp; --#sourceToken|@{selected|token_id} &nbsp; --#targetToken|@{target|token_id} &nbsp; &nbsp; --&gt;GetAndCheckSlotInformation| &nbsp; --=MissileCount|[$SlotLevel] + 2 &nbsp; --=OneMissileDamage|1d4+1 &nbsp; --&gt;BuildAndAskTargets|[$MissileCount.Total] &nbsp; --=DisplayCount|1 &nbsp; --=MissileDamage|0 &nbsp; --#leftsub|Slot level [$SlotLevel] &nbsp; --#rightsub|Ranged Attack &nbsp; --#emoteText|@{selected|character_name} uses a level [$SlotLevel.Total] spell slot to fire [$MissileCount.Total] missiles of magical force! &nbsp; --/|Determine damage subroutine. Start by assuming we aren't going to apply damage &nbsp; --&amp;damageRoutine|DontApplyDamage&nbsp; &nbsp; --?[&amp;damageApplyScript] -eq "alterbars"|&amp;damageRoutine;ApplyDamageAlterbars &nbsp; --a|[&amp;SoundEffectTrack] &nbsp; --:MissileLoop| &nbsp; --&gt;FireMissile|[$DisplayCount.Total] &nbsp; --=DisplayCount|[$DisplayCount] + 1 &nbsp; --?[$DisplayCount] -le [$MissileCount]|MissileLoop &nbsp; --+Total|Total damage is [$MissileDamage] &nbsp; --&gt;DeductSpellSlot| &nbsp; --#rightsub|Level [$SlotLevel] Left: [$SlotsTotal] - [$SlotsExpended]&nbsp; &nbsp; --X| --:GetAndCheckSlotInformation| &nbsp; --=SlotLevel|?{Spell Slot Level?|1|2|3|4|5|6|7|8|9} &nbsp; --=SlotsTotal|[*S:lvl[$SlotLevel]_slots_total] &nbsp; --=SlotsExpended|[*S:lvl[$SlotLevel]_slots_expended] &nbsp; --?[$SlotsExpended.Total] -ge [$SlotsTotal.Total]|NoSlotsLeft &nbsp; --&lt;| &nbsp; --:NoSlotsLeft| &nbsp; --+|[*S:character_name] has no level [$SlotLevel.Total] spell slots available. &nbsp; --X| &nbsp; --:DeductSpellSlot| &nbsp; --=SlotsExpended|[$SlotsExpended] + 1 &nbsp; --@setattr|_charid [*S:character_id] _lvl[$SlotLevel]_slots_expended|[$SlotsExpended] _silent &nbsp; --=SlotsRemaining[$SlotsTotal] - [$SlotsExpended]&nbsp; &nbsp; --&lt;| &nbsp; --:FireMissile| &nbsp; --&amp;ThisTarget|[&amp;target[%1%]] &nbsp; --?[&amp;damageMode] -eq 1|=ThisMissile;1d4+1|=ThisMissile;[$OneMissileDamage] &nbsp; --=MissileDamage|[$MissileDamage] + [$ThisMissile] &nbsp; --+Missile|[$DisplayCount.Total] Hits [*[&amp;ThisTarget]:character_name] for [$ThisMissile] [b]force[/b] damage&nbsp; &nbsp; --&gt;PlayEffects|@{selected|token_id};[&amp;ThisTarget];none;burst-smoke;beam-magic &nbsp; --=ResultantDamage|[$ThisMissile.Raw] &nbsp; --?"[*[&amp;tokenid]:npc_immunities]" -inc "[&amp;damageType]"|Immune &nbsp; --?"[*[&amp;tokenid]:npc_resistances]" -inc "[&amp;damageType]"|Resistant &nbsp; --?"[*[&amp;tokenid]:npc_vulnerabilities]" -inc "[&amp;damageType]"|Vulnerable &nbsp; --^DoneResist| &nbsp; --:Immune| &nbsp; --=ResultantDamage|0 &nbsp; --^DoneResist| &nbsp; --:Resistant| &nbsp; --=ResultantDamage|[$ThisMissile] \ 2 &nbsp; --^DoneResist| &nbsp; --:Vulnerable| &nbsp; --=ResultantDamage|[$ThisMissile] * 2 &nbsp; --^DoneResist| &nbsp; --:DoneResist| &nbsp; --&gt;[&amp;damageRoutine]|[&amp;ThisTarget];[&amp;hitPointsBar];[$ResultantDamage.Raw]&nbsp; &nbsp; --&lt;| &nbsp; --:BuildAndAskTargets| &nbsp; --&amp;TargetString| &nbsp; --=targetCount|1 &nbsp; --:TargetLoop| &nbsp; --&amp;TargetString|+t;target[$targetCount.Raw];Missile [$targetCount.Raw] Target &nbsp; --=targetCount|[$targetCount.Raw] + 1 &nbsp; --?[$targetCount] -le [%1%]|&gt;AddSeparator &nbsp; --?[$targetCount] -le [%1%]|TargetLoop &nbsp; --iPlease click the button below to select magic missile targets. The same target can be selected multiple times;Select [%1%] Targets|[&amp;TargetString] &nbsp; --/| &nbsp; --&lt;| &nbsp; --:AddSeparator| &nbsp; --&amp;TargetString|+|| &nbsp; --&lt;|
Colin C. said: --+|[rbutton][*R:atkname]::AddAttack|[*R:atkname][/rbutton] Should be this: --+|[rbutton][*R:atkname]::AddAttack ; [*R:atkname][/rbutton] With a ; in place of the second | Thank you Colin for your response I tried this and it makes the call to the procedure but I cannot access the passed parameter&nbsp; [*R:atkname] &nbsp;using [%1%] in the AddAttack procedure.&nbsp; It seems like it is not being passed or do I need to reference the parameter differently?&nbsp; I am wanting to add the string output of it into the array but I cannot even output it with&nbsp; --+test: | [%1%] . &nbsp;I am not sure where I am going wrong with this so any help would be appreciated. !script {{ --+|[rbutton][*R:atkname]::AddAttack ; [*R:atkname][/rbutton] --X| --:AddAttack| --+test: | [%1%] --~dummy|array;add;AttackList;[%1%] --&gt;NextStep| }}
1642445381
I have a new question.&nbsp; Is it possible for a scriptcard to prompt the GM for variables for a card a player initiates.&nbsp; My guess is no.&nbsp; I want the GM to be able to add a modifier to a roll or establish a difficulty for a roll without the player knowing immediately what it is.
1642453965
timmaugh
Pro
API Scripter
Pop-up interrogatives are only presented to the originator of the message. Chat messages can present buttons and be tailored to individual recipients, though. So you maybe could accomplish this with a series of buttons to create new message "owners". You would have to send a button to the GM, prompting that person to click and initiate a roll (DiscreteWhisper can do this, as well as other scripts). That roll would initiate a ScriptCard to launch a ChatSetAttr to query for data it would then dump data in a particular place (a macro mule). Then that SC would launch your notification script (DW, in this case) to send a button back to the original player. That button would launch the next step (be it another ScriptCard or a different script/roll). Maybe someone else will have something more... direct.
1642468335

Edited 1642468582
Kurt J.
Pro
API Scripter
Dyesuhn said: In using the version of magic missile that allows for multiple targets, I'm finding that the damage applied to target hit point bars doesn't work correctly if less targets than the number of missiles are selected. For example, if I select 2 targets on a level 1 cast, the first missile's damage isn't applied to either target. If I select 1 target on a level 1 cast, only the third missile's damage is applied to the target. The body of the code version I'm using is printed below. Does anyone know how to fix this problem? The reason behind this is that, when using external API calls to adjust hitpoints, they are all seeing the value before it gets adjusted if there are a multiple calls for the same target. If you are using version 1.5.2+ of ScriptCards, the latest update to the Magic Missile sample in the repo ( <a href="https://github.com/kjaegers/ScriptCards/blob/main/ScriptExamples/dnd5e/5e_Magic_Missile.txt" rel="nofollow">https://github.com/kjaegers/ScriptCards/blob/main/ScriptExamples/dnd5e/5e_Magic_Missile.txt</a> ) has been updated to use the new ability for ScriptCards to directly modify attribute on tokens and characters, meaning it doesn't need to call external APIs so the values are always up to date. It would be possible to modify the damage application logic to build of a list of the damage that should be applied to targets so there is only one call for each target, but that is a more complicated solution.&nbsp;
1642468524
Kurt J.
Pro
API Scripter
Matt N. said: Colin C. said: --+|[rbutton][*R:atkname]::AddAttack|[*R:atkname][/rbutton] Should be this: --+|[rbutton][*R:atkname]::AddAttack ; [*R:atkname][/rbutton] With a ; in place of the second | Thank you Colin for your response I tried this and it makes the call to the procedure but I cannot access the passed parameter&nbsp; [*R:atkname] &nbsp;using [%1%] in the AddAttack procedure.&nbsp; It seems like it is not being passed or do I need to reference the parameter differently?&nbsp; I am wanting to add the string output of it into the array but I cannot even output it with&nbsp; --+test: | [%1%] . &nbsp;I am not sure where I am going wrong with this so any help would be appreciated. !script {{ --+|[rbutton][*R:atkname]::AddAttack ; [*R:atkname][/rbutton] --X| --:AddAttack| --+test: | [%1%] --~dummy|array;add;AttackList;[%1%] --&gt;NextStep| }} The variable passed by a reentrant button is accessed via&nbsp;[&amp;reentryval], and not [%1%] since, technically, reentrant buttons are not calling subroutines (--&lt;| from a reentrant point won't return to anything, and there is no passed parameter stack, since --&gt; was not used to call the procedure.)
1642468558
Matt N. said: Thank you Colin for your response I tried this and it makes the call to the procedure but I cannot access the passed parameter&nbsp; [*R:atkname] &nbsp;using [%1%] in the AddAttack procedure.&nbsp; It seems like it is not being passed or do I need to reference the parameter differently?&nbsp; I am wanting to add the string output of it into the array but I cannot even output it with&nbsp; --+test: | [%1%] . &nbsp;I am not sure where I am going wrong with this so any help would be appreciated. !script {{ --+|[rbutton][*R:atkname]::AddAttack ; [*R:atkname][/rbutton] --X| --:AddAttack| --+test: | [%1%] --~dummy|array;add;AttackList;[%1%] --&gt;NextStep| }} It's because the [rbutton] structure uses the reentry syntax, rather than the gosub syntax. Earlier in your script you need: --#reentrant|&lt;something unique about this script&gt; And then in your procedure, instead of [%1%], you need to use [&amp;reentryval]
1642520616
Kurt J. said: If you are using version 1.5.2+ of ScriptCards, the latest update to the Magic Missile sample in the repo ( <a href="https://github.com/kjaegers/ScriptCards/blob/main/ScriptExamples/dnd5e/5e_Magic_Missile.txt" rel="nofollow">https://github.com/kjaegers/ScriptCards/blob/main/ScriptExamples/dnd5e/5e_Magic_Missile.txt</a> ) has been updated to use the new ability for ScriptCards to directly modify attribute on tokens and characters, meaning it doesn't need to call external APIs so the values are always up to date. Thanks, Kurt. That worked.
1642530565
Hey Kurt,&nbsp; I know there is an output line to send text that only the GM (--*)can see, but is it possible to have it the other way around? If I have a card that whispers to me as the GM, can I output a line that goes to the public chat? Thanks!
1642540246
--e Erik M. said: Hey Kurt,&nbsp; I know there is an output line to send text that only the GM (--*)can see, but is it possible to have it the other way around? If I have a card that whispers to me as the GM, can I output a line that goes to the public chat? Thanks!