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 - Thread #2

Thanks, I also needed to remove the space before [$Die]. 
1749756138

Edited 1749756244
<Pats himself on back> Whooo hoo! I'm starting to make some headway in grokking this stuff. I know it's newb level, but I managed to add crit/fail sound triggers to the 5E Action Menu script.  Around line 707 I added this.  Mostly there because it looked like a lot of other roll-based calculations were happening there so the variables would already be "loaded". There could be a better place.    --?[$attack_crit] -eq 1|>audioCrit   --?[$attackRoll.Base] -eq 1|>audioFail At the end I added these at the end... gosubs?   --:audioCrit|   --@roll20AM|_audio,play,nomenu|sfxCrit   --<|     --:audioFail|   --@roll20AM|_audio,play,nomenu|sfxFail   --<|    I'm not sure this was a "good" way to do it, but it worked (After much head scratching and screwing things up, LOL.) In case it helps someone else. I'd appreciate pointers on more elegant methods. ScriptCards roll20AM critical fail sound trigger  5e_Character_Action_Menu.scard  5e_Character_Action_Menu
1749756814

Edited 1749836848
More blabberings... I posted about heals not working on my 5E ActionMenu  script. I was looking at it and this section looks mal-formatted to me, starting at line 954. It is also in the one on the github, not just my copy. Not sure that's any help, but I figured I'd should it out.   --?[&spell_heal] -eq 1|[     --&damageToApply|   --]| (Edited for clarity that I mean the 5E Action Menu script, not some script I created.)
1752616140

Edited 1752616151
Kurt J.
Pro
API Scripter
ScriptCards 3.0.12 is queued for OneClick The latest version of ScriptCards is now queued for inclusion in OneClick. Changes since 3.0.01 include: - Support for Campaign properties "nodeVersion" and "sandboxVersion" to [*C:...] - Added _defaulttoken to the list of fields treated like "bio" fields to allow it to be retrieved. - New string line functions: numbersonly, nonumbers, alphaonly, and numericonly.    Examples given &Test is "-abc123.zyx89":     [&Test(numbersonly)] = 12389     [&Test(nonumbers)] = -abc.zyx     [&Test(alphaonly)] = abczyx     [&Test(numericonly)] = -123.89
1752959719

Edited 1752959879
I see that t-bar1_value returns the  ID of selected card,   is there a way to return the numeric value of bar1?
James, I cannot replicate that. What kind of a game setup are you on? For me in a default game (ie. non-Jumpgate), and non-Beacon sheet, and default sandbox I get: !script {{ --#sourceToken|@{selected|token_id} --+Value|[*S:t-bar1_value] --+Max|[*S:t-bar1_max] --+Link|[*S:t-bar1_link] }} I get value, max, and link as I would expect.
Thank you for your offer of help. The issue is resolved and if you care to know more of the issue read on.  I am using Jumpgate on a homebrew game. According to Wiki ScriptCards Character/Token Attributes (9.6} it says that    t-bar1_value returns the  ID of selected card.  That is what I was getting. The Mod Output was complaining that it found no card. I have been cleaning up some things and tried it again and I got the numeric value. I'm not sure why I was getting what I was (it is apparently connected to the Jukebox according to the error message.) Again many thanks.
Oh I see. I suspect that is some copy/paste issue from the wiki since the _cardid field says the same thing. t-bar1_value now says `numeric` like bar2_value and bar3_value do.
1753223108

Edited 1753223441
vÍnce
Pro
Sheet Author
Is there a method to prevent SC from grabbing the value of an attribute? For example; !script {{ --&SC|@{selected|character_id} --Rfind|[&SC];Test;repeating_nonweaponproficiencies;nwp_name --!a:[&SC]|![*R>nwp_attribute]:@{strength} }} I want to set nwp_attribute with a string value called "@{strength}"  SC grabs the value of @{strength} which is normally fine... but for reasons, I need it to set with the attribute name, not it's value.  Possible?
Hey Vince, Roll20 chat processes all the @{} attribute calls before SC runs. Same for roll queries ?{} and ability calls %{}. You can use SC's string variables as a workaround like so: !script {{ --&AT|@ --&AT|+{ --&SC|@{selected|character_id} --Rfind|[&SC];Test;repeating_nonweaponproficiencies;nwp_name --!a:[&SC]|![*R>nwp_attribute]:[&AT]strength} }} That should work for you to write an attribute with an at symbol.
1753225750
vÍnce
Pro
Sheet Author
Now that you say that... I totally missed that the SC commands are processed in chat before being written to the sheet. lol macro works as expected. Thank you Joshua
Hi, I'm trying to get a scrpitcard program to play the Nimble 5E system. So basically the Nimble 5e only roll the damage dice with modifiers. Now this is the tricky part they use Exploding dice as crit, but the only exploding dice is the one that is most to the left. Below are some situations that I don't know how to resolve. Ex. 1  Rolling advantage. To roll advantage you add one extra damage dice and keep the highest. The problem I get is for weapons or spell that use more than one dice, see bellow. Greatsword (damage 2d6) If I roll with advantage I need to roll 3d6 and drop the lowest, I know how to do that but the problem is with the exploding dice is only the most left. I don't know how to make it so it can always look for that specific dice. Same problem with fumble, the attack miss if the most left dice is a 1. If this even possible to do with scriptcards?. If not I will have my answer and I will have to find a less automated way. Thanks for any help you can give me.
1757091979
timmaugh
Forum Champion
API Scripter
I think you're going to have to come up with a convention for what represents the "left-most die" in a roll. For me, I would assume that to be the first die in the array of dice that are rolled AND which contribute to the roll value. In the case of your 2d6-with-advantage-becoming-a-3d6 example, if the dice rolled: ( 2,  4,  6) The first die would be dropped (2), leaving (4,6). In that case, 4 is in the position of what represents the "left-most", so it has the chance to explode. It does not explode. The 6, although it could have exploded were it considered the left-most, also does not explode. ScriptCards rolls its own dice based on equations you give it, and I believe that it offers up the values of the dice rolled for you to manipulate. (If it doesn't you could build a loop of rolling 1d6 some number of times, allowing you to generate the correct number of values). So I think your approach should be to have a procedure to generate your roll that collects the values of the dice; then you check for how many you should be keeping/dropping and trim the set accordingly; then you have a check for any explosion, consulting the correct value in the array; finally, you use any result from exploded dice to generate another call to your rolling procedure, with appropriate looping in any applicable parts (does it continue to have advantage? does it continue to explode? etc.).
Thanks, timmaugh. That is what I was afraid of. I can use Scriptcards for programming some stuff, but the loops are not my specialty. I guess I can also do some roll and add a button to roll crit if apply. Anyway thanks again, I will see what I can do.
Hey Warlord, I may be able to help you with this part in ScriptCards if you want. I guess I would want to know, how do you want to signal the attack is with advantage? Do you always want to roll advantage or do you want to signal advantage somehow? So if you can list the manual steps out, that might be helpful. Something like: 1. Determine attacking with advantage by checking if status marker present on attacker/defender 2. Determine the weapon damage die by checking the weapon on the character sheet 3. Roll damage, including the advantage die 4. Check if the 1st kept die in the roll should explode 5. If explode, roll the die again and explode again if max 6. Check if the 1st kept die is a 1, if so, the attack misses 7. Display total damage rolled If you have a manual list, then I or someone else should be able to help you get this all together.
Thanks Joshua, I will post how I did my scriptcard below, but the idea is when I activate the macro the player will get a pop up to select Normal, Advantage, Advantage 2, Disadvantage or disadvantage 2. Normal attack has no issues I can make it work my problem start when I start adding dice for advantage or disadvantage. Also since you are looking at this I also have a question is there any way to make a button to apply the damage. Basically when I press the button it will ask for a target and apply dmg. Thanks for any help you can give me or direction. The example is for a Greatsword weapon attack but I think the theory should apply with some difference to attack spells. Also this code is just one idea of how to do it  !script {{   --#title|Greatsword   --&atk|?{Type of Attack?|Normal|Advantage|Advantage2|Disadvantage|Disadvantage2}   --? [&atk] -eq Normal| [     --=normal|2d6 --=crit|1d6!     --+Normal Attack Roll:|[$normal.Text] --+Total Damage:|[$normal] [Slashing] --+If Crit add:|[$crit]   --]|   --? [&atk] -eq Advantage| [     --=adv|3d6kh2 --=crit|1d6!     --+Attack Roll with Advantage:|[$adv.Text] --+Total Damage:|[$adv] [Slashing] --+If Crit add:|[$crit]   --]|   --? [&atk] -eq Advantage2| [     --=adv2|4d6kh2 --=crit|1d6!     --+Attack Roll with Advantage 2):|[$adv2.Text] --+Total Damage:|[$adv2] [Slashing] --+If Crit add:|[$crit]   --]|   --? [&atk] -eq Disadvantage| [     --=disadv|3d6kl2 --=crit|1d6!     --+Attack Roll with Disadvantage:|[$disadv.Text] --+Total Damage:|[$disadv] [Slashing] --+If Crit add:|[$crit]   --]|   --? [&atk] -eq Disadvantage2| [     --=disadv2|4d6kl2 --=crit|1d6!     --+Attack Roll with Disadvantage 2:|[$disadv2.Text] --+Total Damage:|[$disadv2] [Slashing] --+If Crit add:|[$crit]   --]| }}
So one way to apply damage to a token via ScriptCard is listed in  ScriptCards tutorial 1 This block takes a token id and the amount of damage to apply and will apply that to the target token's bar that is set at the top of the ScriptCard into the string variable `&HPBar` --:ApplyDamageToToken|TokenID;DamageToApply --!t:[%1%]|bar[&HPBar]_value:-=[%2%] --<| Then you call it with the token id and the damage amount like so: -->ApplyDamageToToken|[*T:t-id];[$DamageRoll] where in this case the damage is a roll variable and the token id comes from the `--#targetToken|@{selected|token_id}` parameter. So if you want a ScriptCard to prompt for a target, prompt for the amount of damage, and then apply that amount to a token's bar, here is a way to do that: !script {{ --/|CONFIGURATION VARIABLES --&HPBar|1 --#whisper|self --#title|Damage Applier --&TargetTokenID|@{target|token_id} --&Damage|?{How much damage|0} -->ApplyDamageToToken|[&TargetTokenID];[&Damage] --+|Applied [&Damage] to [*[&TargetTokenID]:t-name] --:Done| --X| --:ApplyDamageToToken|TokenID;DamageToApply --!t:[%1%]|bar[&HPBar]_value:-=[%2%] --<| }} Just need to adjust the &HPBar string variable at the top to whatever bar you use for health.
Hi, I got a question about XdYW dice roll. My question is if there is any way after rolling the dices make a call to look at the wild dice result only. ex. let's said I want to roll 4d4W, I want to be able to look at the wild dice and if it is a 1 it miss the attack.
Hi, me again trying to figure out how to make a macro for Nimble 5E. Now I think I'm close but I'm not an expert in coding. I need some one to give me an idea I got this code: --:disadvantage2|     --=DisDiceCount|2+[$DiceCount] --=dmg|[$DisDiceCount]d6kl[$DiceCount] --=halfdmg|[$dmg]/2 {FLOOR}     --=x|1 --+Dice Rolls|[$dmg.Text] --:Loop4| --?"[$dmg.RolledDice([$x])]" -inc "[x[$dmg.RolledDice([$x])]x]"|CheckDicePosition --?[$dmg.RolledDice([$x])] -eq 1|miss --?[$dmg.RolledDice([$x])] -eq 6|crit --+[$dmg.RolledDice([$x])]| --+[$x]| --+Monster Armor:|Any Armor --+Total Damage:|[$dmg] Radiant --+If the monster is resistance to Radiant damage:|You do Half damage [$halfdmg] Radiant --+If you Crit:|[$TotalCritDmg] Radiant --+[button]Apply Damage::!
#DMG[/button]| --X| --:CheckDicePosition| --=x|[$x]+1 --?[$x] -le [$DiceCount]|Loop4 --X| I know what is wrong, (I think). So in this code x represent the position of the dice on the roll. So when I put --=x|1 is so [$dmg.RolledDice(x)] position 1 in the dice roll. The problem I have is that I need to check if [$dmg.Text] Position 1 [$dmg.RolledDice(x)], contain [x#x]. Whit this I can make a loop so x increased to 2 and then check position 2. Once it gets to a position where it does not contain [x#x], it should check if the position is a 1 (min) or 6 (Max), and complete the program. The card work as intended for the most part, the only part I haven't make it work is to check for eliminated rolls in the dice formula. Any help or suggestions anyone can give me is appreciated. Thanks in advance. Warlord
Hey Warlord, Since it looks like you are trying to skip the dropped, I think you should probably not use RolledDice roll modifier and use the KeptDice modifier . The so that format of xNUMx only appears in the .Text modifier. The numbers in the RolledDice array do not show up with that. They are just straight integers. Example: !script {{ --=dmg|4d6kl2 --+|[$dmg.Text] --%i|1;4 --+Roll [&i]|[$dmg.RolledDice([&i])] --%| }} You can see the 4 and 3 are just plain integers in the RolledDice array. Another example showing the other roll modifiers of KeptDice and DroppedDice: !script {{ --=dmg|4d6kl2 --+|[$dmg.Text] --~|array;fromrollvar;RolledArr;dmg;rolled --~|array;fromrollvar;KeptArr;dmg;kept --~|array;fromrollvar;DroppedArr;dmg;dropped --~rolledList|array;stringify;RolledArr;, --~keptList|array;stringify;KeptArr;, --~droppedList|array;stringify;DroppedArr;, --+Rolled|[&rolledList] --+Kept|[&keptList] --+Dropped|[&droppedList] }} So for your code snippet you pasted, I would change from using RolledDice([$x]) to using KeptDice and then you can get rid of that conditional that checks if it's dropped ` --?"[$dmg.RolledDice([$x])]" -inc "[x[$dmg.RolledDice([$x])]x]"|CheckDicePosition`
Thanks, For the response, One question How do I now verify that the first number kept is a 1 or 6?
These lines get changed:          --?[$dmg.RolledDice([$x])] -eq 1|miss --?[$dmg.RolledDice([$x])] -eq 6|crit to          --?[$dmg.KeptDice(1)] -eq 1|miss --?[$dmg.KeptDice(1)] -eq 6|crit If all you care about is the first die, then you don't need to loop. You just check the first value. In a bit of ScriptCard confusing things, in regular arrays, ScriptCards starts at 0, but with those dice modifiers, they start at 1. So if you want to check the first value in kept, then KeptDice(1) works.
Ok, Thanks so much Joshua, I came up with other solution not this elegant but I will change to this is a lot nicer. Thanks again for your Help.
Hi, Has anyone developed a scriptcard that will list the token markers already applied on a targeted token and is willing to share ? Hope that makes sense and thanks in advance
Hey FFR,  If you have a target token designated with #targetToken, you can retrieve any markers on the token with [*T:t-statusmarkers].
1758249029
Andrew R.
Pro
Sheet Author
Check the System Neutral Library for its Token Marker support.
Guys, Thanks for your help. I haven't been able to figure this out. Any chance of a sample scriptcard ?
FFR, If you just want to list status markers and that is it, there is a built-in array function `statusmarkers` which will return an array to loop over. !script {{ --#targetToken|@{target|token_id} --#whisper|self --#title|[*T:t-name] Status List --~|array;statusmarkers;TargetMarkers;[*T:t-id] --?"[@TargetMarkers(length)]" -eq 0|Done --%status|foreach;TargetMarkers --+|[&status] --%| --:Done| --X| }} If you want to manipulate status markers, I second Andrew's recommendation of using Kurt's system neutral library
Joshua, Just needed a list. You're script card is perfect and thanks for sharing