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

Is there a way (without changing parameter delimiters) to do string operations on semicolons? I haven't found anything about escape characters in the wiki.
Is there a way to put a line break/newline/carriage return into a table entry so the scriptcard splits the entry into two lines?
How do i use this with WOD Storyteller system where the attributes are d10 dice that have to be rolled at a variable difficulty and then calculate target successes? I had it figured out in Power Cards but cant get it to work here. This is an example of a line im trying: @{selected|Strength} + ?{Damage Modifier|0})d10>?{Damage Difficulty|6}f1!
@Reuben: AFAIK, there's no direct die code that allows for WoD (assuming oWoD or WoD20, given the variable difficulty) style rolls.  Here's a quick code that will handle it (written for a die pool of 10 at difficulty 6, but you should be able to extrapolate from this for your needs).  This code assumes that you don't subtract ones on rerolls; I've seen Storytellers do it either way - if you want to subtract ones on the rerolls, you need to add in a line to subtract [$temp.Ones] from the running total.  This is kit-bashed, ugly code, but it should give you the basics to know what you need - it can be streamlined, but hopefully in its blocky form it shows you what you need better. !scriptcard {{ --/|basic roll --=roll|10d10>6 --+roll|[$roll] --/|subtract the ones --=botches|[$roll] - [$roll.Ones] --+botches|[$botches] --/|set up to reroll 10s --=rerolls|[$roll.Aces] --=total|[$botches] --/|handles the exploding 10s --:loop| --?[$rerolls] -eq 0|break --/|the reroll --=temp|[$rerolls]d10>6 --+rerolling 10s|[$temp] --/|add the new successes --=total|[$total] + [$temp] --/|reset the rerolls for any new 10s --=rerolls|[$rerolls.Aces] --^loop| --/|escaped the loop and display total --:break| --+total|[$total] }} If you wanted nWoD-style rolls (where you might have to explode 8s or 9s, you'd have to have to be tricky; with the reroll 8's, *any* success rerolls, so that's easy...  the reroll 9s rule on the other hand would probably require an individual die check to figure out the exploding.
@Kurt & David..... I apologize for the delayed response as I have been out of town.... These options are perfect and great as they help me understand different ways to get the results I was looking for in both cases.. I appreciate the feedback and insight on how it should work!! Thanks again for your support and expertise!!
I'm confused on the format for background images in the cards. --#titlecardbackgroundimage|&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;-----&nbsp; what is the format for this part here to call an image from the web I have tried --#titlecardbackgroundimage|<a href="https://helios-i.mashable.com/imagery/articles/03bDuXus9Lsnz9sUqURbDiB/hero-image.fill.size_1248x702.v1643714839.jpg" rel="nofollow">https://helios-i.mashable.com/imagery/articles/03bDuXus9Lsnz9sUqURbDiB/hero-image.fill.size_1248x702.v1643714839.jpg</a> --#titlecardbackgroundimage|[img]<a href="https://helios-i.mashable.com/imagery/articles/03bDuXus9Lsnz9sUqURbDiB/hero-image.fill.size_1248x702.v1643714839.jpg[/img]" rel="nofollow">https://helios-i.mashable.com/imagery/articles/03bDuXus9Lsnz9sUqURbDiB/hero-image.fill.size_1248x702.v1643714839.jpg[/img]</a> --#titlecardbackgroundimage|+{[img]<a href="https://helios-i.mashable.com/imagery/articles/03bDuXus9Lsnz9sUqURbDiB/hero-image.fill.size_1248x702.v1643714839.jpg[/img]" rel="nofollow">https://helios-i.mashable.com/imagery/articles/03bDuXus9Lsnz9sUqURbDiB/hero-image.fill.size_1248x702.v1643714839.jpg[/img]</a>} Thanks
I'm trying to recall the exact syntax - try this:&nbsp; url(<a href="https://s3.amazonaws.com/files.d20.io/images/229710089/fIxcDIjUWW3z2b6RZRGrCg/original.png?16242243555);background-size" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/229710089/fIxcDIjUWW3z2b6RZRGrCg/original.png?16242243555);background-size</a>: auto;background-repeat: round;
Will M. said: I'm trying to recall the exact syntax - try this:&nbsp; url(<a href="https://s3.amazonaws.com/files.d20.io/images/229710089/fIxcDIjUWW3z2b6RZRGrCg/original.png?16242243555);background-size" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/229710089/fIxcDIjUWW3z2b6RZRGrCg/original.png?16242243555);background-size</a>: auto;background-repeat: round; That worked thanks!!
I'm getting into ScriptCards, and I like it more than a little. I do have a question regarding Object Modification. I'm trying to set the imgsrc of my token and this is not working: !script {{ --!t:@{selected|token_id}|imgsrc:<a href="https://s3.amazonaws.com/files.d20.io/images/255603349/NpgGfmOY7VjMRke3VjaBFw/original.png?16368985955" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/255603349/NpgGfmOY7VjMRke3VjaBFw/original.png?16368985955</a> }} I get the error:&nbsp;" ERROR: You cannot set the imgsrc or avatar of an object unless you use an image that is in your Roll20 Library. See the API documentation for more info. " The image is in my library. Using Debug doesn't tell me any more info. But using this in with Token Mod does work: !token-mod --set imgsrc|<a href="https://s3.amazonaws.com/files.d20.io/images/255603349/NpgGfmOY7VjMRke3VjaBFw/original.png?16368985955" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/255603349/NpgGfmOY7VjMRke3VjaBFw/original.png?16368985955</a> I'd prefer to run it all in ScriptCard to avoid turning on Players can use IDs in Token Mod to call TM from within my script, but if that's what's necessary, then okay. Any thoughts?
1649714520
Kurt J.
Pro
API Scripter
StJohn70 said: I'm getting into ScriptCards, and I like it more than a little. I do have a question regarding Object Modification. I'm trying to set the imgsrc of my token and this is not working: !script {{ --!t:@{selected|token_id}|imgsrc:<a href="https://s3.amazonaws.com/files.d20.io/images/255603349/NpgGfmOY7VjMRke3VjaBFw/original.png?16368985955" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/255603349/NpgGfmOY7VjMRke3VjaBFw/original.png?16368985955</a> }} I get the error:&nbsp;" ERROR: You cannot set the imgsrc or avatar of an object unless you use an image that is in your Roll20 Library. See the API documentation for more info. " The image is in my library. Using Debug doesn't tell me any more info. But using this in with Token Mod does work: !token-mod --set imgsrc|<a href="https://s3.amazonaws.com/files.d20.io/images/255603349/NpgGfmOY7VjMRke3VjaBFw/original.png?16368985955" rel="nofollow">https://s3.amazonaws.com/files.d20.io/images/255603349/NpgGfmOY7VjMRke3VjaBFw/original.png?16368985955</a> I'd prefer to run it all in ScriptCard to avoid turning on Players can use IDs in Token Mod to call TM from within my script, but if that's what's necessary, then okay. Any thoughts? I'll have a fix rolling out for this shortly. The : in https:// &nbsp;is confusing the parameter parser. Additionally, when setting the graphics setting for tokens, you'll need to use "thumb" instead of "original" - tokenmod does this replacement automatically when setting the imgsrc, so I may do that as well. I shoud have a new version up on the GitHub later tonight once I verify that my changes didn't break anything else :)
Kurt J. said: I'll have a fix rolling out for this shortly. The : in https:// &nbsp;is confusing the parameter parser. Additionally, when setting the graphics setting for tokens, you'll need to use "thumb" instead of "original" - tokenmod does this replacement automatically when setting the imgsrc, so I may do that as well. I shoud have a new version up on the GitHub later tonight once I verify that my changes didn't break anything else :) That's great! Unrelated question: I'm using branching logic in my script, and several places in the different branches use ?{} queries to get user input. The script parses all of the queries, regardless of whether the script runs into that branch. The script ignores anything from those queries, but it's weird anyway.&nbsp; Is there a better way to do this?
@StJohn Scriptcards does have an information request (--i) command that you could possibly use instead of the ?{} queries.&nbsp; If it's something that is always asked, the Roll20 (?{}) queries might make the macro flow better, so I'd use them in such a case, as the --i command stops the macro and requires the user to push a button, rather than simply asking like the Roll20 query does.&nbsp; On the other hand, in many cases, that is not only not a problem but useful (since the --i doesn't work up front and can rely on data from the macro), and it won't show up if it's in an unused branch.
unverified said: @StJohn Scriptcards does have an information request (--i) command that you could possibly use instead of the ?{} queries.&nbsp; If it's something that is always asked, the Roll20 (?{}) queries might make the macro flow better, so I'd use them in such a case, as the --i command stops the macro and requires the user to push a button, rather than simply asking like the Roll20 query does.&nbsp; On the other hand, in many cases, that is not only not a problem but useful (since the --i doesn't work up front and can rely on data from the macro), and it won't show up if it's in an unused branch. Yeah, I took a look at the information request and that's not what I need for this particular script, anyhow. I'm taking another look at using some child macros called through the [sheetbutton] implementation, but I use a lot of String Variables that need to be replicated across. Since storage only allows for Settings and RollVariables, I'd have to duplicate a lot to each - or potentially write a library just to return these settings. It's a bit of a re-factor.
There is also a method to place variables in state memory, which can be like having a global memory store.&nbsp; It also persists across sessions.&nbsp;
Will M. said: There is also a method to place variables in state memory, which can be like having a global memory store.&nbsp; It also persists across sessions.&nbsp; Yeah, I tried that. You can only store Settings or RollVariables in this memory store. I need to be able to store StringVariables.
1649755255
Kurt J.
Pro
API Scripter
StJohn70 said: Will M. said: There is also a method to place variables in state memory, which can be like having a global memory store.&nbsp; It also persists across sessions.&nbsp; Yeah, I tried that. You can only store Settings or RollVariables in this memory store. I need to be able to store StringVariables. There are 10 user setting (usersetting0 thru usersetting9) that aren't used by ScriptCards but are saved with the setting storage that can behave like strings.
Is there a way to show the character image as part of Script Card output?
1650132525

Edited 1650132576
&nbsp; --#titlecardbackgroundimage|url( <a href="https://i.pinimg.com/originals/bf/c7/1d/bfc71d599c4f5f2fd6722bd656b08598.gif);background-size" rel="nofollow">https://i.pinimg.com/originals/bf/c7/1d/bfc71d599c4f5f2fd6722bd656b08598.gif);background-size</a> : auto;background-repeat: round; --#titleFontLineHeight|2.5em I set the height at 5 for player images.
1650501234
Kurt J.
Pro
API Scripter
ScriptCards 1.7.5 and 5E Character Action Menu 1.8.5 New updates to ScriptCards and to the 5E Character Action Menu &nbsp;script are now available on the GitHub Repo . ScriptCards 1.7.5 Two new settings: outputtagprefix and outputcontentprefix. Anthing in these settings will be pre-pended to the tag or content portion of all subsequent --+ or --* lines. By default, outputtagprefix is empty and outputcontentprefix contains a single space. You could use these to indent lines by using --#outputtagprefix|&amp;nbsp; or something similar. (&amp;nbsp; is the HTML character for non-breaking space). Added some additional information to error messages for conditionals when a value can't be identified. 5E Character Action Menu 1.8.5 I haven't update the notes here since 1.8.0, so here is the consolidated update list: (1.8.1) - Bug fix for healing spells applying damage instead of healing :) (1.8.2) - Optional feature - "selfHandleAdvantageMode". If set to 1 in the script settings area, the action menu will have an advantage/disadvantage/normal indicator and a button to change the current mode. This is active for as long as that iteration of the action menu is used (rerunning the Action menu macro for a character will return to the default advantage mode, also settable). (1.8.3) - Includes optional ammo tracking (disabled by default. Enable in the script settings area) (1.8.4) - Added the ability to optionally track and enforce spell slot limits for PCs. If trackPCSpellSlots is set to 1 in the configuration section, available spell slots will be used to determine which buttons are displayed on the action menu for spells. It also determines which levels are available from the casting menu when the player clicks a spell button. If the player scrolls back up and tries to re-cast from a previously generated action menu and chooses a slot level they no longer have a slot for, they will receive a whispered message telling them that they are out of slots for that level. If spell slot tracking is turned on, by default a table of available spell slots is displayed above the spellcasting buttons on the menu.
Okay, I am probably missing something simple but I have been trying to turn on the token UDL lighting in a game without success.&nbsp; Alternately, I have used both of the following commands which have been accepted (without an error message) but do not function.&nbsp; The macro runs without a hitch but the token status does not change. &nbsp; &nbsp; &nbsp;--@token-mod| _ids @{selected|token_id} _on emits_bright emits_low _set bright_distance|10 low__distance|10 statusmarkers|Torch&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;--!t:@{selected|token_id}|emits_bright:on|emits_low:on|bright_distance:10|low__distance:10|statusmarkers:Torch Help?
1650977960
David M.
Pro
API Scripter
Double underscore might be the problem? low__distance should be low_distance
@David M. - sadly, that was a typing error on my part and isn't in the macro.&nbsp;&nbsp;
1651022519
David M.
Pro
API Scripter
Hmm, not sure what's going on. The following works for me (I don't have a statusmarker named Torch, so changed to red for testing). !script {{ --@token-mod| _ids @{selected|token_id} _on emits_bright emits_low _set bright_distance|10 low_distance|10 statusmarkers|red }}
1651090407

Edited 1651090478
Is there a way to know if the other_resource_name field is empty? I've tried comparing it to empty string but it still won't report it as empty. I want to print the other_resource_name only if it is not empty. !scriptcard {{ --&amp;CharID|@{selected|character_id} --?"[*[&amp;CharID]:other_resource_name]" -eq ""|yes|no --^Done| --:yes| --+YES|it is empty --^Done| --:no| --+NO|it is not empty, name is [*[&amp;CharID]:other_resource_name] --:Done| }}
1651090940
David M.
Pro
API Scripter
Try this? --?"X[*[&amp;CharID]:other_resource_name]" -eq "X"|yes|no
David M. said: Try this? --?"X[*[&amp;CharID]:other_resource_name]" -eq "X"|yes|no YES this works, thank you so much =)
I am new to script cards and have been referred here from another posting where I asked about creating complex dice rolls for warhammer DARK HERESY 1e.&nbsp; They have some fairly interesting ways of handling rolls, especially damage and crits.&nbsp; I think I have an idea of how to do some basic if/else work.&nbsp; But the problem is that I seem to run into is that the result of the dice needs to be flipped.&nbsp; That is if the dice rolls a 52, the result becomes 25 (for the purpose of determining what where on the body a hit strikes. I was wondering if anyone had a good way of handling this using ScriptCards.&nbsp; Or even better, if anyone has some script cards codes already set up for DARK HERESY 1e, so I dont need to reinvent the wheel. For reference, the attack roll/damage rules for dark heresy are as follows: 1. Hit Test To make a melee attack with a hand-held weapon, you must be engaged with your target. Test Weapon Skill. When making a ranged attack, you Test Ballistic Skill. Both of these are like any other Tests. If you roll equal to or below your Weapon Skill or Ballistic Skill, you hit your opponent. 2. Determine Hit Location On a successful hit, you next need to determine where the hit landed. Using the Test result, reverse the order of the dice, (e.g. a roll of 32 becomes 23, 19 becomes 91, and so on) and compare this number to Table 7-7: Hit Locations. Note that certain creatures with different body shapes, or mounted opponents, may use different hit location tables. 3. Determine Damage Once you’ve determined the Hit Location, it is time to work out any Damage you have dealt. Each weapon has a Damage listing. This is usually a die roll, plus or minus a number. Roll the appropriate die, and add the Damage Bonus of the weapon. Finally, if you are using a melee weapon, add your Strength Bonus. This is the Damage total. If you roll a “10” on any of your Damage dice, you have a chance of Righteous Fury! (see sidebar). [Righteous Fury: If you get a Nat 10 (or a result of 10 when rolling d5s).&nbsp; The chat output will announce it so you are aware and can roll to hit again.] 4. Apply Damage From the Damage total, your opponent subtracts his Toughness Bonus and any Armour Points that protect the location that is hit. If this reduces the Damage total to 0 or less, your opponent has shrugged off the attack. Any remaining Damage is recorded on his character sheet as Damage. Should this injury equal or exceed his Wounds, he notes any excess as critical Damage and the GM consults the appropriate table based on the weapon used and the amount of Critical Damage accumulated. See Critical Damage on page 201 for more information. I will continue to work on this, on my end and try and create a basic set of scripts to handle this.&nbsp; Thank you in advance.
1651490306
David M.
Pro
API Scripter
Here is a simple string reversal algorithm, including padding with leading zeros for single digit rolls. !script {{ --=roll|1d100 --+Original Roll|[$roll] --?[$roll] -lt 10|[ --&amp;rollStr|0[$roll.Raw] --]|[ --&amp;rollStr|[$roll.Raw] --]| --~len|string;length;[&amp;rollStr] --%i|[$len];1;-1 --~s|string;substring;[&amp;i];1;[&amp;rollStr] --&amp;revStr|+[&amp;s] --%| --=revRoll|[&amp;revStr] --+reverse roll|[$revRoll] }} Examples:
1651494809
Kurt J.
Pro
API Scripter
ScriptCards 1.7.6 The newest version of ScriptCards is currently up on the GitHub and has been queued to push to OneClick for update when that cycle happens. Version 1.7.6 Added the abilityto set roll components with --= (and case or conditional statements). This is accomplished by including the roll component suffix, so --=Roll.Total will allow you to set the Total value on a roll without any relationship to the other components (.Aces, .Odds,.Raw, etc.) The most obvious usage of this is to set the .Style component to override fumble/crit/both coloring. There are several scriptsettings that control this colorization, so if you want to make a 19 or 20 a crit, you could do the following after the roll: &nbsp; &nbsp; &nbsp; &nbsp; --?[$Roll.Base] -ge 19|=Roll.Style;[~stylecrit] &nbsp; The defined settings are "stylenone", "stylenormal", "stylefumble", "stylecrit", and "styleboth" Note that you are not limited to setting just .Style, but any of the roll components. Updates since 1.6.4 (The previous OneClick release) If you haven't followed along with the GitHub releases, the following changes since 1.6.4 will also be live in the new OneClick update: 1.7.5 &nbsp;- Two new settings: outputtagprefix and outputcontentprefix. Anthing in these settings will be pre-pended to the tag or content portion of all subsequent --+ or --* lines. By default, outputtagprefix is empty and outputcontentprefix contains a single space. You could use these to indent lines by using --#outputtagprefix|&amp;nbsp; or something similar. (&amp;nbsp; is the HTML character for non-breaking space). 1.7.5 - Added some additional information to error messages for conditionals when a value can't be identified. 1.7.4 &nbsp;- Reworked the parameters code for Object Modification (--!) to allow for a colon (:) in the content of a setting. 1.7.4 - Included a function from The Aaron's TokenMod to clean up an image url to make it appropriate for setting a token's imgsrc value. 1.7.3 - Some code cleanup to remove JSLint workarounds 1.7.3 - Initial card parsing now replaces newlines with spaces instead of removing them completely. This should not adversely impact existing scripts, but will prevent issues where a line ends with a single dash (-), since that gets interpreted as three dashes in a row, making ScriptCards look for a --- command instead of whatever you are actually trying to do. 1.7.2 &nbsp;- Corrected a display bug in roll text/details when flavor text was added to a roll that began with [T or [t. This was due to the inline formatting code thinking the hover-over text was trying to create a table. 1.7.1 - New in-line rolling syntax. [...] variable referencing constructs now support = as a type, so [=1d20] will in-line roll 1d20 and replace the construct with the raw value of the roll. The roll can also be assigned to a roll variable: [=Result:1d20]. Square brackets are not supported in inline rolls, and currently + and - are the only component connectors supported. 1.7.0 &nbsp;-&nbsp;New expanded suffixes for roll variables: .RollCount, .KeptCount, .DroppedCount, .RolledDice(x), .KeptDice(x), and .DroppedDice(x) 1.6.9 -&nbsp;Added object creation to the --! statment with --!o. Currently, character objects can be created using --!oc-ReturnVariableName|CharacterName 1.6.8 -&nbsp;The --i command now uses the value set by #parameterdelimiter 1.6.7 &nbsp;-&nbsp;Added the #parameterdelimiter setting to allow you to specify the sequence to be used to separate parameters in most ScriptCards commands. 1.6.6 &nbsp;-&nbsp;Bug fix for possible sandbox crash when attempting to retrieve token properties during a variable dereferencing call. 1.6.5 -&nbsp;Changed the referencing prefix for settings from # to ~, so [~title] will now refence the card's title setting. # was clashing with formatting.
Thank you for the reverse number script, it was perfect and exactly what I needed, However, I've run into a bit of an issue where I need to output text based on the result of a roll. The example I'm going to use is not the final one I need (i wanted something simple to learn), but I cannot seem to see much on the way of how this works for if..else logic.&nbsp; I have to take the roll and check if it falls within specific RANGES of numbers.&nbsp; The current example I am using to learn this is: !scriptcard {{ --#title|Fate Roll --#titlecardbackground|red --#leftsub|Void Born --#rightsub|Blank --=FRoll|1d10 --?[$FRoll.Total] -lt 4|le4 --?[$FRoll.Total] -ge 5 -and -le 8|be58 --?[$FRoll.Total] -gt 9|ge9 --:le4| --=FatePts|2 --X| --:be58| --=FatePts|3 --X| --:ge9| --=FatePts|3 --X| --+FATE!|You rolled a [$FRoll.Total].&nbsp; You have [$FatePts.Total] Fate Points. }} The way this is supposed to work is that if you roll a 1-10 you have 2 fate points if you are less than 4, 3 fate points if you have 5-8 and 3 fate points if you roll a 9-10.&nbsp; I know I could combine the 5-8 with the 9-10, but that would defeat what I'm trying to do to learn how the conditionals work.&nbsp; Ideally, I will take what I learn here and apply that to the Attack Roll targeting body parts and then checking the damage to see if it is a critical. I am sorry if this question has been answered somewhere else, but with 45 pages to this thread, its kinda hard to page through it all, and searching for what I wanted wasn't producing results.
1651521583
David M.
Pro
API Scripter
When the parser reaches the --X| lines, it is prematurely ending your macro so the --+FATE line is never executed. Try something like this. It replaces the --X lines with a Goto line that directs the parser to the Done branch label (your final output). I also changed the last conditional to a -ge 9 since it seems like that was the intent. All of this is untested air coding, but I think should at least get you on the right track! !scriptcard {{ --#title|Fate Roll --#titlecardbackground|red --#leftsub|Void Born --#rightsub|Blank --=FRoll|1d10 --?[$FRoll.Total] -lt 4|le4 --?[$FRoll.Total] -ge 5 -and -le 8|be58 --?[$FRoll.Total] -ge 9|ge9 --:le4| --=FatePts|2 --^Done| --:be58| --=FatePts|3 --^Done| --:ge9| --=FatePts|3 --:Done| --+FATE!|You rolled a [$FRoll.Total]. You have [$FatePts.Total] Fate Points. }}
David M. said: When the parser reaches the --X| lines, it is prematurely ending your macro so the --+FATE line is never executed. Try something like this. It replaces the --X lines with a Goto line that directs the parser to the Done branch label (your final output). I also changed the last conditional to a -ge 9 since it seems like that was the intent. All of this is untested air coding, but I think should at least get you on the right track! Okay so it seems I was on the right track.&nbsp; And thank you, ge was the correct one for the purpose of consistency.&nbsp; As for it being air coding; it worked.&nbsp; And was exactly what I was looking for to learn how to do this.&nbsp; I mean, having a fate/wounds roller would be nice.&nbsp; But, normally my players have finished their character creation long before they copy their stuff to r20.&nbsp; But, maybe I could use it to generate npcs on the fly (Yes, I do give my npcs fate points and let them use them).
1651529914
Kurt J.
Pro
API Scripter
ScriptCards 1.7.7 Please be aware that I found a bug in 1.7.6 that can cause issues when setting rolls using case/conditional statements. This will be corrected in 1.7.7 which I have already queued for OneClick (and is up on the Repo) but it will be present in OneClick for a week after this goes live. If you weren't setting roll variables with conditionals (ie, --?"X" -eq "X"|=Roll;1d20) you won't run into any issues, but if you are, please grab 1.7.7 from the GitHub.
Trying to adapt the previous to have the attack roll, reverse number script and then check for a range to output to mark what part of the body is being struck. !scriptcard {{ --#title|Attack Name --#titlecardbackground|#993333 --#leftsub|Melee Attack --#rightsub|5' Reach --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#emoteText|[*S:token_name] attacks [*T:token_name] --&amp;AimType|?{Aim | No aim (+0),+0 | Half aim (+10),+10| Full aim (+20),+20} --&amp;RangeType|?{Range | Point Blank (+30),+30 | Short Range (+10),+10 | Standard range (+0),+0 | Long Range (-10),-10 | Extreme Range (-30),-30} --&amp;RoFType|?{Rate of Fire/Attack Type| Standard (+10),+10 | Semi auto (+0),+0 | Full Auto (-10),-10 | Called Shot (-20),-20 | Suppressing Fire (-20),-20} --=AtkTarget|[*S:BallisticSkill] [BS] + [&amp;AimType] [Aim] + [&amp;RangeType] [Range] + [&amp;RoFType] [Rate of Fire] --=AtkRoll|1d100 --=BodyHit|Null --=DegSucess|[$AtkTarget] - [$AtkRoll] \ 10 --?[$AtkRoll] -lt 10|[ --&amp;rollStr|0[$AtkRoll.Raw] --]|[ --&amp;rollStr|[$AtkRoll.Raw] --]| --~len|string;length;[&amp;rollStr] --%i|[$len];1;-1 &nbsp; --~s|string;substring;[&amp;i];1;[&amp;rollStr] &nbsp; --&amp;revStr|+[&amp;s] --%| --=revRoll|[&amp;revStr] --+Original Role|[$AtkRoll] || Reverse Roll|[$revRoll] --?[$revRoll] -le 0|OOR --?[$revRoll] -le 10|Head --?[$revRoll] -ge 11 -and -le 20|RightArm --?[$revRoll] -ge 21 -and -le 30|LeftArm --?[$revRoll] -ge 31 -and -le 70|Body --?[$revRoll] -ge 71 -and -le 85|RightLeg --?[$revRoll] -ge 86|LeftLeg --?[$revRoll] -ge 101|OOR --:Head| --=BodyHit|Head --^Done| --:RightArm| --=BodyHit|Right Arm --^Done| --:Body| --=BodyHit|Body --^Done| --:LeftArm| --=BodyHit|Left Arm --^Done| --:RightLeg --=BodyHit|Right Leg --^Done| --:LeftLeg| --=BodyHit|Left Leg --:OOR| --=BodyHit|Out of Range --:Done --+[$BodyHit.Text]| }} The script simply will output "Out of Range" as the value of $BodyHit.Text.&nbsp;&nbsp;
1651530455
Kurt J.
Pro
API Scripter
Toby said: Trying to adapt the previous to have the attack roll, reverse number script and then check for a range to output to mark what part of the body is being struck. !scriptcard {{ --#title|Attack Name --#titlecardbackground|#993333 --#leftsub|Melee Attack --#rightsub|5' Reach --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#emoteText|[*S:token_name] attacks [*T:token_name] --&amp;AimType|?{Aim | No aim (+0),+0 | Half aim (+10),+10| Full aim (+20),+20} --&amp;RangeType|?{Range | Point Blank (+30),+30 | Short Range (+10),+10 | Standard range (+0),+0 | Long Range (-10),-10 | Extreme Range (-30),-30} --&amp;RoFType|?{Rate of Fire/Attack Type| Standard (+10),+10 | Semi auto (+0),+0 | Full Auto (-10),-10 | Called Shot (-20),-20 | Suppressing Fire (-20),-20} --=AtkTarget|[*S:BallisticSkill] [BS] + [&amp;AimType] [Aim] + [&amp;RangeType] [Range] + [&amp;RoFType] [Rate of Fire] --=AtkRoll|1d100 --=BodyHit|Null --=DegSucess|[$AtkTarget] - [$AtkRoll] \ 10 --?[$AtkRoll] -lt 10|[ --&amp;rollStr|0[$AtkRoll.Raw] --]|[ --&amp;rollStr|[$AtkRoll.Raw] --]| --~len|string;length;[&amp;rollStr] --%i|[$len];1;-1 &nbsp; --~s|string;substring;[&amp;i];1;[&amp;rollStr] &nbsp; --&amp;revStr|+[&amp;s] --%| --=revRoll|[&amp;revStr] --+Original Role|[$AtkRoll] || Reverse Roll|[$revRoll] --?[$revRoll] -le 0|OOR --?[$revRoll] -le 10|Head --?[$revRoll] -ge 11 -and -le 20|RightArm --?[$revRoll] -ge 21 -and -le 30|LeftArm --?[$revRoll] -ge 31 -and -le 70|Body --?[$revRoll] -ge 71 -and -le 85|RightLeg --?[$revRoll] -ge 86|LeftLeg --?[$revRoll] -ge 101|OOR --:Head| --=BodyHit|Head --^Done| --:RightArm| --=BodyHit|Right Arm --^Done| --:Body| --=BodyHit|Body --^Done| --:LeftArm| --=BodyHit|Left Arm --^Done| --:RightLeg --=BodyHit|Right Leg --^Done| --:LeftLeg| --=BodyHit|Left Leg --:OOR| --=BodyHit|Out of Range --:Done --+[$BodyHit.Text]| }} The script simply will output "Out of Range" as the value of $BodyHit.Text.&nbsp;&nbsp; You will want to use string variables instead of roll variables for text. To set a string variable, use --&amp;: --&amp;BodyHit|Null and to out the contents of a string variable, use [&amp;variablename] with no suffixes: --+[&amp;BodyHit]| Roll variables (--=) are always parsed as dice rolls, while string variables just accept text/numbers/etc. and don't try to manipulate them (other than inline formatting)
1651532262

Edited 1651532325
David M.
Pro
API Scripter
You could also simplify the macro by using a procedure ( wiki link ) to set the hit location. You call a procedure in a conditional by using --?val1 -comparator val2|&gt;ProcedureName;ParameterToPass It functions like a goto branch statement except a procedure will run until it sees a --&lt;| at which time the parser will jump back to the line after which the procedure was called. Finally, you place all procedures after the --X| line so the parser doesn't try to run them all again at the end when you expect your macro to be complete.&nbsp; So, for your macro above using a SetHitLocation procedure and implementing the string variable that Kurt suggested, you'd have something like this. I also updated your emoteText syntax (to *S:t-name syntax as described in the wiki here ) because It was returning undefined for me in testing. Oh, and finally I also added some optional text formatting to make the reverse roll text and hit location stand out, but that is easily removed. Changes are in bold below. !scriptcard {{ --#title|Attack Name --#titlecardbackground|#993333 --#leftsub|Melee Attack --#rightsub|5' Reach --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#emoteText| [*S:t-name] attacks [*T:t-name] --&amp;AimType|?{Aim | No aim (+0),+0 | Half aim (+10),+10| Full aim (+20),+20} --&amp;RangeType|?{Range | Point Blank (+30),+30 | Short Range (+10),+10 | Standard range (+0),+0 | Long Range (-10),-10 | Extreme Range (-30),-30} --&amp;RoFType|?{Rate of Fire/Attack Type| Standard (+10),+10 | Semi auto (+0),+0 | Full Auto (-10),-10 | Called Shot (-20),-20 | Suppressing Fire (-20),-20} --=AtkTarget|[*S:BallisticSkill] [BS] + [&amp;AimType] [Aim] + [&amp;RangeType] [Range] + [&amp;RoFType] [Rate of Fire] --=AtkRoll|1d100 --&amp;BodyHit|Null --=DegSucess|[$AtkTarget] - [$AtkRoll] \ 10 --?[$AtkRoll] -lt 10|[ --&amp;rollStr|0[$AtkRoll.Raw] --]|[ --&amp;rollStr|[$AtkRoll.Raw] --]| --~len|string;length;[&amp;rollStr] --%i|[$len];1;-1 --~s|string;substring;[&amp;i];1;[&amp;rollStr] --&amp;revStr|+[&amp;s] --%| --=revRoll|[&amp;revStr] --+Original Role|[$AtkRoll] || [b]Reverse Roll[/b] [$revRoll] --?[$revRoll] -le 0| &gt;SetHitLocation;OOR --?[$revRoll] -le 10| &gt;SetHitLocation;Head --?[$revRoll] -ge 11 -and -le 20| &gt;SetHitLocation;RightArm --?[$revRoll] -ge 21 -and -le 30| &gt;SetHitLocation;LeftArm --?[$revRoll] -ge 31 -and -le 70| &gt;SetHitLocation;Body --?[$revRoll] -ge 71 -and -le 85| &gt;SetHitLocation;RightLeg --?[$revRoll] -ge 86| &gt;SetHitLocation;LeftLeg --?[$revRoll] -ge 101| &gt;SetHitLocation;OOR --+Hit Location:| [b][#990000][&amp;BodyHit][/#][/b] --X| End Macro --:PROCEDURES| --:SetHitLocation| accepts hit location as parameter --&amp;BodyHit|[%1%] --&lt;| }}
When I copy and try the code you've given, my result is different:
1651535025
David M.
Pro
API Scripter
Hmm, I just copied the macro posted above in its entirety and it is displaying correctly for me. I even hardcoded a roll of 99 in case it was an issue with that particular case. Did you copy it completely, or just some elements of it?
I copied it completely.
Toby said: I copied it completely. Browser crashed, when i reloaded it started working..&nbsp; Dont know what caused it not to work in the first place.
1651710702

Edited 1651711272
Surok
Roll20 Production Team
So I'm trying to have a macro that calls on multiple tables based on the roll. What I'm I doing wrong? Also I would like to roll 4 times...eventually though it's not setup for that right now. !scriptcard {{ --#title|Question and Answer --#leftsub| --#rightsub| --#subtitleFontColor|#000000 --#titlecardbackgroundimage|linear-gradient(red, yellow) --]| --=Roll|[[1d20]] --+Roll|[$Roll] --?[$Roll.Total] -ge 13|SITUATIONS --?[$Roll.Total] -eqi 12|NPC-Generator --?[$Roll.Total] -eqi 11|NPC-Generator --?[$Roll.Total] -eqi 10|NPC-Generator --?[$Roll.Total] -eqi 9|NPC-Generator --?[$Roll.Total] -eqi 8|CREATURES --?[$Roll.Total] -eqi 7|CREATURES --?[$Roll.Total] -le 6|URBAN-EVENTS --^Final| --:URBAN-EVENTS| --=URBAN-EVENTS|[T#URBAN-EVENTS] --+|[$URBAN-EVENTS.tableEntryText] --^Final| --:SITUATIONS| --=SITUATIONS|[T#SITUATIONS-TABLE-VERB-LIST] --+|[$SITUATIONS.tableEntryText] --^Final| --:NPC-Generator| --=NPC-Generator|[#NPC-Generator] --+|[$NPC-Generator.tableEntryText] --^Final| --:CREATURES| --=CREATURES|[T#CREATURES] --+|[$CREATURES.tableEntryText] --^Final| --:Final| --X| --&lt;| }}
1651714368

Edited 1651715014
David M.
Pro
API Scripter
Hmm, this seems like a bug may have crept in. I just tried a previously working scriptcard that uses rollable tables. Result = no longer getting any table output. This was using v1.7.5. I tried manually installing a previous version (1.4.4), and suddenly it started working again. Back to 1.7.5 and broken again. EDIT - Just tried v1.7.7a from github . This latest version seems to be working.
1651715257
David M.
Pro
API Scripter
Surok, try updating your version to 1.7.7a. Aside from two unnecessary lines ( a --]| near the front and a --&lt;| at the end) it looks like what you have should work.
1651749104
Surok
Roll20 Production Team
David M. said: Surok, try updating your version to 1.7.7a. Aside from two unnecessary lines ( a --]| near the front and a --&lt;| at the end) it looks like what you have should work. Seems to be working now, thanks!&nbsp;
1651754095

Edited 1651754114
Surok
Roll20 Production Team
Any idea how I can get this to output 4 rolls? I tried a couple different ways but doesn't seem to spit out results beyond the first roll. I tried making a second set via a Roll2 but it didn't show. Maybe simply telling it to loop 4 times? I dunno. Any ideas? !scriptcard {{ --#title|ELEMENT-INTERACTION --#leftsub| --#rightsub| --#subtitleFontColor|#000000 --#titlecardbackgroundimage|linear-gradient(red, yellow) --=Roll|[[1d20]] --+Roll|[$Roll] --?[$Roll.Total] -ge 13|SITUATIONS --?[$Roll.Total] -eqi 12|NPC-Generator --?[$Roll.Total] -eqi 11|NPC-Generator --?[$Roll.Total] -eqi 10|NPC-Generator --?[$Roll.Total] -eqi 9|NPC-Generator --?[$Roll.Total] -eqi 8|CREATURES --?[$Roll.Total] -eqi 7|CREATURES --?[$Roll.Total] -le 6|URBAN-EVENTS --^Final| --:URBAN-EVENTS| --=URBAN-EVENTS|[T#URBAN-EVENTS] --+|[$URBAN-EVENTS.tableEntryText] --^Final| --:SITUATIONS| --=SITUATIONS|[T#SITUATIONS-TABLE-VERB-LIST] --+|[$SITUATIONS.tableEntryText] --^Final| --:NPC-Generator| --=NPC-Generator|[T#RACE-TABLE] --=NPC-Generator2|[T#ALIGNMENT] --=NPC-Generator3|[T#GENDER] --=NPC-Generator4|[T#PROFESSION] --=NPC-Generator5|[T#ECONOMIC-STATUS] --+|[$NPC-Generator2.tableEntryText] [$NPC-Generator3.tableEntryText] [$NPC-Generator.tableEntryText] [$NPC-Generator4.tableEntryText] [$NPC-Generator5.tableEntryText] --^Final| --:CREATURES| --=CREATURES|[T#CREATURES] --+|[$CREATURES.tableEntryText] --^Final| --:Final| --X| }}
1651771063
David M.
Pro
API Scripter
A For... loop seems easy. You wouldn't even need to reference your loop counter. --=numRolls|?{How many rolls?|4} --%i|1;[$numRolls];1 &nbsp; &nbsp; &nbsp; --=Roll|1d20 &nbsp; &nbsp; &nbsp; &lt;....the rest of your logic&gt; --%| &nbsp; --:Final| &nbsp; --X| }}
1651780406

Edited 1651780503
Surok
Roll20 Production Team
David M. said: A For... loop seems easy. You wouldn't even need to reference your loop counter. --=numRolls|?{How many rolls?|4} --%i|1;[$numRolls];1 &nbsp; &nbsp; &nbsp; --=Roll|1d20 &nbsp; &nbsp; &nbsp; &lt;....the rest of your logic&gt; --%| &nbsp; --:Final| &nbsp; --X| }} Hmm it still only outputs one result. !scriptcard {{ --#title|ELEMENT-INTERACTION --#leftsub| --#rightsub| --#subtitleFontColor|#000000 --#titlecardbackgroundimage|linear-gradient(red, yellow) --=numRolls|?{How many rolls?|4} --%i|1;[$numRolls];1 --=Roll|1d20 --+Roll|[$Roll] --?[$Roll.Total] -ge 13|SITUATIONS --?[$Roll.Total] -eqi 12|NPC-Generator --?[$Roll.Total] -eqi 11|NPC-Generator --?[$Roll.Total] -eqi 10|NPC-Generator --?[$Roll.Total] -eqi 9|NPC-Generator --?[$Roll.Total] -eqi 8|CREATURES --?[$Roll.Total] -eqi 7|CREATURES --?[$Roll.Total] -le 6|URBAN-EVENTS --^Final| --:URBAN-EVENTS| --=URBAN-EVENTS|[T#URBAN-EVENTS] --+|[$URBAN-EVENTS.tableEntryText] --^Final| --:SITUATIONS| --=SITUATIONS|[T#SITUATIONS-TABLE-VERB-LIST] --+|[$SITUATIONS.tableEntryText] --^Final| --:NPC-Generator| --=NPC-Generator|[T#RACE-TABLE] --=NPC-Generator2|[T#ALIGNMENT] --=NPC-Generator3|[T#GENDER] --=NPC-Generator4|[T#PROFESSION] --=NPC-Generator5|[T#ECONOMIC-STATUS] --+|[$NPC-Generator2.tableEntryText] [$NPC-Generator3.tableEntryText] [$NPC-Generator.tableEntryText] [$NPC-Generator4.tableEntryText] [$NPC-Generator5.tableEntryText] --^Final| --:CREATURES| --=CREATURES|[T#CREATURES] --+|[$CREATURES.tableEntryText] --^Final| --%| --:Final| --X| }}
1651780850
David M.
Pro
API Scripter
Ah, right. It's because you are jumping to the :Final tag after resolving the first roll, and Final is outside of the loop. Try changing the last part of your macro to the following. It puts :Final at the end of but still within your loop. --:CREATURES| --=CREATURES|[T#CREATURES] --+|[$CREATURES.tableEntryText] --:Final| --%| }}
1651781139
Surok
Roll20 Production Team
David M. said: Ah, right. It's because you are jumping to the :Final tag after resolving the first roll, and Final is outside of the loop. Try changing the last part of your macro to the following. It puts :Final at the end of but still within your loop. --:CREATURES| --=CREATURES|[T#CREATURES] --+|[$CREATURES.tableEntryText] --:Final| --%| }} Success! Thanks again =)