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

1673180268
David M.
Pro
API Scripter
Use the {CLAMP:min:max} expression immediately after the roll you want to clamp. Look in the wiki under the section labeled " Mathematical Functions in Roll Expressions " for more info. You can type the min/max values directly or use other roll variables, like this !script {{ --=min|2 --=max|6 --=roll|1d10 {CLAMP:[$min]:[$max]} --+roll|[$roll] }}
Awesome, just what I was looking for, must've missed that section when looking through the wiki, thanks!
So for some reason this works on its own !script {{ --#hideTitleCard|1 --!t:@{selected|token_id}|bar1_value:-=1 --?@{selected|bar1} -lt 1 | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green:1 --]|[ ]| }} but not when !script {{ --#hideTitleCard|1 --!t:@{selected|token_id}|bar1_value:-=1 --=FP|@{selected|Fatigue|max}/2 + 1 --=FP0|@{selected|Fatigue|max}/4 + 1 --?@{selected|bar1} -le [$FP] | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green --]|[ ]| --?@{selected|bar1} -le [$FP0] | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green:0 --]|[ ]| --?@{selected|bar1} -lt 1 | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green:1 --]|[ ]| }} What should happen here is when Fatigue is equal under 5 (one half of max), green dot is applied. If it is equal/under 2.5 green:0 should apply, if under 0, green:1 should apply.  It works at first, but noy green:0. I tried changing up the sequence and it looks that the middle If-Then gets ignored for some reason.
With some trial and erro I got this to work !script {{ --#hideTitleCard|1 --!t:@{selected|token_id}|bar1_value:-=1 --=FP|@{selected|Fatigue|max}/2 + 1 --=FP0|@{selected|Fatigue|max}/4 + 1 --?@{selected|bar1} -le [$FP0] | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green:0 --]|[ ]| --?@{selected|bar1} -le [$FP] | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green --]|[ ]| --?@{selected|bar1} -le 0 | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green:1 --]|[ ]| }} but not when incorporated in the full script: !script {{ --#hideTitleCard|1 --#nominmaxhighlight|1 --=3d6|@{selected|Dodge}+?{mod}-3d6+@{selected|Bonus}[Bon] --+♦ @{selected|token_name}| Dodges [$3d6] . . . [rbutton]Retreat::Retreat[/rbutton] [rbutton]Feverish Defense::Defense[/rbutton] --+|Extra +1 when defending limbs or head, +2 for feet, hands, face. --=FP|@{selected|Fatigue|max}/2 + 1 --=FP0|@{selected|Fatigue|max}/4 + 1 --X| --:Retreat| --+@{selected|token_name}| spends 1 FP to Retreat +3 --!t:@{selected|token_id}|bar1_value:-=1 --=FP|@{selected|Fatigue|max}/2 + 1 --=FP0|@{selected|Fatigue|max}/4 + 1 --?@{selected|bar1} -le [$FP0] | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green:0 --]|[ ]| --?@{selected|bar1} -le [$FP] | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green --]|[ ]| --?@{selected|bar1} -le 0 | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green:1 --]|[ ]| --X| --:Defense| --+@{selected|token_name}| spends 1 FP for Feverish Defense +2. --!t:@{selected|token_id}|bar1_value:-=1 --=FP|@{selected|Fatigue|max}/2 + 1 --=FP0|@{selected|Fatigue|max}/4 + 1 --?@{selected|bar1} -le [$FP0] | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green:0 --]|[ ]| --?@{selected|bar1} -le [$FP] | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green --]|[ ]| --?@{selected|bar1} -le 0 | [--@token-mod| _ids @{selected|token_id} _set statusmarkers|green:1 --]|[ ]| }}
1673726869
Kurt J.
Pro
API Scripter
ScriptCards 2.2.4d is now Live on OneClick The latest version of ScriptCards is now live on OneClick. Below is a summary of the changes since 2.2.0: Looping information is now stashed with the other information that is saved when a script is interrupted for --i or [rbutton] constructs, meaning that a loop can surround one of these structures and the information about that loop will still be active when the script is resumed. Expanded string referencing now allows "word" as a selector: [&MyString(word,4)] will return the 4th word (as separated by spaces) in the word. Negative word number will return words starting at the end of the string (-1 would be the last word for example), and 0 will return the whole string. Added "before" and "after" as expanded string referencing selectors. Each will return the portion of the string either before or after the supplied substring. ex: [&Line(before,Fox)] Added fromtable as an array creation source, which will return the values in a rollable table as an array. Added --\ as a command type, which will log anything after the vertical bar to the API console (ex: --\|Hello World!) It is now possible to directly compare two empty strings (eg, --?"" -eq "", or --?"[&MyVariable]" -eq "") and get the proper result. No more resorting to adding dummy characters to test against sheet attributes that return nulls It is now possible to use math functions (like {MIN:X}) in ScriptCards inline roll references ([=...]) Any parameter that sets a color (like oddrowbackground, etc.) will now check to see if it is getting set to a 3, 6, or 8 digit hex number without a leading hash symbol and will add one as needed. New dice rolling formula: XuY, which will roll X dice with Y sides but always return unique results. If X is greater than Y, X will be reduced to Y. Example: 4u8 will roll d8s until four unique values are obtained and return those values as the dice results. New dice rolling formula: XmY, which will roll X dice with Y sides but always return Y on each die. The hover over text will indicate that this was done, and the console log will alert you when a user uses this formula.  Added the {PAD:X} roll modifier, which will pad the roll output when displayed as either Total or Raw with leading zeros so the output is at least X characters long. Added setting: #explodingonesandaces. If set to 1, exploding dice will count 1's and Max counts throughout the roll and rerolls. Extended the [F]...[/F] inline formatting syntax to allow a font to be specified. You can now use [F:fontname:fontsize]...[/F] which will create a span (instead of a div) changing the font name and size for that span. Technically the size can be left out, but the results may then be browser dependent on what happens when blank font size is used. The [F##]...[/F] structure remains unchanged and creates a div with the new font size in the current font. For additional details and for updated versions before they come to OneClick, check out the ScriptCards GitHub
Hi again! If I use the --!a command to modify an attribute, and that attribute does not exist, If I have it set to create an attribute, it doesn't add properly. For instance: --!a:@{selected|token_id}|!Luck:+=1 Would create the Luck stat if it does not exist, but when doing so it will set its value to "+=1" instead of just "1". Is that the intended behaviour and if so, is there another workaround?
I guess with the new patch I can check if the variable exists at the start of the card by comparing it to an empty string, and if it matches I can set it to 0, but still curious if it is intended behaviour or not
1673904108
Kurt J.
Pro
API Scripter
Cindurion said: I guess with the new patch I can check if the variable exists at the start of the card by comparing it to an empty string, and if it matches I can set it to 0, but still curious if it is intended behaviour or not It isn't the intended behavior, just a situation I never tried out :) I'll fix and plan an update for the next release.
I have been converting my character sheet into CSE compliant and have run into an interesting bug.  I am not sure if it is unique to ScriptCards or some strange quirk or limitation of roll20. I have scriptCards macro contained in a textarea (visible so that the players can edit it or swap out their own macro).  However, when the text area is called as part of a roll it the parsing engine in chat entirely clips the last few lines of the script cards.  The text of the script cards is as follows: <textarea class="macro-text" title="@{repeating_weapon_$X_wHitRoll}" name="attr_wHitRoll">!scriptcard {{ --/| === ScriptCard Layout for Attack Rolls === |\-- --/| === Version 1.0                        === |\-- --/| === Date: 01/17/2023                   === |\-- --/| Local Variables --|\ --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --/| ===== Roll Queries / Information Lookup =========== |\ --&AimType|?{Aim | No aim (+0),+0 | Half aim (+10),+10| Full aim (+20),+20} --=AimTypeNum|[&AimType] --&RoFType|?{Rate of Fire/Attack Type| Standard (+0),+0 | Semi auto (+10),+10 | Full Auto (+20),+20 | Called Shot (-20),-20 | Suppressing Fire (-20),-20} --&AtkMod|?{Modifier|0} --/| ===== Convert RQ Value into int variables --=AtkModNum|[&AtkMod] --=AimTypeNum|[&AimType] --=RangeNum|[&RangeType] --=RoFNum|[&RoFType] --/| ===== Strings =========== |\ --&DmgRoll|@{damage} --/| ========== Numbers ============= |\ --=Clip|[*T:clip] --=ClipMax|[*T:clip^] --=Clip| $Clip --=Clip Max|$ClipMax --=AtkType|0 --/| ===== Weapon Proficiency Full Display =========== |\ --?@{wProficiency} -eq Yes|Yes --?@{wProficiency} -eq No|No --:Yes| --&wProficiency|Yes --^wProficiencyDisplayDone| --:No| --&wProficiency|No --^wProficiencyDisplayDone| --:wProficiencyDisplayDone| --/| ===== DAMAGE TYPE Full Display =========== |\ --?@{wType} -eq E|E --?@{wType} -eq I|I --?@{wType} -eq R|R --?@{wType} -eq X|X --?@{wType} -eq N|N --:E| --&DmgTypeDisplay|Energy --^DMGTypeDone| --:I| --&DmgTypeDisplay|Impact --^DMGTypeDone| --:R| --&DmgTypeDisplay|Rending --^DMGTypeDone| --:X| --&DmgTypeDisplay|Explosive --^DMGTypeDone| --:N| --&DmgTypeDisplay|None --^DMGTypeDone| --:DMGTypeDone| --/| ===== Weapon Type Full Display =========== |\ --?@{wClass} -eqi basic|Basic --?@{wClass} -eqi heavy|Heavy --?@{wClass} -eqi melee|Melee --?@{wClass} -eqi pistol|Pistol --?@{wClass} -eqi thrown|Thrown --:Basic| --&wClassDisplay|Basic --&AtkType|[*S:bs-base] [BS] --^wClassDisplayDone| --:Heavy| --&wClassDisplay|Heavy --&AtkType|[*S:bs-base] [BS] --^wClassDisplayDone| --:Melee| --&wClassDisplay|Melee --&AtkType|[*S:ws-base] [WS] --=AimTypeNum|0 --&AimType|0 --&MeleePenalty|-30 --^wClassDisplayDone| --:Pistol| --&wClassDisplay|Pistol --&AtkType|[*S:bs-base] [BS] --^wClassDisplayDone| --:Thrown| --&wClassDisplay|Thrown --&AtkType|[*S:bs-base] [BS] --^wClassDisplayDone| --:wClassDisplayDone| --/| ===== Numbers =========== |\ --=DmgPen|@{penetration} --=RollDamage|@{damage} --=clip|@{clip} --=clipMax|@clip|max} --/| ===== Functions =========== |\ --~sqRange|distance;@{selected|token_id};@{target|token_id} --=Range|[$sqRange] [Squares] * 1 [meters] --=RoFNum|[&RoFType] --?[$Range] -le 3|RngPB --?[$Range] -ge 3 -and [$Range] -le @{range-s}|RngShort --?[$Range] -ge @{range-s} -and [$Range] -le @{range-n}|RngNormal --?[$Range] -ge @{range-n} -and [$Range] -le @{range-m}|RngMed --?[$Range] -ge @{range-m} -and [$Range] -le @{range-l}|RngLong --?[$Range] -ge @{range-e}|RngExtreme --:RngPB| --&AtkRange|30+[&MeleePenalty] [Point Blank] --&RngDisplay|Point Blank --^RngDone|Done --:RngShort| --&AtkRange|10 [Short] --^RngDone|Done --&RngDisplay|Short --:RngNormal| --&AtkRange|0 [Normal] --&RngDisplay|Normal --^RngDone|Done --:RngMed| --&AtkRange|0 [Medium] --&RngDisplay|Medium --^RngDone|Done --:RngLong| --&AtkRange|-10 [Long] --&RngDisplay|Long --^RngDone|Done --:RngExtreme| --&AtkRange|-30 [Extreme] --&RngDisplay|Extreme --^RngDone|Done --:RngDone| --/ ======== Range Bonus Calculations ======== |\ --#title|@{atkName} --#titlecardbackground|#993333 --#leftsub|[$Range] m. [&RngDisplay] --#rightsub|Ammo @{clip}/@{clip|max} --#emoteText|[*S:t-name] attacks [*T:t-name] --/| ===== Special Qualites that effect the attack roll ====== |\ --/| ===== ACCURATE QUALITY =========== |\ --?[$AimTypeNum] -gt 0 -and @{q-accurate} -eq 1|Accurate --?[$AimTypeNum] -eq 0 -or  @{q-accurate} -eq 0|NoAccurate --:Accurate| --&AtkAccurate|10 [Accurate] --^AccurateDone| --/| Fail Catch not working..... --:NoAccurate| --&AtkAccurate| --^AccurateDone| --:AccurateDone| --/| ===== Inaccurate QUALITY =========== |\ --/| @@ DETAILS: This overides the AIMTYPE variable to ZERO (0) instead of adding a new component to the AtkTarget string. --?@{q-inaccurate} -eq 1|Inaccurate --?@{q-inaccurate} -eq 0|NoInaccurate --?@{q-defensive} -eq 1|Defensive --?@{q-defensive} -eq 0|NoDefensive --:Inaccurate| --&AimType|0 --^InaccurateDone| --:NoInaccurate| --^InaccurateDone| --:InaccurateDone| --?@{q-defensive} -eq 1|Defensive --?@{q-defensive} -eq 0|NoDefensive| --:Defensive| --&AtkDefensive|-10 [Defensive] --^DefensiveDone| --:NoDefensive| --&AtkDefensive|0 --^DefensiveDone| --:DefensiveDone| --=AtkTarget|[&AtkType] + [&AimType] [Aim] + [&AtkAccurate] [Accuracy] + [&AtkRange] + [&RoFType] [Rate of Fire] + [&AtkDefensive] + [&AtkMod] [Modifier] --=AtkRoll|1d100 --&BodyHit|Null --=DegSuccess|[$AtkTarget] - [$AtkRoll] \ 10 --/| === WEAPON DETAILS === --+|[c]● Weapon Details ●[/c] --+[t border=1 width=100%][tr][td][c]Class[/c][/td][td][c]Type[/c][/td][td][c]Damage[/c][/td][td][c]Pen[/c][/td][/tr][tr][td][c][&wClassDisplay][/c][/td][td][c][&DmgTypeDisplay][/c][/td][td][c]@{damage}[/c][/td][td][c][$DmgPen][/c][/td][/tr][/t]| --/| === Roll Details Tables --+|[c]● Roll Details ●[/c] --+[c][t border=2 width=95% align=center][tr][td][b]Skill    [/b][/td][td][b]Aim      [/b][/td][td][b]Range    [/b][/td][td][b]RoF      [/b][/td][td][b]Modifier [/b][/td][/tr][tr][td][&AtkType][/td][td][&AimType][/td][td][&AtkRange][/td][td][&RoFType][/td][td][&AtkMod][/td][/tr][/t][/c]| --/| ======= Test Output for Debugging (Hide When Code is Complete)  ======== --/|[c][t border=2 width=95% align=center][tr][td][b]Skill    [/b][/td][td][b]Aim      [/b][/td][td][b]Range    [/b][/td][td][b]RoF      [/b][/td][td][b]Modifier [/b][/td][/tr][tr][td]XX[/td][td][$AimTypeNum][/td][td][$RangeNum][/td][td][$RoFNum][/td][td][$AtkModNum][/td][/tr][/t][/c]| --+|[c][t border=2 width=95% align=center][tr][td][b]Total  [/b][/td][td][b]Target [/b][/td][/tr][tr][td][$AtkRoll]   [/td][td][$AtkTarget] [/td][/tr][/t][/c] --/| ====== Count the Number of Allowed Attacks --/| The Rate of fire is 1 + [Rate of Fire Modifier] + [Scatter Modifier] * [Storm Weapon Modifier] --/| Rate of Fire Mods -> --/| Automatic                  = 1 per 1 degrees of success --/| Semi-Automatic             = 1 per 2 degrees of success --/| Point-Blank + Scatter      = Base * 2 --/| Storm (Blood of Martyrs)   = Base * 2 (Doubles the Number of Shots Fired) --/| The number of extra shots fired is cannot exceed the number of rounds in the gun (its overall rate of fire) or charge capacity for energy weapons. --/| Regardless of successful hits the amount of ammo expended is 1 per shot fired. --/| ====== Check And Assign Number of Attacks based on rate of fire. --/| Number of Attacks  - Addititve --?[$RoFNum] -le 0|NoExtra --?[$RoFNum] -eq 10 -and [$DegSuccess.Total] -ge 0|SemiAuto --?[$RoFNum] -eq 20 -and [$DegSuccess.Total] -ge 0|FullAuto --:SemiAuto| --=MaxAtk|@{rof2} --=RoFMod|[$DegSuccess.Total] [Successes] / 2 {CEIL} {MAX:@{rof2}} [Semi Auto] --^RoFDone| --:FullAuto| --=MaxAtk|@{rof3} --=RoFMod|[$DegSuccess.Total] [Successes] / 1 {CEIL} {MAX:@{rof3}} [Full Auto] --^RoFDone| --/| Reserved for possible Future Use and Error Checking --:NoExtra| --=MaxAtk|@{rof1} --=RoFMod|0 [No Extra Attacks] --^RoFDone| --:RoFDone| --/| ====== Check if the number of sucesses is at least 0 (a non-negative number) --?[$DegSuccess.Total] -le -1|DegDone --?[$DegSuccess.Total] -ge 0|Continue --:Continue| --=NumAtkBase|1 --^DegDone| --/| ==== Reserved for possible Future Use and Error Checking --:DegError| --^DegDone| --:DegDone| --/| Number of Attacks  - Multiplicative  --=NumAtks|[$NumAtkBase.Total] [Base] + [$RoFMod.Total] [Rate of Fire] --/| ====== Check and assign number of attacks based on SCATTER and RANGE. --/| @@ DETAILS: It is set to "30" because the output of the Roll Query is +30, as in thats how much the bonus to hit is. --/| @@ DETAILS: The equation basically is checking if the range is Point Blank and is Scatter selected. --?[$RangeNum] -ge 30 -and @{q-scatter} -eq 1|Scatter --?[$RangeNum] -lt 30 -or @{q-scatter} -eq 0|NoScatter --:Scatter| --=NumAtkScatter|[$NumAtks] * 2 --^ScatterDone| --:NoScatter| --=NumAtkScatter|0 --^ScatterDone| --:ScatterDone| --/| ====== Check and assign number of attacks based on STORM --?@{q-storm} -eq 1|Storm --?@{q-storm} -eq 0|NoStorm --:Storm| --=MaxAtk|[$MaxAtk]*2 --=NumAtkStorm|[$NumAtks] * 2 --^StormDone| --:NoStorm| --=NumAtkStorm|0 --^StormDone| --:StormDone| --+[c] ●  Number of HITS  ● [/c]| --=NumAtksTotal|[$RoFMod] [RoF] + [$NumAtkBase.Total] [Base] + [$NumAtkScatter] [Scatter] + [$NumAtkStorm] [Storm] {MAX:[$MaxAtk]}     --/| +Num|[$RoFMod] [RoF] + [$NumAtkBase.Total] [Base] + [$NumAtkScatter] [Scatter] + [$NumAtkStorm] [Storm] =  --+|[c][b][$NumAtksTotal.Total][/b][/c] --/| ====== Check if AttackRoll is less than the test THRESHOLD --?[$AtkRoll.Total] -le [$AtkTarget.Total]|Success --?[$AtkRoll.Total] -gt [$AtkTarget.Total]|Failure --:Success| --+[c][#3FB315]HIT! ([$DegSuccess.Total])[/#][/c]| --^Done| --:Failure| --+[c][#B31515]MISS! ([$DegSuccess.Total])[/#][/c]| --^Done| --:Jam| --+[c]JAM![/c]| --^Done| --:Done| --?[$AtkRoll] -lt 10|[ --&rollStr|0[$AtkRoll.Raw] --]|[ --&rollStr|[$AtkRoll.Raw] --]| --~len|string;length;[&rollStr] --%i|[$len];1;-1 --~s|string;substring;[&i];1;[&rollStr] --&revStr|+[&s] --%| --=revRoll|[&revStr] --/| === Out of Range Values Included for Debugging === --?[$revRoll] -le 0|>SetHitLocation;Error - Out of Range --?[$revRoll] -le 10|>SetHitLocation;Head --?[$revRoll] -ge 11 -and -le 20|>SetHitLocation;Right Arm --?[$revRoll] -ge 21 -and -le 30|>SetHitLocation;Left Arm --?[$revRoll] -ge 31 -and -le 70|>SetHitLocation;Body --?[$revRoll] -ge 71 -and -le 85|>SetHitLocation;Right Leg --?[$revRoll] -ge 86|>SetHitLocation;Left Leg --?[$revRoll] -ge 101|>SetHitLocation;Error - Out of Range --+[c][b][#3FB315][&BodyHit][/#][/b][/c]| --X| End Macro --:PROCEDURES| --:SetHitLocation| accepts hit location as parameter     --&BodyHit|[%1%] --<|  }} </textarea> Everything after:  --<| is removed from the code when rolled so when the roll button is pressed it just shoves like 60 lines of text to the chat window.  This is really REALLY annoying, especially since it didnt happen before.  I was wondering if it was something with a new version of the script cards or as part of converting it to CSE?
1673963926
timmaugh
Pro
API Scripter
You might need to encode that open caret (left arrow)... good chance it is tripping the parser into thinking that everything that follows is an HTML tag.
Alright so.. using the escape code --<| instead of -->| functioned.  However, I do have a question still.  Why is this breaking?  I have this combination of symbols elsewhere in my code and it doesnt break.  Is it a ScriptCards error or a roll20 error is it a problem with how CSE is parsed vs. Legacy?  I am interested in understanding how this error came up so I can avoid it in the future...
1673999799
Kurt J.
Pro
API Scripter
Toby said: Alright so.. using the escape code --<| instead of -->| functioned.  However, I do have a question still.  Why is this breaking?  I have this combination of symbols elsewhere in my code and it doesnt break.  Is it a ScriptCards error or a roll20 error is it a problem with how CSE is parsed vs. Legacy?  I am interested in understanding how this error came up so I can avoid it in the future... I couldn't really answer that, as I have done zero character sheet development, but given that it looks like an opening html tag, I would guess the parsing of CSE (not even sure what that is) is misinterpreting it. ScriptCards never gets involved because without the }} the command isn't a valid API call to ScriptCards, so it just gets ignored (which is why you see all the code lines in chat).
1674002895
Andrew R.
Pro
Sheet Author
Character Sheets usually don’t use the Mod system so you may be on untested ground. 
1674149817

Edited 1674149942
timmaugh
Pro
API Scripter
Not sure, but I think it's in how the textarea control handles its content. For instance, if you typed a "<" character into the textarea then read the contents of the field, you'd likely see "<". It automatically renders the supplied content for display, so when you type, it's doing the reverse (and de-rendering the display of "<" to the html encoding). In your case, the raw content it is rendering includes the "<" which is going to act like an HTML control character... It's in the raw, supplied data, not in the rendered "display data"... if that makes sense. In any case, not a Roll20 thing. More of a whole-web thing.
I'm having a problem with the case statement. The program segment should look like this:   --=nlang|[[1d4]]   --C[$nlang]|1:⟨hindi|2:⟨medieval|3:⟨sanskrit|4:⟨thai   --@namegen|[&lang] } When I leave the program and come back in it looks like this:   --=nlang|[[1d4]]   --C[$nlang]|1:⟨hindi|2:⟨medieval|3:⟨sanskrit|4:⟨thai   --@namegen|[&lang] } I copy the entire program and paste it into an outside editor, correct the line, copy it, paste the corrected program into Roll20 and save it. When I open it up it has reverted.  Any ideas what is going on?
James B. said: I'm having a problem with the case statement. The program segment should look like this:   --=nlang|[[1d4]]   --C[$nlang]|1:⟨hindi|2:⟨medieval|3:⟨sanskrit|4:⟨thai   --@namegen|[&lang] } When I leave the program and come back in it looks like this:   --=nlang|[[1d4]]   --C[$nlang]|1:⟨hindi|2:⟨medieval|3:⟨sanskrit|4:⟨thai   --@namegen|[&lang] } I copy the entire program and paste it into an outside editor, correct the line, copy it, paste the corrected program into Roll20 and save it. When I open it up it has reverted.  Any ideas what is going on? I don't think I'll be able to help you, but you may wanna give some more info so others can give help! Where is it you're putting the code? Does it happen immediately when you refresh or is it after some time?
Also, I'm looking for help with regards to coloring the output of a scriptcard. Back with Powercards, if you didn't specify a color it defaulted to the color of the player's picked color, but it seems like scriptcards default to red? Is there any way to replicate that old behaviour aside from setting up the formating list I noticed in the scriptcards wiki? Ideally in such a way that it updates if the player changes their colors!
1674476066
David M.
Pro
API Scripter
James, not sure exactly what is going on here. Maybe try editing in a "dumb" editor like Notepad just to make sure that there are no weird invisible characters injected into your text? Cindurion, there are several settings for changing the style of individual components of the output card, found here . To incorporate player color into the formatting, here's an approach: Set the selected token for easier referencing using --#sourcetoken|@{selected|token_id} Get the playerID from the controlledby property of the token using [*S:controlledby]. Note that if multiple players control the token, you'll have to parse the comma-delimited list. If all players control, this property value will be "all" and not very helpful so you'll need to fall back on a default color  Use "Object Attribute Referencing" with this format [*O:ObjectID:ObjectType:PropertyName] to get the "color" property associated with that playerID. A description of the various object properties can be found here . If your id was stored in a string variable named "playerID", this would be something like   --&playerColor|[*O:[&playerID]:player:color] Use your playerColor string variable in a parameter setting, such as --#bodyfontface|[&playerColor]
1674514596
Kurt J.
Pro
API Scripter
Cindurion said: Also, I'm looking for help with regards to coloring the output of a scriptcard. Back with Powercards, if you didn't specify a color it defaulted to the color of the player's picked color, but it seems like scriptcards default to red? Is there any way to replicate that old behaviour aside from setting up the formating list I noticed in the scriptcards wiki? Ideally in such a way that it updates if the player changes their colors! The simplest thing to do would be to add :   --#titlecardbackground|#[*O:[&SendingPlayerID]:player:color] Near the top of your scripts, which will colorize the title bar of any card a player sends with their color. It is not a thorough as David M's solution of looking up the selected token's controlled by and parsing the player from that, but it will work 99% of the time.
For some reason this very simple code does not work. If the roll is zero or greater, it should skip the 'lose 2 fatigue', yet it does not. !script {{ --#hideTitleCard|1 --#nominmaxhighlight|1 --=3d6|@{selected|HT}-3d6+333 --?[$3d6] -ge 0|Skip --+@{selected|token_name}’s| struggles to stay standing with HT[$3d6] and loses 2 Fatigue. --!t:@{selected|token_id}|bar1_value:-=2 --X| --Skip| --+@{selected|token_name}| succeeds to stay standing with HT[$3d6] }}
1674562548
David M.
Pro
API Scripter
Kaspar, your Skip label is missing a colon, so it's not being recognized as a label. Should be: --:Skip|
The reason I mentioned using an outside editor was to indicate I was aware of the need to use a dumb editor. I should have mentioned it was dumb. As to speed it is immediate. I saved the new program and immediately opened it and checked the section and it had changed. The code is in a Hunt program in Vampire the Dark Ages which I'm creating. It merely gives a name to the victim.
Hi everyone, I want to read the bar1_max value of a target token. The following works fine for bar1 value, but not for bar1 max value . What am I doing wrong? !script {{   --#targetToken|@{target|token_id}   --+Current bar1 value:|@{target|bar1}   --+Current bar1 max value:|@{target|bar1|max} }} No attribute was found for @{TARGET:bar1|max}   ScriptCards Current bar1 value: 30 Current bar1 max value: TARGET:bar1|max|max
1674935152
David M.
Pro
API Scripter
Try adding the text prompt part of the reference, something like @{target|select a target|bar1|max} Note that since you are using #targetToken, you can also directly reference the token values using [*T:t-property] syntax. See example below comparing the two methods: !script {{ --#targetToken|@{target|click a target|token_id} --+Current bar1 value:|@{target|click a target|bar1} --+Current bar1 max value:|@{target|click a target|bar1|max} --+Current bar1 value:|[*T:t-bar1_value] --+Current bar1 max value:|[*T:t-bar1_max] }}
1674955227

Edited 1675024558
I'm using sheetbuttons to create an array to choose abilties on a Mule called Disciplines. The script is !script {{   --#overridetemplate|scroll   --&Name|@{selected|character_name}    --#title|Disciplines --+|[t border=2 width=100%][tr][td] [sheetbutton:#0f0:#000]Animalism::Disciplines::Animalism[/sheetbutton] [/td][td][sheetbutton:#0f0:#000]Auspex::Disciplines::Auspex[/sheetbutton][/td][td][sheetbutton:#0f0:#000]Celerity::Disciplines::Celerity[/sheetbutton][/td][td][sheetbutton:#0f0:#000]Chimerstry::Disciplines::Chimerstry[/sheetbutton][/td][/tr] [tr][td] [sheetbutton:#0f0:#000]Dominate::Disciplines::Dominate[/sheetbutton] [/td][td][sheetbutton:#0f0:#000]Fortitude::Disciplines::Fortitude[/sheetbutton][/td][td][sheetbutton:#0f0:#000]Obfuscation::Disciplines::Obfuscation[/sheetbutton][/td][td][sheetbutton:#0f0:#000]Obtenebration::Disciplines::Obtenebration[/sheetbutton][/td][/tr] [tr][td] [sheetbutton:#0f0:#000]Potence::Disciplines::Potence[/sheetbutton] [/td][td][sheetbutton:#0f0:#000]Presence::Disciplines::Presence[/sheetbutton][/td][td][sheetbutton:#0f0:#000]Protean::Disciplines::Protean[/sheetbutton][/td][td][sheetbutton:#0f0:#000]Thaumaturgy::Disciplines::Thaumaturgy[/sheetbutton][/td][/tr][/t] }} The script works fine when I run it as gm. When I run it as a player it fails: No ability was found for %{-NHuXbAFeMY0O52X96eT|Auspex} James B.: -NHuXbAFeMY0O52X96eT|Auspex In fact the token i used 'as a player' was the same I used as gm when it ran properly. I also created a separate player from a different email since I know the 'as a player' doesn't always show what a player sees, but I get the same problem. The Mule named Disciplines is set to permit all players to edit it.  The ID is the id of the Mule named Disciplines. (I went back and checked.) But why doesn't the sheetbutton open the ability when I'm a player but does when I'm a gm? Obviously it is permissions. As gm I have permission for everything, but I've given control of the Mule named Disciplines to 'All Players' so why don't the players have control? Never mind. I just went back and put the Disciplines Mule icon on the board and moved it with my regular player to make sure it had control and the icon moved as expected. I then tried the Disciplines again and this time it worked. Did it work because the Disciplines icon was on the board? I removed the icon and tried again. It worked again. I had not changed anything except to add the Mule icon to the board. Do the mule icons have to appear on board once at the beginning of a session? Or is there perhaps a period of time which has to elapse when changes are made before they propagate through the network? I had noticed problems as I was developing programs which suggested these possibilities. However I was making so many changes that I could never be sure what was causing these anomalies.  Further testing reveals that just opening the Mule and closing it is sufficient to get the program allow the player's to operate the sheetbuttons. There is no need to pull the Mule icon onto the board. However that has to be done by each player on their own game. Doing it on the gm's game does not allow players to use their sheetbuttons. Any ideas what is going on?
Thx. i will give it a try. David M. said: Try adding the text prompt part of the reference, something like @{target|select a target|bar1|max} Note that since you are using #targetToken, you can also directly reference the token values using [*T:t-property] syntax. See example below comparing the two methods: !script {{ --#targetToken|@{target|click a target|token_id} --+Current bar1 value:|@{target|click a target|bar1} --+Current bar1 max value:|@{target|click a target|bar1|max} --+Current bar1 value:|[*T:t-bar1_value] --+Current bar1 max value:|[*T:t-bar1_max] }}
Can anyone give me any pointers?.... I have checked out the wiki on loops and really can't figure out how to get this card to do what I want it to do.... Currently the card works and puts out 1 random item "fruit" from my array... However, I would like it to roll let's say a 1d4 for the number of times to go through the array and randomly selecting each possibilities and outputting them in the sentence... so a roll of 2 would output 2 fruit, etc.... I just don't now where, what & how the loop would be written on the following script to make it work..... see script [10:45 PM] !script {{   --:Fruit Stand|     --~|array;define;FRUIT;Lemons;Pears;Plums;Apples;Cherries;Peaches;Dates     --=FRUIT|1d[@FRUIT(length)] - 1     --&FRUIT|[@FRUIT([$FRUIT.Raw])]     --+|This Fruit stand is run by a male human , who also sells fresh [&FRUIT] for 1 cp each. }}
1675602259
David M.
Pro
API Scripter
Something like this? !script {{ --~|array;define;FRUIT;Lemons;Pears;Plums;Apples;Cherries;Peaches;Dates --=numFruit|1d4 --=allItems|[$numFruit.Raw]u[$numFruit.Raw] --+|This Fruit stand is run by a male human, who sells: --%i|1;[$numFruit.Raw];1 --=itemIndex|[$allItems.RolledDice([&i])] - 1 --+[@FRUIT([$itemIndex.Raw])]| for 1cp each --%| }}
Hola, Does anyone know if the RollStats API script works for Scriptcards rolls? thx much
1675818039

Edited 1675818146
James, he script works fine when I run it as gm. When I run it as a player it fails: James B.: -NHuXbAFeMY0O52X96eT|Auspex In fact the token i used 'as a player' was the same I used as gm when it ran properly. I also created a separate player from a different email since I know the 'as a player' doesn't always show what a player sees, but I get the same problem. The Mule named Disciplines is set to permit all players to edit it.  The ID is the id of the Mule named Disciplines. (I went back and checked.) But why doesn't the sheetbutton open the ability when I'm a player but does when I'm a gm? Obviously it is permissions. As gm I have permission for everything, but I've given control of the Mule named Disciplines to 'All Players' so why don't the players have control? Never mind. I just went back and put the Disciplines Mule icon on the board and moved it with my regular player to make sure it had control and the icon moved as expected. I then tried the Disciplines again and this time it worked. Did it work because the Disciplines icon was on the board? I removed the icon and tried again. It worked again. I had not changed anything except to add the Mule icon to the board. Do the mule icons have to appear on board once at the beginning of a session? Or is there perhaps a period of time which has to elapse when changes are made before they propagate through the network? I had noticed problems as I was developing programs which suggested these possibilities. However I was making so many changes that I could never be sure what was causing these anomalies.  Further testing reveals that just opening the Mule and closing it is sufficient to get the program allow the player's to operate the sheetbuttons. There is no need to pull the Mule icon onto the board. However that has to be done by each player on their own game. Doing t on the gm's game does not allow players to use their sheetbuttons. Any ideas what is going on? I am seeing this same behavior with a script mule. I use Kurt's template mule script and for some reason when I start the game invoking a script on the mule results in the character-id to be displayed in chat but the script does not function. I also have found that if I open the character sheet for the mule, it works correctly. Maybe Kurt or someone can shed some insight into this. thx
Hello I am working on a script were it prompts the user and sets a variable as true or false. Then later I try and read the variable and go to a sub procedure.  I cannot get the check to properly read the variable even though I print the variable out and its true.  --&Brain|?{Harvest a Brain over Eyes?|true|false} --+Brain| is [&Brain]  --?[$Brain] -eq “true” -and [$RollHeart] -ge  [$DC]  |>HarvestHeart --- I have tried with " and ' around the true. What am I missing?
1675901776

Edited 1675901862
Andrew R.
Pro
Sheet Author
You are referring to $Brain when you should be referring to &Brain in your —? statement. 
Thank you I removed the " around true and its working .....
1676233230

Edited 1676233557
Kurt J.
Pro
API Scripter
ScriptCards System Neutral Library (snlib) v 0.0.1 If you are unfamiliar with ScriptCards libraries, they are sections of code you can place in a specially named handout in your game and then include in any ScriptCards script by using the +++libraryname+++ structure. You can include any number of libraries by separating their names with a semicolon. (ex: +++snlib;dnd5e+++ would include the "snlib" and "dnd5e" libraries. Libraries are pasted into the notes section of a specially created handout that is named in a particular way: ScriptCards Library libname (case sensitive), so ScriptCards Library snlib for example. The text of the library should be pasted in plain text into the Notes section and not edited from within Roll20 or it will break. The System Neutral Library (snlib) contains a collection of functions from a number of scripts I've put together, including: Functions to deal with "bump" (another API script) tokens Functions related to controlled or selected tokens Functions related to token status markers Functions related to the Roll20 Initiative Tracker Functions to apply damage or healing to selected token(s) Going forward, I'll be updating the snlib with anything useful from other scripts I develop that don't relate to any specific game system's character sheet.  The dnd5e lib is due for a major update in the near future as well. Below is a full list of the functions available in the snlib library: --/| ################################################################################################### --/| Functions related to the BUMP Api/Mod Script --/| ################################################################################################### --/| LibSN_FIND_BUMP_MASTER_TOKEN|TokenID of Shadow Token;Return var --/| Pass a Token ID for the "shadow" bump token and a string variable name for the --/| return value. The function will return the token id of the real token it is --/| standing in for. If the passed token ID is already the real token, the same ID will --/| be returned. If the token ID isn't registered with bump, the return value will --/| be empty. --/| --/| LibSN_FIND_BUMP_SHADOW_TOKEN|TokenID of Master Token;Return var --/| Pass a Token ID for the real token and a string variable name for the --/| return value. The function will return the token id of the shadow token it is --/| associated with. If the passed token ID is already the shadow token, the same ID will --/| be returned. If the token ID isn't registered with bump, the return value will --/| be empty. --/| --/| LibSN_FIND_BUMP_TOKEN_PAIR|TokenID of Shadow or Master Token;Master Token Var;Shadow Token Var --/| Takes a token ID as parameter 1 and two string variable names as parameters 2 and 3. --/| Acts as a combination of the two previous functions, returning the real token (param 2) --/| and the shadow token (param 3) given either of the tokens as the first parameter --/| --/| ################################################################################################### --/| Functions related controlled and/or selected tokens --/| ################################################################################################### --/| LibSN_CHECK_FOR_SELECTED_TOKEN|Result String Var --/| Returns a "1" if there is a selected token passed to the script, otherwise returns "0" --/| --/| LibSN_GET_CONTROLLED_CHARACTER_LIST|Result String Var --/| Returns a comma seprated list of all of the characters controlled by the player that --/| executed the script. (ie, ControlledBy contains their player ID) --/| --/| LibSN_GET_TOKENS_REPRESENTING|CharacterID;PageID;ReturnTokenIDVariable --/| Returns a comma separated list of tokens on the PageID page that represent the character --/| specified by CharacterID --/| --/| LibSN_GET_CONTROLLED_TOKENS_FROM_PAGETOKENS|Return String Var --/| Returns a comma separated list of all of the tokens on the current player (ribbon) page --/| that are controlled by the player executing the script. --/| --/| ################################################################################################### --/| Functions related to the Token Status Markers --/| ################################################################################################### --/| LibSN_CHECK_STATUS_MARKER - TokenID;MarkerToFind;ExistsVariable;CountVariable --/| Will check the given token (TokenID) for the status marker (MarkerToFind) and set two return --/| string variables: (ExistsVariable) will be 1 if the token has the marker, and (CountVariable) --/| will contain the counter number on the marker (default 0 for no number) --/| --/| LibSN_REMOVE_STATUS_MARKER - TokenID;MarkerToRemove --/| Will remove any variation of (MarkerToRemove from the given token (TokenID) --/| --/| LibSN_ADD_STATUS_MARKER - TokenID;MarkerToAdd;Count --/| Will add (MarkerToAdd) to the given token (TokenID). If count is specified with a number --/| betweeen 1 and 9, the number will be placed on top of the status marker. --/| --/| LibSN_DECREMENT_STATUS_MARKER - TokenID;MarkerToDecrement;Blank, 0 or 1 (OPTIONAL) --/| If (MarkerToDecrement) exists on the on token (TokenID), the counter number will be --/| decreased by 1. If a third parameter is added and set to 1, the status marker will --/| be removed when decrementing from 1 to no counter. If set to 0, the marker will be --/| be removed when decrementing for a marker without a counter. If not specified, the --/| marker will not be removed when the counter would go below 1 or 0. --/| --/| LibSN_INCREMENT_STATUS_MARKER - TokenID;MarkerToIncrement;Blank, 0 or 1 (OPTIONAL) --/| If (MarkerToDecrement) exists on the on token (TokenID), the counter number will be --/| increased by 1. If a third parameter is added and set to 0 or 1, the status marker will --/| be added to the token if it does not exist. If the parameter is 0, no counter number --/| will be added to the token. If the value is 1, the counter number will be set to 1 --/| --/| LibSN_CLEAR_STATUS_MARKERS - TokenID --/| Removes all status markers from the indicated token. --/| --/| ################################################################################################### --/| Functions related to the Roll20 Turn Order/Initiative Tracker --/| ################################################################################################### --/| LibSN_GET_CURRENT_TURN_INFO - Returns information for the current entry in the turn tracker --/| LibSN_GET_NEXT_TURN_INFO - Returns information for the next upcoming entry in the turn tracker --/| LibSN_GET_LAST_TURN_INFO - Returns information for the final entry in the turn tracker --/| --/| All of these functions accept 6 parameters, which are all the names of string variables that will be --/| set after the analysis of the information for the given turn. The parameters are : --/| Param 1 : Variable to set to the Token ID for the token representing the turn (if any) --/| Param 2 : Variable to set to the initiative value for the turn (ie, the Initiative number) --/| Param 3 : Variable to set to the Custom text for a turn that doesn't represent a token --/| Param 4 : Variable to set to the per-round formula setting for the custom turn --/| Param 5 : Variable to set to the Page ID where the turn resides --/| Param 6 : Variable to set to the display name, which is the token name for turns that represent --/| tokens, and the Custom text for custom (non-token) turn entries --/| --/| LibSN_GET_NUMBERED_TURN_INFO --/| This function is identical to the three above, except it adds an additional parameter the is the --/| number of the turn to examine (in sequence) from the top of the turn tracker list (starting at 1) --/| (ie, GET_NUMBERED_TURN_INFO|TID;INIT;CUSTOM;FORMULA;PAGE;NAME;TURNNUMBER)| --/| --/| LibSN_GET_TURNORDER_LENGTH|Return Roll Var --/| This function returns the number of turns in the turn tracker --/| --/| LibSN_REFRESH_TURNORDER_CACHE --/| The turnorder functions check when called to see if the turn order has been parsed. If you modify the --/| turn order in your script, you should call REFRESH_TURNORDER_CACHE to make sure the turnorder functions --/| are working with the updated information. --/| --/| ################################################################################################### --/| General/Uncategorized functions --/| ################################################################################################### --/| --/| LibSN_APPLY_DAMAGE_OR_HEALING_TO_SELECTED|bar#;amount;display (0 or 1) --/| Applies (amount) damage [negative number] or healing [positie number] to all selected tokens (bar#) token bar. --/| If (display) is specified as 1, an output line will be genereated for each token damaged/healed. --/| --/| LibSN_APPLY_DAMAGE_OR_HEALING|tokenid;bar#;amount;display (0 or 1) --/| Applies damage (negative number) or healing (positie number) to (tokenid)'s (bar#) token bar. --/| --/| LibSN_APPLY_DAMAGE_OR_HEALING_TO_ARRAY|ArrayName;bar#;amount;display (0 or 1) --/| Applies (amount) damage [negative number] or healing [positie number] to all tokens (bar#) token bar with ids --/| contained as elements in (ArrayName) --/| If (display) is specified as 1, an output line will be genereated for each token damaged/healed. Here is a quick sample of using the library: !script {{ +++snlib+++ -->LibSN_DECREMENT_STATUS_MARKER|@{selected|token_id};snail;1 }} This includes the library (+++snlib+++) and then uses the LibSN_DECREMENT_STATUS_MARKER to decrement the counter on the "snail" status marker, removing it if it reaches 0.
hi there, the conditional doesn't seem to work. SC always displays GainLevel. I don't get it! any hints for a dumb and blind. !script {{   --+XP before|[*@{selected|token_id}:xp]   --!a:@{selected|token_id}|xp:+=?{XP|0}   --+XP after|[*@{selected|token_id}:xp]   --+XPmax|[*@{selected|token_id}:xp^]   --?[*@{selected|token_id}:xp^] -le [*@{selected|token_id}:xp]|End|GainLevel --x| --:GainLevel|   --+|@{selected|token_name} gains a level! --x| --:End| --x| }}
1676915612

Edited 1676915652
Found it by myself. The conditional works. The branches had to change position. End <-> GainLevel
1677091089

Edited 1677091328
Random Table Tool I've collected and/or purchased a ton of Random Item books and lists over the years and love using them in my games.&nbsp; Unfortunately, many times the random list I wanted in the moment always seemed to be buried in some book or file and I didn't have time to find a particular list in the middle of a game session.&nbsp;&nbsp; This little script will look through your campaigns list of Rollable Tables looking for those that start with "RT_".&nbsp; It expects the following name format:&nbsp; " RT_Category-Name" .&nbsp; For example, RT_Names-Elf or RT_Encounters-Woodland. When you run the script it will present a list of categories it found.&nbsp; When a category is selected, it will present a list of tables for that category.&nbsp; Finally, once you select a table, it will randomly select an item from that table, giving you the options to randomly select again and to show players the selection.&nbsp;&nbsp; Navigation:&nbsp; Category Lister -&gt; Table Lister -&gt; Random Selection Note: &nbsp; To build these tables, I use Aaron's TableExporter Script ( <a href="https://github.com/shdwjk/Roll20API/blob/master/TableExport/TableExport.js" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/TableExport/TableExport.js</a> ) which also has a table import feature to import many of these tables into Roll20.&nbsp; I built an Excel tool to make it easy to dump in the list of items and it writes out the Table Import commands. !scriptcard {{ --/|Script Name : Randmom Tables --/|Version : 2-21-2023 --/|Requires SC : 2.2.0+, --/|Author : Will M. --/|Description : Interface for grouping and selecting items from random tables --/| rollabletable name format --/| RT_[Category]-[Name] --/| Example Categories: Item, Scene, Potion, Location, Riddle, Prophecy, Names, Encounters, Food, Drink, Quests, ... --/| Example table names: RT_Names-Goblin, RT_Names-Elf, RT_Ecnounters-Woodland, RT_Encounters-Desert --#title|Random Tables --/#overridetemplate|dnd --#reentrant|Random Tables --#timezone|America/Chicago --#debug|0 --&gt;SETUP_GLOBAL_VARS| --:TOP| --#whisper|gm --~|array;objects:rollabletable;aryTables;RT_ --~|array;define;aryTableNames --?"[@aryTables(length)]" -eq "0"|END --%loop|foreach;aryTables --/+|[*O:[&amp;loop]:rollabletable:name] --&amp;aryTableNames([@aryTableNames(length)])|[*O:[&amp;loop]:rollabletable:name] --%| --~|array;sort;aryTableNames --~|array;define;aryCategories --&amp;PrevCat| --%loop|foreach;aryTableNames --/+|[&amp;loop] --~Category|string;before;[&amp;DASH];[&amp;loop] --?"[&amp;Category]" -ne "[&amp;PrevCat]"|[ --&amp;PrevCat|[&amp;Category] --&amp;aryCategories([@aryCategories(length)])|[&amp;Category] --/*Category|[&amp;Category] --]| --%| --&amp;CatBtns| --%loop|foreach;aryCategories --~tmp|string;after;_;[&amp;loop] --&amp;CatBtns|+ [rbutton][&amp;tmp]::FILTER_TABLE_ITEMS;[&amp;loop][/rbutton] --%| --+|[&amp;CatBtns] --+|[hr] --+|[i][c][rbutton]List Tables::LIST_RANDOM_TABLES[/rbutton][/c][/i] --:END| --x| --:FILTER_TABLE_ITEMS| --~Cat|string;after;_;[&amp;reentryval] --#title|[&amp;Cat] --~|array;objects:rollabletable;aryFilteredTables;[&amp;reentryval] --~|array;define;aryFilteredTableNames --?"[@aryFilteredTables(length)]" -eq "0"|END --%loop|foreach;aryFilteredTables --&amp;aryFilteredTableNames([@aryFilteredTableNames(length)])|[*O:[&amp;loop]:rollabletable:name] --/*|[*O:[&amp;loop]:rollabletable:name] --%| --~|array;sort;aryFilteredTableNames --%loop|foreach;aryFilteredTableNames --~tmp|string;after;[&amp;DASH];[&amp;loop] --/*|[&amp;tmp] --+|[rbutton][&amp;tmp]::GET_RT_ITEM;[&amp;loop][/rbutton] --%| --x| --:GET_RT_ITEM| --~Cat|string;before;_;[&amp;reentryval] --~Tbl|string;after;-;[&amp;reentryval] --#title|[&amp;Tbl] --=Result|[T#[&amp;reentryval]] --+|[$Result.tableEntryText] --+|[hr] --+|[i][&amp;reentryval]:[$Result][/i] --+|[c][i][rbutton]Again::GET_RT_ITEM;[&amp;reentryval][/rbutton] - [rbutton]Show Players::SHOW_PLAYERS[/rbutton] - [rbutton]Top::TOP[/rbutton][/i][/c] --/~DT|system;date;getdatetime --/@note-log|[&amp;DT]: Random Tables([&amp;Tbl]:[$Result]); [$Result.tableEntryText] --x| --:SHOW_PLAYERS| --#whisper| --#title|[&amp;Tbl] --+|[$Result.tableEntryText] --*|[c][i][rbutton]Again::GET_RT_ITEM;[&amp;reentryval][/rbutton] - [rbutton]Show Players::SHOW_PLAYERS[/rbutton] - [rbutton]Top::TOP[/rbutton][/i][/c] --x| --:LIST_RANDOM_TABLES| --~|array;objects:rollabletable;aryTables;RT_ --~|array;define;aryTableNames --?"[@aryTables(length)]" -eq "0"|END --%loop|foreach;aryTables --/+|[*O:[&amp;loop]:rollabletable:name] --&amp;aryTableNames([@aryTableNames(length)])|[*O:[&amp;loop]:rollabletable:name] --%| --~|array;sort;aryTableNames --&amp;PrevCat| --%loop|foreach;aryTableNames --/+|[&amp;loop] --~Category|string;before;[&amp;DASH];[&amp;loop] --?"[&amp;Category]" -ne "[&amp;PrevCat]"|[ --&amp;PrevCat|[&amp;Category] --/*Category|[&amp;Category] --~tmp|string;after;RT_;[&amp;Category] --+|[b][&amp;tmp][/b] --]| --~tmp|string;after;[&amp;Category]-;[&amp;loop] --+|[&amp;spc][&amp;spc][rbutton][&amp;tmp]::GET_RT_ITEM;[&amp;loop][/rbutton] --%| --X| --:SETUP_GLOBAL_VARS| --&amp;QB|? --&amp;QB|+{ --&amp;QE|} --&amp;AB|@ --&amp;AB|+{ --&amp;TB|&amp; --&amp;TB|+# --&amp;TB|+64 --&amp;TB|+; --&amp;TB|+{ --&amp;BED|&amp; --&amp;BED|+# --&amp;BED|+128719; --&amp;CLOCK|&amp; --&amp;CLOCK|+# --&amp;CLOCK|+128336; --&amp;SPACE|X X --&amp;SPACE|[&amp;SPACE(1,1)] --&amp;spc|&amp;nbsp; --&amp;obrac|[ --&amp;cbrac|] --&amp;vbar|| --&amp;DASH|- --&amp;DDASH|[&amp;DASH][&amp;DASH] --&lt;| }}
1677721277
Kurt J.
Pro
API Scripter
I've queued the latest version of ScriptCards for OneClick update, so it should show up next week. When it does, I'll post a summary of the changes since the last OneClick deploy.
I couldn't find any documentation on the TableExport script for how to use it. Can you point me in the right direction? Either that or it's not working for me. I'm also interested in your Excel process! Will M. said: Random Table Tool I've collected and/or purchased a ton of Random Item books and lists over the years and love using them in my games.&nbsp; Unfortunately, many times the random list I wanted in the moment always seemed to be buried in some book or file and I didn't have time to find a particular list in the middle of a game session.&nbsp;&nbsp; This little script will look through your campaigns list of Rollable Tables looking for those that start with "RT_".&nbsp; It expects the following name format:&nbsp; " RT_Category-Name" .&nbsp; For example, RT_Names-Elf or RT_Encounters-Woodland. When you run the script it will present a list of categories it found.&nbsp; When a category is selected, it will present a list of tables for that category.&nbsp; Finally, once you select a table, it will randomly select an item from that table, giving you the options to randomly select again and to show players the selection.&nbsp;&nbsp; Navigation:&nbsp; Category Lister -&gt; Table Lister -&gt; Random Selection Note: &nbsp; To build these tables, I use Aaron's TableExporter Script ( <a href="https://github.com/shdwjk/Roll20API/blob/master/TableExport/TableExport.js" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/TableExport/TableExport.js</a> ) which also has a table import feature to import many of these tables into Roll20.&nbsp; I built an Excel tool to make it easy to dump in the list of items and it writes out the Table Import commands.
Colin C. said: I couldn't find any documentation on the TableExport script for how to use it. Can you point me in the right direction? Either that or it's not working for me. I'm also interested in your Excel process! Will M. said: Random Table Tool I've collected and/or purchased a ton of Random Item books and lists over the years and love using them in my games.&nbsp; Unfortunately, many times the random list I wanted in the moment always seemed to be buried in some book or file and I didn't have time to find a particular list in the middle of a game session.&nbsp;&nbsp; This little script will look through your campaigns list of Rollable Tables looking for those that start with "RT_".&nbsp; It expects the following name format:&nbsp; " RT_Category-Name" .&nbsp; For example, RT_Names-Elf or RT_Encounters-Woodland. When you run the script it will present a list of categories it found.&nbsp; When a category is selected, it will present a list of tables for that category.&nbsp; Finally, once you select a table, it will randomly select an item from that table, giving you the options to randomly select again and to show players the selection.&nbsp;&nbsp; Navigation:&nbsp; Category Lister -&gt; Table Lister -&gt; Random Selection Note: &nbsp; To build these tables, I use Aaron's TableExporter Script ( <a href="https://github.com/shdwjk/Roll20API/blob/master/TableExport/TableExport.js" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/TableExport/TableExport.js</a> ) which also has a table import feature to import many of these tables into Roll20.&nbsp; I built an Excel tool to make it easy to dump in the list of items and it writes out the Table Import commands. Try this: <a href="https://www.youtube.com/watch?v=AAblSTfMzWw" rel="nofollow">https://www.youtube.com/watch?v=AAblSTfMzWw</a>
1678272029
Kurt J.
Pro
API Scripter
ScriptCards 2.2.9 is now live on OneClick Here are the updates since 2.2.4: The "SendingPlayer...." preset strings are now updated when resuming a reentrant script with information about the player that caused the script to resume. A new set of strings (OriginalSendingPlayer...) are set when the script is initially executed. When using attribute modification (--!a) and creating an attribute if it doesn't exist, += and -= will now properly set the newly created attribute to the expected value instead of the text string including += or -=. Thanks to Cindurion on the Roll20 forum for catching this bug. Roll crit highlighting (green background) would not trigger on exploding dice because they could never technically be equal&nbsp; to the max value on the die. Green highlighting will now be triggered if the value of any die is greater than or equal to the number of sides on the dice, so an exploding die that explodes at least once will always be colored green. When using --!or commands to create repeating row sections, passing "%3A" as part of the value in replacement of a colon (:)&nbsp; will translate %3A to a colon in the stored result. Normally you can use a : to separate the current/max values and this prevented you from having a : in your attribute value. Simply replace actual colons in your value strings with %3A before calling --!or and the value will be translated. Added 2 string functions: onlynumbers and nonumbers. string;onlynumbers;stringvalue will extract the numeric characters from a string and return the value (a leading - sign will be preserved). nonumbers will remove all numeric characters from the string and return the resulting value. Fix for --!c not finding the character because it was looking for a "graphic" instead of a "character" It is now possible to use images in button captions by using the [img]...[/img] formatting structure. It is wise to set the width and height properties in the [img...] opener. [p]...[/p] now support specifying style information in the opening [p] tag. Ex: [p style='font-size:smaller;']Hello World[/p] turnorder;addtoken and turnorder;replace token now accept optional parameters for custom and formula values. If you want to specify a formula, you must specify a custom value, but it can be blank.
Heyas! So I have a question about Libraries and API calls. I have the following macro:&nbsp; !scriptcard {{&nbsp; +++Conditions+++ --&amp;Affected|@{selected|token_id} --&amp;ConditionName|Charmed --&gt;ApplyCondition| }} And the library code is: --:ApplyCondition| --?"[&amp;ConditionName]" -eq "Blinded"|[ --+Blinded|[*[&amp;Affected]:t-name] is blinded by the spell. They&nbsp; suffer a –3 penalty to any rolls that rely on vision - including attack rolls - and halves their Defense. --@token-mod|_ignore-selected _ids [&amp;Affected] _set statusmarkers|broken-skull --&lt;| --]| --?"[&amp;ConditionName]" -eq "Charmed"|[ --+Charmed|[*[&amp;Affected]:t-name]'s luck may spare them from serious injury, ensure that she meets someone whose acquaintance will be valuable to them later, guarantee that she isn’t the one who gets the short straw, or help them win an important game of chance. You may invoke this twist of fate at any time as a reflexive action. If used to avoid injury, resolving this Condition reduces the damage to 1. Otherwise, no one knows the exact nature this good fortune will take when it manifests — only that it will have a significant impact. --@token-mod|_ignore-selected _ids [&amp;Affected] _set statusmarkers|angel-outfit --&lt;| --]| When I run the macro, it correctly runs the correct code block, but the status marker isn't applied at all. The debug dump says that call is made but noting happens.&nbsp; "Line Counter: 2, Tag:&amp;Affected, Content:-NOvYsIuFkjFmt6i887s" "Line Counter: 3, Tag:&amp;ConditionName, Content:Charmed" "Line Counter: 4, Tag:&gt;ApplyCondition, Content:" "ContentIn: ?\"[&amp;ConditionName]\" -eq \"Blinded\" Match: [&amp;ConditionName], vName: ConditionName, replacement Charmed" "Line Counter: 7, Tag:?\"Charmed\" -eq \"Blinded\", Content:[" "Condition \"Charmed\" -eq \"Blinded\" evaluation result: false" "ContentIn: ?\"[&amp;ConditionName]\" -eq \"Charmed\" Match: [&amp;ConditionName], vName: ConditionName, replacement Charmed" "Line Counter: 12, Tag:?\"Charmed\" -eq \"Charmed\", Content:[" "Condition \"Charmed\" -eq \"Charmed\" evaluation result: true" "ContentIn: [*[&amp;Affected]:t-name]'s luck may spare them from serious injury, ensure that she meets someone whose acquaintance will be valuable to them later, guarantee that she isn’t the one who gets the short straw, or help them win an important game of chance. You may invoke this twist of fate at any time as a reflexive action. If used to avoid injury, resolving this Condition reduces the damage to 1. Otherwise, no one knows the exact nature this good fortune will take when it manifests — only that it will have a significant impact. Match: [&amp;Affected], vName: Affected, replacement -NOvYsIuFkjFmt6i887s" "Line Counter: 13, Tag:+Charmed, Content:npcsettings's luck may spare them from serious injury, ensure that she meets someone whose acquaintance will be valuable to them later, guarantee that she isn’t the one who gets the short straw, or help them win an important game of chance. You may invoke this twist of fate at any time as a reflexive action. If used to avoid injury, resolving this Condition reduces the damage to 1. Otherwise, no one knows the exact nature this good fortune will take when it manifests — only that it will have a significant impact." "ContentIn: _ignore-selected _ids [&amp;Affected] _set statusmarkers|angel-outfit Match: [&amp;Affected], vName: Affected, replacement -NOvYsIuFkjFmt6i887s" "Line Counter: 14, Tag:@token-mod, Content:_ignore-selected _ids -NOvYsIuFkjFmt6i887s _set statusmarkers|angel-outfit" "ScriptCards: Making API call - !token-mod&nbsp; --ignore-selected --ids -NOvYsIuFkjFmt6i887s --set statusmarkers|angel-outfit" "Line Counter: 15, Tag:&lt;, Content:" "Line Counter: 5, Tag:X, Content:" Can Mod calls happen from a library? Or do I have an error somewhere? Thanks!
1679090060
Kurt J.
Pro
API Scripter
Erik M. said: Heyas! So I have a question about Libraries and API calls. I have the following macro:&nbsp; !scriptcard {{&nbsp; +++Conditions+++ --&amp;Affected|@{selected|token_id} --&amp;ConditionName|Charmed --&gt;ApplyCondition| }} And the library code is: --:ApplyCondition| --?"[&amp;ConditionName]" -eq "Blinded"|[ --+Blinded|[*[&amp;Affected]:t-name] is blinded by the spell. They&nbsp; suffer a –3 penalty to any rolls that rely on vision - including attack rolls - and halves their Defense. --@token-mod|_ignore-selected _ids [&amp;Affected] _set statusmarkers|broken-skull --&lt;| --]| --?"[&amp;ConditionName]" -eq "Charmed"|[ --+Charmed|[*[&amp;Affected]:t-name]'s luck may spare them from serious injury, ensure that she meets someone whose acquaintance will be valuable to them later, guarantee that she isn’t the one who gets the short straw, or help them win an important game of chance. You may invoke this twist of fate at any time as a reflexive action. If used to avoid injury, resolving this Condition reduces the damage to 1. Otherwise, no one knows the exact nature this good fortune will take when it manifests — only that it will have a significant impact. --@token-mod|_ignore-selected _ids [&amp;Affected] _set statusmarkers|angel-outfit --&lt;| --]| When I run the macro, it correctly runs the correct code block, but the status marker isn't applied at all. The debug dump says that call is made but noting happens.&nbsp; "Line Counter: 2, Tag:&amp;Affected, Content:-NOvYsIuFkjFmt6i887s" "Line Counter: 3, Tag:&amp;ConditionName, Content:Charmed" "Line Counter: 4, Tag:&gt;ApplyCondition, Content:" "ContentIn: ?\"[&amp;ConditionName]\" -eq \"Blinded\" Match: [&amp;ConditionName], vName: ConditionName, replacement Charmed" "Line Counter: 7, Tag:?\"Charmed\" -eq \"Blinded\", Content:[" "Condition \"Charmed\" -eq \"Blinded\" evaluation result: false" "ContentIn: ?\"[&amp;ConditionName]\" -eq \"Charmed\" Match: [&amp;ConditionName], vName: ConditionName, replacement Charmed" "Line Counter: 12, Tag:?\"Charmed\" -eq \"Charmed\", Content:[" "Condition \"Charmed\" -eq \"Charmed\" evaluation result: true" "ContentIn: [*[&amp;Affected]:t-name]'s luck may spare them from serious injury, ensure that she meets someone whose acquaintance will be valuable to them later, guarantee that she isn’t the one who gets the short straw, or help them win an important game of chance. You may invoke this twist of fate at any time as a reflexive action. If used to avoid injury, resolving this Condition reduces the damage to 1. Otherwise, no one knows the exact nature this good fortune will take when it manifests — only that it will have a significant impact. Match: [&amp;Affected], vName: Affected, replacement -NOvYsIuFkjFmt6i887s" "Line Counter: 13, Tag:+Charmed, Content:npcsettings's luck may spare them from serious injury, ensure that she meets someone whose acquaintance will be valuable to them later, guarantee that she isn’t the one who gets the short straw, or help them win an important game of chance. You may invoke this twist of fate at any time as a reflexive action. If used to avoid injury, resolving this Condition reduces the damage to 1. Otherwise, no one knows the exact nature this good fortune will take when it manifests — only that it will have a significant impact." "ContentIn: _ignore-selected _ids [&amp;Affected] _set statusmarkers|angel-outfit Match: [&amp;Affected], vName: Affected, replacement -NOvYsIuFkjFmt6i887s" "Line Counter: 14, Tag:@token-mod, Content:_ignore-selected _ids -NOvYsIuFkjFmt6i887s _set statusmarkers|angel-outfit" "ScriptCards: Making API call - !token-mod&nbsp; --ignore-selected --ids -NOvYsIuFkjFmt6i887s --set statusmarkers|angel-outfit" "Line Counter: 15, Tag:&lt;, Content:" "Line Counter: 5, Tag:X, Content:" Can Mod calls happen from a library? Or do I have an error somewhere? Thanks! --@ command should work from module code, but if the script is being run by a non-gm token-mod needs to be configured to allow the user of IDs. If you run the token-mod command by just pasting the text into the chat, does that work? The other thing I would caution against is using code blocks in library code. Code block can't be nested, so if you call a library function that uses a code block from inside code that is also using a code block, you may experience strange behavior. This is something I need to work on addressing in the code, but it is the way it is right now.
Dagnabbit. New campaign, new need to turn on PlayersCanUseIds. Thanks Kurt.&nbsp; I'll make a note of the code block issue. Do you think there is a way I could use the library in that way without the code blocks?
Hi everyone, I have a question about the GMLine. Is it possible to hide the phrase 'GMLine' e.g. --*GMLine|Perception:10 will produce a line that looks like this: GMLine Perception:10 Thanks in advance
If I have buttons to increase or decrease a variable, only the original value of the variable gets modified. I cant increment it multi times by pressing the same button. Here’s the example code: !script {{ --#hideTitleCard|1 --#nominmaxhighlight|1 --=TEST|1 --+Testing| [rbutton]+1::Inc[/rbutton] [rbutton]-1::Dec[/rbutton] --+TEST=|[$TEST] --X| --:Inc| --=TEST|[$TEST]+1 --+Increased to=|[$TEST] --^Skip1| --X| --:Dec| --=TEST|[$TEST]-1 --+Decreased to=|[$TEST] --^Skip1| --X| --:Skip1| --+TEST=|[$TEST] }} Any way to get it to work? So that pressing the +1 button 3 times would increment the TEST value to 2 then 3 then 4.
Rholan said: Hi everyone, I have a question about the GMLine. Is it possible to hide the phrase 'GMLine' e.g. --*GMLine|Perception:10 will produce a line that looks like this: GMLine Perception:10 Thanks in advance Just delete the 'GMLine' and it will work.
Thanks. Sometimes it is just too easy. :D