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

1619636400
David M.
Pro
API Scripter
Yep! You will need to use the --side command. I believe there is one or two examples of this on the first post of the Spawn forum thread. I'm on mobile right now, so can't look up and link easily.
1619642072

Edited 1619650197
Kurt J. said: ScriptCards version 1.0.8, 5E Tools Library version 0.0.6 [yadayadayada] t-ligt_radius I noticed the above typo. Also, the current list does not account for the UDL properties of the tokens: emits_bright_light:emits_low_light:low_light_distance:bright_light_distance Maybe others? I added those to my version so my Sunsword macro works: !script {{ --#hideTitleCard|1 --#whisper|self --#sourcetoken|@{selected|token_id} --Rfind|[*S:character_id];Sunsword;repeating_inventory;itemname --?[*R:equipped] -ne 1|Wield|Wielded --X| --:Wield| --#hideCard|1 --=NewRadius|15 --@setattr|_name [*S:character_name] _[*R>equipped]|1 _silent --^SetAura| --X| --:Wielded|stow, increase/decrease radius --+|[rbutton]Stow Sunsword::Stow[/rbutton] [rbutton]Increase Light::ModAura;+ 5[/rbutton] [rbutton]Decrease Light::ModAura;- 5[/rbutton] --X| --:ModAura|change value --#hideCard|1 -->Clamp|[*S:t-bright_light_distance];[&reentryval] --^SetAura| --X| --:SetAura| --@token-mod|_set emits_low|yes emits_bright|yes bright_light_distance#[$NewRadius.Total] low_light_distance#[$NewRadius.Total] aura1_radius#[$NewRadius.Total] showplayers_aura1|yes defaulttoken _report gm|"{name} now has dim light of {low_light_distance} and bright light of {bright_light_distance} which is {aura1_radius} of sunlight." --X| --:Clamp|current total radius;change --/|Also clamps between max and min --=NewRadius|[%1%] [%2%] --~NewRadius|math;clamp;[$NewRadius];10;30 --<| --:Stow| --#hideCard|1 --@token-mod|_ignoreselected _ids [*S:token_id] _set emits_low|no emits_bright|no bright_light_distance#0 low_light_distance#0 aura1_radius#0 _report gm|"{name} has stowed the Sunsword." --@setattr|_name [*S:character_name] _[*R>equipped]|0 _silent --X| }} Edit: Fixed script
@David M. Ok, right  --side to specify which of the sides (items) to use.  So, Spawn can pull the token from the rollable table?  Normally, I have to click the token tab on the macro bar to drop it to the page...
1619716729
David M.
Pro
API Scripter
Michael, the short answer is yes, but I'm going to PM you since this is getting a little off topic.
1619813383

Edited 1619895725
Kurt J.
Pro
API Scripter
ScriptCards 1.2.1 - Please Read the Notes Edition! :) I've updated the development GIST with version 1.2.1. The focus of the 1.2.x series is mostly around cleaning up some of the code, and adding some additional convenience features to the "language". This version starts off that process, and the final change listed here is a big one, so please read this before updating to 1.2.1 to ensure that you are aware of the potential for impact to your existing scripts (while not huge, it is still there). Corrected (several) bugs with the "indexof" array function. It now shouldn't crash the sandbox, and should actually work :) ( Thanks Soren S.) Added UDL token attributes to the token attribute list so they can be used with the [*x:t-attribute] syntax. Also corrected the spelling of t-light_radius (thanks Colin C.) Completely rewrote the code that processes the results  of conditionals and case statements ( not conditional evaluation itself ) This code was expanded upon at one point to add the "false" branch options, but was less than ideal. This rewrite itself shouldn't have a huge impact, but it also enabled to to expand upon the abilities of conditional statements to do more than just branching. With version 1.2.1, the following options are available in both the true and false sections of a conditional: - Normal branch : This is the current default behavior. Including a label name will jump to that label as a "goto" branch. - Procedure branch : Also the current behavior. Preceding a label name with ">" will execute a gosub branch, passing parameters separated by semicolons. IMPORTANT: Semicolons inside double-quotes are now ignored, treating the unit as a single parameter. When passing token/character/etc. IDs (which can contain semicolons), wrap the parameter in double-quotes to prevent it from being split into multiple parameters. This may have an impact on existing code if you were passing parameters containing quotes. I'm working on a method for escaping the quotes so they can still be in parameters, but that is not in place yet. - Roll Variable Assignment : If the first character for the segment is an equals sign (=) you can assign a roll variable as a result of the conditional. The variable name takes the place of the branch label, and the first parameter is used as the definition of the roll variable. For example: --? $Atk.Base -eq 20|=Damage;2d8|=Damage;1d8 This will check to see if the base roll for $Atk was a 20, and assign the result of 2d8 to the Damage variable if true, or 1d8 if not. - String Variable Assignment : If the first character for the segment is an ampersand (&) you can assign a string variable as  a result of the conditional. The variable name takes the place of the branch label, and the first parameter is used as the string content. For example: --? $Atk.Base -eq 20|&HitType;Critical Hit!|&HitType;Hit Would assign "Critical Hit" to HitType if the roll was a 20, or just 'Hit" otherwise. Each segment/case is treated as its own entity, meaning you can mix and match any of the above options in a single --? or -c line (ie, on true, gosub to a procedure but just set a variable on false, etc.) Important: There is a small potential here for problems with existing scripts if you use labels that start with "=" or "&" characters. This would be extremely uncommon (and confusing), but it is technically allowed by the language.
So nice Kurt !! Thx !
Exceptional, Kurt.  Thanks.
1619895620

Edited 1619895661
Kurt J.
Pro
API Scripter
Updated the 1.2.1 notes to include case statements in the changes... Because they work just like conditionals, that code was updated in 1.2.1 as well, but I left it out of the notes. Each case in a case statement can be any of the supported statement types listed above. I also added a little clarification that you can mix and match the statement types. You can run a gosub on true and set a variable on false, etc.
1619918718

Edited 1620095477
Updated: Replaced emoji graphics with HTML Escape Codes Just added my Party/Character scriptcards macro to the  API Working Sharing forum.   The Scriptcard macro is part of my kit for reviewing player and party info.  Will report on any page token assigned to a player.  With it you can view: Party Info: Party Health Party Funds Party Resources Character Details: Character Sheet summary Attacks Features and Traits  Proficiencies Spell Book /w  details and ability to cast Inventory  Resources (Class, other and Repeating) Tools and Custom Skills Future Enhancements: Include NPCs option Include a Page Statistics report Inlcude a UDL report (Page settings, Player Tokens, Other Tokens) Add small button somewhere on every subcard to display the top level card again.  Improve card look Include a report of all map tokens option Ability to adjust things like resources or prepared spells Requirements :  Scriptcards 19.e or better. Select at least one token on the map.
@Will M.  Great effort.  Unfortunately, I couldn't get this to work.  Chat simply printed out the name of the caller and a line feed.  Debug showed no errors.  Running 1.2.1 in DnD 5e OGL.  Are there other requirements?  Anyone else get this to work or have problems with it working?
1619964520

Edited 1619964575
Kurt J.
Pro
API Scripter
Michael C. said: @Will M.  Great effort.  Unfortunately, I couldn't get this to work.  Chat simply printed out the name of the caller and a line feed.  Debug showed no errors.  Running 1.2.1 in DnD 5e OGL.  Are there other requirements?  Anyone else get this to work or have problems with it working? It seemed to work for me (very cool script, by the way) on my 5E OGL test game. The only issue i saw was that the emoji characters don't come thru properly when cut and paste from the forums. This is a pretty common problem (I had it for Encounter Helper) and my solution was to use html emoji references in the code instead of typing the characters in directly as emojis ( HTML Emoji Reference (w3schools.com) )
@Will M. - reloaded the script and it worked second time through though had same experience as Kurt J. regarding icons.  Ran through several of the buttons - really is excellent work...I think I found some (to be expected given the length of the script) minor style errors such as deception is misspelled in one place; the party health madness level is "undefined" rather than blank for characters without the attribute, and right and left repeating resource totals are zero (current is fine). I'll keep checking...
Michael C. said: @Will M. - reloaded the script and it worked second time through though had same experience as Kurt J. regarding icons.  Ran through several of the buttons - really is excellent work...I think I found some (to be expected given the length of the script) minor style errors such as deception is misspelled in one place; the party health madness level is "undefined" rather than blank for characters without the attribute, and right and left repeating resource totals are zero (current is fine). I'll keep checking... Michael - Thanks for taking a look and your comments.  I'll look into the trick that Kurt posted with escape characters for some of my button icons.  I have no doubt there are some spelling errors here and there.  I learned a lot putting this script together.  It demonstrates a lot of the functionality that Kurt has put into Scriptcards.  
Hi Kurt, First, thanks a lot for your awesome work !!! I definitly love ScriptCards. In my library, I use a procedure without parameter. It works perfectly with 1.1.19, but when I use this procedure with 1.2.1 the sandbox crashes with this message : When I add a fake parameter, it seems to work correctly
1619986323

Edited 1619986356
Kurt J.
Pro
API Scripter
ScriptCards 1.2.1a on the GIST Thanks Dellatosa! That was indeed a bug with my parameter processing code. I have updated the GIST with version 1.2.1a which should eliminate the sandbox crash in this case and allow a gosub branch with no paramters.
Is it possible to pull the GM notes from a token into a roll variable?  I'm making a door opening script card that checks if a door is locked or trapped.  If the character notices the trap, they are offered the chance to disarm the trap before trying to open the door.  The problem I'm running into is I'm out of token bars for info. Currently I have: bar 1: Unlock skill Bar 1 Max: Unlock DC Bar 2: Trap Save Stat Bar 2 Max: Find Trap DC Bar 3: Trap Disarm Skill Bar 3 Max: Trap Save DC I'm hoping to put the actual trap description in the GM notes and pull it into the script card.  I'm trying to avoid using a character sheet for each door.  Is this possible?
Brien V.  - Why not just create custom attributes in the attribute tab.  Then use ScriptCards or chatsetattr functions to read and set the attributes for your games logic.  That's what I did for tracking Madness levels in my Out of the Abyss campaign.  
1620037994

Edited 1620038036
Kurt J.
Pro
API Scripter
Brien V. said: Is it possible to pull the GM notes from a token into a roll variable?  I'm making a door opening script card that checks if a door is locked or trapped.  If the character notices the trap, they are offered the chance to disarm the trap before trying to open the door.  The problem I'm running into is I'm out of token bars for info. Currently I have: bar 1: Unlock skill Bar 1 Max: Unlock DC Bar 2: Trap Save Stat Bar 2 Max: Find Trap DC Bar 3: Trap Disarm Skill Bar 3 Max: Trap Save DC I'm hoping to put the actual trap description in the GM notes and pull it into the script card.  I'm trying to avoid using a character sheet for each door.  Is this possible? You CAN retrieve the GM Notes on a token with the [*X:t-gmnotes] notation (where X is either S, T, or a token ID. However , the Roll20 text editor will throw HTML character encoding in for things like spaces, etc. You could then do some string replacement functions to strip them out. One alternative is to put the text into another easily editable field, like "aura1_radius". As long as it isn't actually a numeric value it won't show an aura, and can be retrieved with [*X:t-aura1_radius].
1620055494
timmaugh
Pro
API Scripter
I am updating the meta script Fetch to offer a one step retrieval and decoding of the gmnotes field as an inline return. Should be up later today. Then you can drop this into any macro: @(selected.gmnotes) ...or... @( TokenName .gmnotes) and it will retrieve the notes, provided you're a GM.
Is there a way to acquire the Roll20 Page Object Model settings from scriptcards?  I know you have your Reporter script that pulls some of the UDL attributes, but I'm not aware of any scripts or tools to acquire page settings for the current page or for all pages.  
Kurt J. said: ScriptCards 1.2.1 - Please Read the Notes Edition! :) I've updated the development GIST with version 1.2.1. The focus of the 1.2.x series is mostly around cleaning up some of the code, and adding some additional convenience features to the "language". This version starts off that process, and the final change listed here is a big one, so please read this before updating to 1.2.1 to ensure that you are aware of the potential for impact to your existing scripts (while not huge, it is still there). Corrected (several) bugs with the "indexof" array function. It now shouldn't crash the sandbox, and should actually work :) ( Thanks Soren S.) Added UDL token attributes to the token attribute list so they can be used with the [*x:t-attribute] syntax. Also corrected the spelling of t-light_radius (thanks Colin C.) Completely rewrote the code that processes the results  of conditionals and case statements ( not conditional evaluation itself ) This code was expanded upon at one point to add the "false" branch options, but was less than ideal. This rewrite itself shouldn't have a huge impact, but it also enabled to to expand upon the abilities of conditional statements to do more than just branching. With version 1.2.1, the following options are available in both the true and false sections of a conditional: - Normal branch : This is the current default behavior. Including a label name will jump to that label as a "goto" branch. - Procedure branch : Also the current behavior. Preceding a label name with ">" will execute a gosub branch, passing parameters separated by semicolons. IMPORTANT: Semicolons inside double-quotes are now ignored, treating the unit as a single parameter. When passing token/character/etc. IDs (which can contain semicolons), wrap the parameter in double-quotes to prevent it from being split into multiple parameters. This may have an impact on existing code if you were passing parameters containing quotes. I'm working on a method for escaping the quotes so they can still be in parameters, but that is not in place yet. - Roll Variable Assignment : If the first character for the segment is an equals sign (=) you can assign a roll variable as a result of the conditional. The variable name takes the place of the branch label, and the first parameter is used as the definition of the roll variable. For example: --? $Atk.Base -eq 20|=Damage;2d8|=Damage;1d8 This will check to see if the base roll for $Atk was a 20, and assign the result of 2d8 to the Damage variable if true, or 1d8 if not. - String Variable Assignment : If the first character for the segment is an ampersand (&) you can assign a string variable as  a result of the conditional. The variable name takes the place of the branch label, and the first parameter is used as the string content. For example: --? $Atk.Base -eq 20|&HitType;Critical Hit!|&HitType;Hit Would assign "Critical Hit" to HitType if the roll was a 20, or just 'Hit" otherwise. Each segment/case is treated as its own entity, meaning you can mix and match any of the above options in a single --? or -c line (ie, on true, gosub to a procedure but just set a variable on false, etc.) Important: There is a small potential here for problems with existing scripts if you use labels that start with "=" or "&" characters. This would be extremely uncommon (and confusing), but it is technically allowed by the language. Any chance Case Statement could be adapted to include comparisons? For example: --c[*S:level]|-ge 17:Dam;5d6|-ge 11:Dam;4d6|-ge 5:Dam;3d6|-ge 1:Dam;2d6 Some abilities are determined by character tier, and it would be cleaner to do a single case statement line to see what tier the character is in compared to a bunch of conditionals. --?[*S:level] -ge 1|=Dam;2d6 --?[*S:level] -ge 5|=Dam;3d6 --?[*S:level] -ge 11|=Dam;4d6 --?[*S:level] -ge 17|=Dam;5d6
Kurt J. said: ScriptCards 1.2.1a on the GIST Thanks Dellatosa! That was indeed a bug with my parameter processing code. I have updated the GIST with version 1.2.1a which should eliminate the sandbox crash in this case and allow a gosub branch with no paramters. Thanks for your quick fix Kurt. I think I found another issue with parameters. If a parameter has no value, this parameter is ignored. Ex : -->MyProc|A;B;;D v 1.1.19 : [%1%] -> A, [%2%] -> B, [%3%] -> 'empty', [%4%] -> D v 1.2.1  : [%1%] -> A, [%2%] -> B, [%3%] -> D
1620070649

Edited 1620073410
Kurt J.
Pro
API Scripter
Dellatosa said: Kurt J. said: ScriptCards 1.2.1a on the GIST Thanks Dellatosa! That was indeed a bug with my parameter processing code. I have updated the GIST with version 1.2.1a which should eliminate the sandbox crash in this case and allow a gosub branch with no paramters. Thanks for your quick fix Kurt. I think I found another issue with parameters. If a parameter has no value, this parameter is ignored. Ex : -->MyProc|A;B;;D v 1.1.19 : [%1%] -> A, [%2%] -> B, [%3%] -> 'empty', [%4%] -> D v 1.2.1  : [%1%] -> A, [%2%] -> B, [%3%] -> D Hmmm... given the regex I use to allow semicolons by using double quotes, I'm having difficulty matching an empty parameter. I can get around it by putting the empty parameter in quotes, but that isn't exactly convenient. I'll continue to poke around with the regex and see what I can come up with. I have a fix I think is working. I'll do some more testing and get an updated version uploaded. The regex went from this: /(".*?"|[^";]+)(?=\s*;|\s*$)/g to this: /(?!\s*$)\s*(?:'([^'\\]*(?:\\[\S\s][^'\\]*)*)'|"([^"\\]*(?:\\[\S\s][^"\\]*)*)"|([^;'"\s\\]*(?:\s+[^;'"\s\\]+)*))\s*(?:;|$)/g Yikes :). Going to try to make sure there aren't any undesirable side effects.
1620082774

Edited 1620082854
timmaugh
Pro
API Scripter
Brien V. said: Is it possible to pull the GM notes from a token into a roll variable?  --SNIP-- I'm hoping to put the actual trap description in the GM notes and pull it into the script card.  I'm trying to avoid using a character sheet for each door.  Is this possible? I've updated Fetch to allow you to retrieve the GM Notes field (properly decoded) to use in your scriptcard. Will M. said: Is there a way to acquire the Roll20 Page Object Model settings from scriptcards?  I know you have your Reporter script that pulls some of the UDL attributes, but I'm not aware of any scripts or tools to acquire page settings for the current page or for all pages.   This probably wasn't directed at me, but I can say that pulling Page properties is the next thing that will be added to Fetch, so you should soon be able to retrieve any of the data that is available to the API.
timmaugh said: Brien V. said: Is it possible to pull the GM notes from a token into a roll variable?  --SNIP-- I'm hoping to put the actual trap description in the GM notes and pull it into the script card.  I'm trying to avoid using a character sheet for each door.  Is this possible? I've updated Fetch to allow you to retrieve the GM Notes field (properly decoded) to use in your scriptcard. Will M. said: Is there a way to acquire the Roll20 Page Object Model settings from scriptcards?  I know you have your Reporter script that pulls some of the UDL attributes, but I'm not aware of any scripts or tools to acquire page settings for the current page or for all pages.   This probably wasn't directed at me, but I can say that pulling Page properties is the next thing that will be added to Fetch, so you should soon be able to retrieve any of the data that is available to the API. Do you have an example scriptcard macro that shows how to use Fetch?  
1620096094

Edited 1620101596
timmaugh
Pro
API Scripter
Sure... here is a basic example, and then a more advanced example (advanced from the meta perspective, not ScriptCards). Basic Interaction !scriptcard  {{    --#title|The Grimwalker   --+Description|@(selected.gmnotes[not found]) }} With the appropriate token selected, the above scriptcard produces: The Fetch construction there was: @(selected.gmnotes[not found]) ("not found", there, is serving as a default return should nothing be found... it is arbitrary text to let me know I didn't get a return) Think of it like just another extension of the Roll20 command interface: first Roll20 handles things like @{selected|token_name}, then the meta-scripts get in and handle their things, then the recipient script gets the finished message, never knowing what went on before. The Fetch syntax structure was kept very similar to standard Roll20 structures precisely so they would almost feel the same. Obviously, this requires the token that is the source of the gmnotes to be selected at the time that the scriptcard is run. However Fetch also accepts the token ID. (Fetch currently cannot use the token's name -- I'm working on adding that.) So other solutions of getting the right data from the right token would include... ...using the token_id:   --+Description|@(-M1234567890abcdef.gmnotes[not found]) ...using SelectManager in addition to Fetch and virtually selecting the token by name:   --+Description|@(selected.gmnotes[not found]){& select Grimwalker} Note: the token doesn't actually have to be selected for the above call to work! More Advanced Interaction If you know that Fetch sits in time between the Roll20 parsers and the ScriptCards processing, you realize you could bury ScriptCards syntax in the retrieved data. By changing the gmnotes of my token to include text that will be caught and parsed by ScriptCards, I can effectively add to the ScriptCards macro in real time based on what I retrieve. I can add a row in the Card just by including the correct syntax tokens: A figure emerges from the dark, a figure made... [b][i]from[/i][/b] the dark. A dimming of the light clings to it. Black liquid drips from too-long fingers. Gazing upon the figure, you hear the grind of steel... of steel dragged over endless stone. Clicking emanates from where the figure's mouth should be, though through the dimness you swear you see the shadow of a riveted plate fixed there, instead.   --+Save|Roll Save vs. Pants Crapping Including the '--+' turns that last portion into its own row in the ScriptCard. That syntax makes it into the macro's command line before ScriptCards ever sees it. The effect is: That is the exact same macro call: !scriptcard  {{    --#title|The Grimwalker   --+Description|@(selected.gmnotes[not found]){& select Grimwalker} }} ... but now it is getting more information from the Fetched item. Like I said, it's not a ton more intricate from the ScriptCard side, but it is a powerful side-effect of the meta-script interaction.
1620131831
David M.
Pro
API Scripter
That's cool, Tim!
1620134617

Edited 1620158914
I'm going to have to play with Fetch and Scriptcards a little more.  I can get it to pull back basic attributes like strength and fields from the character object like ControlledBy names.  But it doesn't want to pull back gmnotes or utlize the {& select TokenName} logic.  It may be because I tend to dynamically walk (loop) through my token and character objects instead of using hard-coded names.  May be best for us to continue this discussion on a different channel as this discussion largely pertains to Fetch.  I utilize your SelectManager meta script as well.  
Hi folks! I've send a ticket to the roll20 Legal team in order to get an answer regarding SHAAN's compendium but still no answer.... meanwhile I'm throwing a bottle at sea...... There's almost 350 powers in that system (ie spells). Some of them are pretty starightforward -> static spell fields and just a textual description.....EASY ! Some are a bit more tricky -> Roll results to determine Range, Duration, NbofTargets OR  Roll results  within the description (you can increase the protection bonus of X armors by an amount of Y points.) Some are even worse as they include tresholds in order to change the description itself (if 0< Roll result <X1|descrition1, X1<= Roll result <X2|description2,.....) Did I mention that each  Roll result  is the result of a complex dice manipulation process involving 3 dices (1 action dice & 2 off dices)? ^^ I have managed to deal with the dice combination part with a reentrant script that lets the player choose which dice combination he wants (depending of its mastery level). I have, as you can imagine, quite a few conditionnals ....They point to 9 subroutines (1 for each dice combination). The  Roll result is processed in each of these 9 subs (as it depends on the dice combination chosen). My question : How could I then pass the calculated  Roll result  to the 350 SpellDisplay subroutines ?
I have a question about rolling on a table using Recursive Tables.  I know I can roll normally using the [T#tablename] syntax and get the entry with .tableEntryText, but that doesn't seem to roll the nested rolls in the table.  I've tried using the API call --@rt|[[1t[tablename]]] but that just outputs $[[0]] to the chat.  How do I need to format this?
I modified Kurt J's most excellent fireball script to work out a group heal - using Song of Rest as an example.  Quite rudimentary and mostly Kurt's work but thought it might be of help to the less talented of us here.  (I kept Kurt's annotations as well.) !scriptcard  {{   --#title|Song of Rest   --#emoteText|@{selected|character_name} Heals the Party with a Song!   --#titleFontColor|#F6F055   --#titleCardBackground|#774206   --#leftsub|Bonus Action   --#rightsub|60' Range   --#evenRowBackground|#F3C78D   --#evenRowFontColor|#000000   --#oddRowBackground|#F76E14   --#oddRowFontColor|#000000   --#debug|1   --/|Get all tokens on the page into the "alltokens" array   --~|array;pagetokens;alltokens;@{selected|token_id}   --/|Create the "inRange" array. It will have a blank item in it to begin with, which we will remove later.   --~|array;define;inRange;   --/|Loop through all of the tokens in "alltokens" to check their distance   --~tokenid|array;getfirst;alltokens   --?[&tokenid] -eq ArrayError|endOutput   --:loopCheck|   --/|Skip tokens that are not on the token layer or that don't represent players   --?[*[&tokenid]:t-layer] -ne objects|continue   --?[*[&tokenid]:npc] -eq 1|continue   --/|Check the distance between the caster and the current array token. 60 feet is 12 units   --~dist|distance;@{selected|token_id};[&tokenid]   --?[$dist] -gt 12|continue   --/|The token is within 60 feet, so add it to the inRange array   --~|array;add;inRange;[&tokenid]   --:continue|   --~tokenid|array;getnext;alltokens   --?[&tokenid] -ne ArrayError|loopCheck   --/|Remove the dummy first item in the inRange array   --~|array;removeat;inRange;0   --/|Loop through the inRange tokens and apply hp   --~tokenid|array;getfirst;inRange   --?[&tokenid] -eq ArrayError|endOutput   --:loopDisplay|   --=SongRest|1d6   -->ApplyHPTokenmod|[&tokenid];[$SongRest.Total]   --/|Put a burst-magic visual effect on impacted tokens   --vtoken|[&tokenid] burst-magic   --~tokenid|array;getnext;inRange   --?[&tokenid] -ne ArrayError|loopDisplay   --:endOutput|   --X|   --/|Subroutine to apply HP with Chatsetattr.   --:ApplyHPTokenmod|Parameters are tokenid;amount   --@modbattr|_charid [*[%1%]:character_id] _HP|+[%2%] _silent   --+|[*[%1%]:character_name] has Been Healed for [%2%] HP!   --<| }} Enjoy!
1620162081
Kurt J.
Pro
API Scripter
ScriptCards v 1.2.2 on the GIST I've had a little time to work on some easy-to-implement items (and a bug fix) that are of interest to some folks, so a new version is up on the Development GIST : Passing empty parameters should once again be supported. You can also use either single or double quotes around parameters that contain a semicolon (I found some regex to parse CSV files and just changed the comma to a semicolon).  You can now set an active page with the --#activepage|pageid setting. If you use " playerpage " as the page id, the current ribbon page will be used (so, --#activepage|playerpage ) or (see next item) --#activepage|[*C:playerpageid] There are two new [*X:] attribute accessing options : [*C:attribute] will retrieve campaign-level attributes. Probably the only really useful one is "playerpageid", but they are all available. [*P:attribute] will retrieve attributes on the activepage (which must be set beforehand). All of the UDL items should be available here, though I don't use UDL so I'm not familiar with them. Retrieving token GMNotes will (with something like [*T:t-gmnotes], or [*-sometokenid:t-gmnotes] will now run the result through decodeURIcomponent to get rid of the URI encoding as return the notes as expected. Formatting like bold and italics, etc. should still work. Please let me know if you run into any unexpected behavior.
I'm going to test the page attributes out right now.  Thanks Kurt!
Here is my test script to grab Page attributes.  Nothing special, just a quick test script, but this new functionality is quite useful for me.  Thanks Kurt! Question:  How do I grab the pageid of the selected token?  Many times as a DM, I'm working on a page different than the one the banner is on.  using the @{selecrted|attribute} format, I've tried t-_pageid , t-pageid , pageid and _pageid .  None are recognized.   Also, I noticed that many of the Boolean attributes only return a value if it is set to TRUE/ON.  Otherwise it returns nothing.   !scriptcards {{ --#title|Page Report --#titleCardBackground|#03038a --#oddRowBackground|#d8d8e6 --#evenRowBackground|#FFFFFF --#buttonbackground|#FFFFFF --#buttontextcolor|#000000 --#buttonbordercolor|#FFFFFF --#bodyFontSize|11px --#whisper|gm --#debug|1 --#sourcetoken|@{selected|token_id} --#activepage|[*C:playerpageid] --+[c]My attempt to get current page (not banner page)[/c] --+PageId(t-pageid)|@{selected|t-pageid} --+PageId(t-_pageid)|@{selected|t-_pageid} --+PageId(_pageid)|@{selected|_pageid} --+PageId(pageid)|@{selected|pageid} --+Campaign playerpageid|[*C:playerpageid] --+Name|[*P:name] --+showgrid|[*P:showgrid] --+showdarkness|[*P:showdarkness] --+showlighting|[*P:showlighting] --+width|[*P:width] --+height|[*P:height] --+snapping_increment|[*P:snapping_increment] --+grid_opacity|[*P:grid_opacity] --+fog_opacity|[*P:fog_opacity] --+background_color|[*P:background_color] --+gridcolor|[*P:gridcolor] --+grid_type|[*P:grid_type] --+scale_number|[*P:scale_number] --+scale_units|[*P:scale_units] --+gridlabels|[*P:gridlabels] --+diagonaltype|[*P:diagonaltype] --+lightupdatedrop|[*P:lightupdatedrop] --+lightenforcelos|[*P:lightenforcelos] --+lightrestrictmove|[*P:lightrestrictmove] --+lightglobalillum|[*P:lightglobalillum] --+dynamic_lighting_enabled|[*P:dynamic_lighting_enabled] --+daylight_mode_enabled|[*P:daylight_mode_enabled] --+explorer_mode|[*P:explorer_mode] --+force_lighting_refresh|[*P:force_lighting_refresh] }}
1620171541

Edited 1620171796
Kurt J.
Pro
API Scripter
Will M. said: Here is my test script to grab Page attributes.  Nothing special, just a quick test script, but this new functionality is quite useful for me.  Thanks Kurt! Question:  How do I grab the pageid of the selected token?  Many times as a DM, I'm working on a page different than the one the banner is on.  using the @{selecrted|attribute} format, I've tried t-_pageid , t-pageid , pageid and _pageid .  None are recognized.   Also, I noticed that many of the Boolean attributes only return a value if it is set to TRUE/ON.  Otherwise it returns nothing.   !scriptcards {{ --#title|Page Report --#titleCardBackground|#03038a --#oddRowBackground|#d8d8e6 --#evenRowBackground|#FFFFFF --#buttonbackground|#FFFFFF --#buttontextcolor|#000000 --#buttonbordercolor|#FFFFFF --#bodyFontSize|11px --#whisper|gm --#debug|1 --#sourcetoken|@{selected|token_id} --#activepage|[*C:playerpageid] --+[c]My attempt to get current page (not banner page)[/c] --+PageId(t-pageid)|@{selected|t-pageid} --+PageId(t-_pageid)|@{selected|t-_pageid} --+PageId(_pageid)|@{selected|_pageid} --+PageId(pageid)|@{selected|pageid} --+Campaign playerpageid|[*C:playerpageid] --+Name|[*P:name] --+showgrid|[*P:showgrid] --+showdarkness|[*P:showdarkness] --+showlighting|[*P:showlighting] --+width|[*P:width] --+height|[*P:height] --+snapping_increment|[*P:snapping_increment] --+grid_opacity|[*P:grid_opacity] --+fog_opacity|[*P:fog_opacity] --+background_color|[*P:background_color] --+gridcolor|[*P:gridcolor] --+grid_type|[*P:grid_type] --+scale_number|[*P:scale_number] --+scale_units|[*P:scale_units] --+gridlabels|[*P:gridlabels] --+diagonaltype|[*P:diagonaltype] --+lightupdatedrop|[*P:lightupdatedrop] --+lightenforcelos|[*P:lightenforcelos] --+lightrestrictmove|[*P:lightrestrictmove] --+lightglobalillum|[*P:lightglobalillum] --+dynamic_lighting_enabled|[*P:dynamic_lighting_enabled] --+daylight_mode_enabled|[*P:daylight_mode_enabled] --+explorer_mode|[*P:explorer_mode] --+force_lighting_refresh|[*P:force_lighting_refresh] }} For whatever reason, there are some attributes that the @{} notation doesn't expose. You can to it in ScriptCards a couple of ways: !script {{   --+Token Page Direct:|[*@{selected|token_id}:t-pageid]   --#sourcetoken|@{selected|token_id}   --+Source Token Page:|[*S:t-pageid] }} The first line uses Token ID referencing, while the other way is to set either source or target token to a token ID. The most straightfoward is probably the first line, as you don't need to mess with sourcetoken or targettoken and then hiding the emotes/icons that those turn on. I noticed the true/nothing thing as well. I would have guessed that they were just uninitialized (undefined in Javascript) if they hadn't been set at all, but turning them on and then off again returns them to nothing... very odd.
1620219298

Edited 1620228966
Thanks again Kurt, that worked - I'll need to store this trick away for future use.   I did update my DM Tools Script to include a UDL Report.  You can find it HERE .
Hi Kurt, I face off a strange behavior with 1.2.2 I use a procedure to display a custom header on my card. Another procedure, that manages skill roll, call the fisrt one passing skillname as parameter. But if I use a conditional branch before calling my custom header proc, a semicolon is added to my skillname parameter. It's should be clearer with an example : Custom header proc (with a debug statement) : --:EnteteCarte|NomImage;Titre --+Debug Entete Carte p1|[%1%] --&gt;GetImageEntete|[%1%] --/|CARD --+|[&amp;ImageEntete] --+|[img]<a href="https://i.imgur.com/Sygo67H.png[/img]" rel="nofollow">https://i.imgur.com/Sygo67H.png[/img]</a> --+|[c][b][%2%][/b][/c] --+|[img]<a href="https://i.imgur.com/Sygo67H.png[/img]" rel="nofollow">https://i.imgur.com/Sygo67H.png[/img]</a> --&lt;| Skill roll, without conditional branch : --:RollSkill|Nom compétence;Nom personnage;estPNJ (0 ou 1);images dés lancés;images dés résultat;texte des résultats --&gt;FormatBase|&nbsp; --+Debug RollSkill p1|[%1%] --/|VARIABLES --&amp;Competence|[%1%] --&amp;Nom|[%2%] --=EstPNJ|[%3%] --&amp;ImageDesLances|[%4%]&nbsp; --&amp;ImageDesResultat|[%5%] --&amp;TexteDesResultat|[%6%]&nbsp; --/|CARD&nbsp; --&gt;EnteteCarte|[&amp;Competence];[#4C9EF5][&amp;Nom][/#] ♦ [#4C9EF5][&amp;Competence][/#] --+|[c][b][&amp;Nom][/b] lance[/c] --+|[c][&amp;ImageDesLances][/c] --+|[img]<a href="https://i.imgur.com/Sygo67H.png[/img]" rel="nofollow">https://i.imgur.com/Sygo67H.png[/img]</a> --+|[c][b][&amp;Resultat][/b][/c] --+|[c][&amp;ImageDesResultat][/c] --~SuggestLen|string;length;[&amp;Suggestions] --?[$SuggestLen] -gt 0|&gt;GenSuggestions --&gt;PiedCarte| --&lt;| Result : Skill roll, with conditional branch : --:RollSkill|Nom compétence;Nom personnage;estPNJ (0 ou 1);images dés lancés;images dés résultat;texte des résultats --&gt;FormatBase|&nbsp; --+Debug RollSkill p1|[%1%] --/|VARIABLES --&amp;Competence|[%1%] --&amp;Nom|[%2%] --=EstPNJ|[%3%] --&amp;ImageDesLances|[%4%]&nbsp; --&amp;ImageDesResultat|[%5%] --&amp;TexteDesResultat|[%6%]&nbsp; --?"[&amp;TexteDesResultat]" -inc Succès|&gt;ResultSucces|&gt;ResultFailed --/|CARD&nbsp; --&gt;EnteteCarte|[&amp;Competence];[#4C9EF5][&amp;Nom][/#] ♦ [#4C9EF5][&amp;Competence][/#] --+|[c][b][&amp;Nom][/b] lance[/c] --+|[c][&amp;ImageDesLances][/c] --+|[img]<a href="https://i.imgur.com/Sygo67H.png[/img]" rel="nofollow">https://i.imgur.com/Sygo67H.png[/img]</a> --+|[c][b][&amp;Resultat][/b][/c] --+|[c][&amp;ImageDesResultat][/c] --~SuggestLen|string;length;[&amp;Suggestions] --?[$SuggestLen] -gt 0|&gt;GenSuggestions --&gt;PiedCarte| --X| --:ResultSucces| --&amp;Resultat|Succès --&lt;| --:ResultFailed| --&amp;Resultat|Echec --&lt;| --&lt;| Result :
1620237990

Edited 1620238049
Hey Kurt, I noticed that Scriptcards Version 1.2.2 has changed how your Fireball macro works. When I run the Fireball macro with Scriptcards&nbsp;1.1.19e, it will take into account immunities against fire, and creatures who make their save only take 1/2 damage. Using Version 1.2.2, resistance, immunity, and made saving throws aren't calculated. It just takes off the entire damage for all of them.&nbsp;
1620240449
Kurt J.
Pro
API Scripter
Dellatosa and DM Gross - I'll figure out what is happening and come up with a fix.
1620250948
Kurt J.
Pro
API Scripter
Version 1.2.2a with Bug Fixes Thanks to Dellatosa and GM Goss for finding bugs in the parameter code. As far as I can tell, I have them all squashed on the latest GIST release (famous last words, I know!) :) For the curious, I messed up parameter numbering, so everything was shifted by 1 in the case of conditionals. I also had a bug that was leaving the separators (;) characters at the end of the parameters. I've tried 1.2.2 with the Fireball script and with several test script for conditionals with parameters as well as case statements. Please let me know if anything isn't working as intended.
Thanks, Kurt. I tried the Fireball macro and there's still one little problem. While Characters that have fire immunity rightly don't take damage, characters that make their saves don't take the 1/2 damage that they should. To make sure it wasn't my setup, I tested it with ScriptCards Ver. 1.1.19e, then I tested it again with Ver. 1.2.2a.&nbsp; This is with Ver 1.1.19e: As you can see, the Bandit Captain made his save and took half damage.&nbsp; Now, with Ver. 1.2.2a: The second Bandit Captain makes his safe, but still takes full damage.&nbsp; Thanks in advance.&nbsp;
1620266525
Kurt J.
Pro
API Scripter
DM Goss said: Thanks, Kurt. I tried the Fireball macro and there's still one little problem. While Characters that have fire immunity rightly don't take damage, characters that make their saves don't take the 1/2 damage that they should. To make sure it wasn't my setup, I tested it with ScriptCards Ver. 1.1.19e, then I tested it again with Ver. 1.2.2a.&nbsp; This is with Ver 1.1.19e: As you can see, the Bandit Captain made his save and took half damage.&nbsp; Now, with Ver. 1.2.2a: The second Bandit Captain makes his safe, but still takes full damage.&nbsp; Thanks in advance.&nbsp; Version 1.2.2b :) One more tweak :) My new regex was treating the \ for integer division incorrectly.&nbsp;
Works like a charm. Thanks, Kurt.
So...complete newbie here. Is there a way to prevent negative numbers inline with a roll. I've browsed through the forums and didn't quite find my answer. I've done it in PowerCards with kh1 but I can't quite get in ScriptCards. I've might have missing something somewhere. I use the below line. The problem is when the armor is more than the damage the output is negative. I've got it working with conditional statements checking the [$Damage]. --=Damage|2 + [$DamageEffortMod] [Damage Effort] - @{target|armor} [Armor]
@ GM TC - not sure what game you are using?&nbsp;I assume it is not DnD 5e as that game doesn't calculate damage that way.&nbsp;&nbsp;
It's Numenera (Cypher System). Light weapons do a static damage of 2.
Michael C. said: @ GM TC - not sure what game you are using?&nbsp;I assume it is not DnD 5e as that game doesn't calculate damage that way.&nbsp;&nbsp; I was able to shorten and simplify the script considerably with the below.&nbsp; --=Damage|2 + [$DamageEffortMod] [Damage Effort] - @{target|armor} [Armor] --?[$Damage] -le 0|=Damage;0 [Armor Absorbed Hit]|=Damage;2 + [$DamageEffortMod] [Damage Effort] - @{target|armor} [Armor]
Kurt J. - not sure if this is part of same problem but I changed the following fireball script line to accommodate a Thunderwave spell (which originates from but does not include caster): &nbsp; &nbsp; --/|Check the distance between the casting token and the current array token. 15 feet is 3 units &nbsp; &nbsp; --~dist|distance;@{selected|token_id};[&amp;tokenid] &nbsp; &nbsp; --?[$dist] -eq 0 -or -gt 3|continue When I changed this it selected all tokens on the page rather than restricting them to targets 1 to 3 spaces away.&nbsp; Remove the "-eq 0 -or&nbsp;" and it restricts the spell to the selected token and any target tokens within 3 spaces.
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Using this example from ScriptCards site: --#title|Case Statement Testing --=Roll|1d4 --C[$Roll.Total]|1:&gt;One;[$Roll]|2:&gt;Two;[$Roll]|3:&gt;Three;[$Roll]|4:&gt;Four;[$Roll] --X| --:One| --+Value|was One ([%1%]) --&lt;| --:Two| --+Value|was Two ([%1%]) --&lt;| --:Three| --+Value|was Three ([%1%]) --&lt;| --:Four| --+Value|was Four ([%1%]) --&lt;| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; I'm trying to make this work without success&nbsp; --+|Begin test [&amp;WeaponType] (code marker) --C [&amp;WeaponType]|Melee:&gt;Melee;&amp;WeaponType|Range:&gt;Range --X| --:Melee|%{Weapon|Attack_Header_Melee} --&lt;| --:Range|%{Weapon|Attack_Header_Range} --&lt;| --+|End test [&amp;WeaponType] (code marker) I tried using quotes around comparisons with no luck. I'm not sure what the --X| does, nor how to close the case statement in case that's an issue. I flanked the code with two vars to see if the suspect code even completed - it did not. If I can't get this to work, I'm afraid to spend time are larger case statements. Thanks ahead of time for any help.