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

1667600186

Edited 1667600366
Kurt J.
Pro
API Scripter
(We reached the maximum number of posts in the&nbsp; Original ScriptCards Thread , so this is a space for continuation of the discussion.)_ ScriptCards is a feature-rich interpreted scripting language implemented as a Roll 20 Mod. ScriptCards programs are written as macros, character abilities, or typed directly into the chat window and support things like variables (including arrays ), ;ooping and branching , conditional statements, interacting with other mod scripts and game objects, code libraries, and lots of other features. Wiki Page:&nbsp; Script:ScriptCards - Roll20 Wiki Current OneClick Version: 2.1.11 (Update to 2.1.19 is pending) Current GitHub (Development) version: 2.1.19 Other GitHub Content:&nbsp; ScriptCards Examples Discord Channel:&nbsp; <a href="https://discord.gg/jSB4wTNpXb" rel="nofollow">https://discord.gg/jSB4wTNpXb</a> ScriptCards is game-system neutral and can be used with any game. It can live alongside its predecessor (PowerCards) without interference, and does not have any conflicts with other scripts that I am aware of. At its most basic, ScriptCards can be used to generate formatted output including any arbitrary text and rolls: There is also a 5E example script available that almost fully automates action selection and execution for PCs and NPCs, called the 5E Character Action Menu, available at&nbsp; <a href="https://github.com/kjaegers/ScriptCards/blob/main/ScriptCards_Examples/dnd5e/5e_Character_Action_Menu.scard" rel="nofollow">https://github.com/kjaegers/ScriptCards/blob/main/ScriptCards_Examples/dnd5e/5e_Character_Action_Menu.scard</a> The 5E Action Menu parses character sheets and creates buttons for actions, attacks, and more, all from a single macro button that is shared across all PCs and NPCs:
I'm looking into converting some of my roll queries used within my script cards into --i information lookup, I've played around with a bit but I'm having some trouble getting the syntax to function correctly.&nbsp; Or perhaps, I'm using it correctly, and it just simply cant do what I'm looking for... I dont want or need the player to be prompted to for more information, the whisper in chat is nice, and even somewhat helpful to explain what is being requested, but, requiring them to click in chat just to continue on and receive the dropdown prompt or the prompt to enter numbers or custom modifiers to a roll is a bit redundant. Is there syntax to skip that, and just have the dialog asking them to enter a number or choose from a dropdown?&nbsp; If not, is there any chance you might consider doing so?
1667732992
Kurt J.
Pro
API Scripter
Toby said: I'm looking into converting some of my roll queries used within my script cards into --i information lookup, I've played around with a bit but I'm having some trouble getting the syntax to function correctly.&nbsp; Or perhaps, I'm using it correctly, and it just simply cant do what I'm looking for... I dont want or need the player to be prompted to for more information, the whisper in chat is nice, and even somewhat helpful to explain what is being requested, but, requiring them to click in chat just to continue on and receive the dropdown prompt or the prompt to enter numbers or custom modifiers to a roll is a bit redundant. Is there syntax to skip that, and just have the dialog asking them to enter a number or choose from a dropdown?&nbsp; If not, is there any chance you might consider doing so? There is no way around the click in the chat, as it is a side-effect of the way Roll20 was designed. The API has no ability to interact with the User Interface in any way other than writing something to chat, so it can't pop something up for the user to respond to. The click in chat is a workaround for that limitation. I completely agree that it would be great if there was another way to get the input from the user, but unless Roll20 modernizes their environment and the API sandbox to allow UI interaction, it just isn't doable right now.
Kurt J. said: I completely agree that it would be great if there was another way to get the input from the user, but unless Roll20 modernizes their environment and the API sandbox to allow UI interaction, it just isn't doable right now. Cool, figured it was something like this, but wasnt sure.&nbsp; Is there any way to cheese the roll queries so that they only display them when its appropriate.&nbsp; Like not prompting a character to "aim" their gun.&nbsp; When using a melee weapon?&nbsp; From what I've seen its normally not possible, since the queries run all at once before everything else.&nbsp; But are there any neat tricks to get around this?
Also, I just wanted to add that I've also been working on a Notepad++ syntax highlighting for ScriptCards to make things easier for myself.&nbsp; I'm not really an expert on creating those highlighting to work so, it doesnt really handle nested conditionals (honestly the really important thing to highlight to keep things readable) but it does highlight alot of useful things like variables, html tags, character sheet attributes (@{attribute}).&nbsp; So it does help.&nbsp; I'd be happy to share if that something that people would be interested in having?&nbsp; Or if other people have made a more complete version, I'd love to use that instead.
No cheats or hacks, sorry.&nbsp;&nbsp; The best I have been able to do is have all my requests in 1 --I statement.&nbsp; &nbsp;
1667866128
Kurt J.
Pro
API Scripter
ScriptCards 2.1.19b is headed to OneClick The latest revision of ScriptCards has been merged on the Roll20 github and will be updated automatically when the next sync happens. I have done an update pass on the Wiki to include the latest updates. Here is a consolidated list of the changes since the last OneClick push (2.1.11): &nbsp;String settings commands (--&amp;, --~|string, --? with a &amp; result, etc.) have been updated to allow array element references to be set with them, so "--&amp;fruits(1)|watermelon" will set the second element (the indexes start at 0) to "watermelon"). If the array does not exist, it will be created. If the element index is greater than the highest index in the array, the element will be added to the array. If the index is negative, the element will be added to the beginning of the array. If the index exists within the array, the current value for that element will be replaced. When rolling on rollable tables [T#TableName], if the weights on all of the table entries are 1, the "dice roll" number will be saved to the .Total and .Base values for the roll variable. If any of the weights is greater than 1, both will be set to 0. Additionally, the .Text and .RollText values are now filled in as well, with the .Text being set to the same value as .tableEntryText Added the "removecustom" subfunction for the turnorder Allows for the removal, by custom name, of a custom entry in the turn tracker. Ex: &nbsp; --~|turnorder;removecustom;Round Counter Added the ability to add an additional parameter to array;objects:type;filter to specify a character id for the object if it is appropriate. For example, to find all abilities for a given character:&nbsp; &nbsp; &nbsp; --~|array;objects:ability;AbilArray;;@{selected|character_id} Added the --w (wait) command, with two methods of operation. --w#| (ie, --w#5|) will sleep the sandbox for the indicated number of seconds (max 10). This is of limited usefulness, and multiple delays could cause Roll20 to think the sandbox has entered an infinite loop. The second option is --w#: followed by a regular ScriptCards command, which will set up a timed call of that command and continue processing. For example, &nbsp; --w5:a|CureLightWounds would run/process the script normally and cause the audio track "CureLightWounds" to play 5 seconds later. This can be used to time vfx and audio, move tokens, etc. If the delayed line is a direct output line (--+ or --*) it will be displayed after the delay as a no-title mini card. Variable referencing is handled at the time the command is created (not when it is run), and each delayed command can only be a single line that doesn't know anything about the original card or other delayed commands. Expanded the object creation feature of the --! command to allow attributes to be created and to allow rows to be added to repeating sections. See the github changelog or the wiki for details.
1667884624
Andrew R.
Pro
Sheet Author
I posted a 13th Age Glorantha monster ScriptCard as an example in the previous thread. I've updated it to use the --~ command, so I'm reposting it.&nbsp; !scriptcard {{ --Lsettings|RuneChaos --#title|Slaying Early, Slaying Often --+|The Crimson Bat takes the first turn in the battle; set its first initiative count one higher than the highest initiative character --+|Then it takes its second turn on an initiative count 5 less, a third turn on an initiative count 10 less, and a fourth turn on a count 15 less --iScriptCards needs additional information to continue;Click to provide information|q;Highest;What is the highest initiative? --=Turn|[&amp;Highest] + 1 --%LoopCount|0;3;1 --=Less|[&amp;LoopCount] * 5 --=Initial|[$Turn] - [$Less] --~|turnorder;addcustom;Crimson Bat;[$Initial] --%|LoopCount --~|turnorder;sort }}
Kurt,&nbsp; You mentioned in Keith's Supernotes thread that Scriptcards can call these templates. How would one do that?&nbsp; Thanks!
Hola, Can someone show me an example of of !setattr in Scriptcards to add a new attribute to a sheet. I am using the 5e sheet. I can update an attribute with "native" Scriptcard syntax however I need to add-one on the fly. I get errors with either --sel(_sel) or --name(_name), thx much
1667942472
Kurt J.
Pro
API Scripter
joeuser said: Hola, Can someone show me an example of of !setattr in Scriptcards to add a new attribute to a sheet. I am using the 5e sheet. I can update an attribute with "native" Scriptcard syntax however I need to add-one on the fly. I get errors with either --sel(_sel) or --name(_name), thx much I don't have a good example using setattr, but the ScriptCards --! command supports adding attributes if you prefix the attribute name with !: --!a:@{selected|token_id}|dndstyling:on|size:enormous|!attitude:epic will update dndstyling and size, but will update or create &nbsp;attitude.
1667942615
Kurt J.
Pro
API Scripter
Erik M. said: Kurt,&nbsp; You mentioned in Keith's Supernotes thread that Scriptcards can call these templates. How would one do that?&nbsp; Thanks! The version of Supernotes containing the templates isn't public yet (with the templates moved to be accessible outside Supernotes). When that hits, I'll have version 2.2.0 of ScriptCards ready that can use them. I have that fully functional right now, as well as a system for adding your own templates via a mule character.
Kurt, Thanks very much! I'll give it a whirl! Fantastic API script in Scriptcards btw.&nbsp; thanks again!
joeuser said: Hola, Can someone show me an example of of !setattr in Scriptcards to add a new attribute to a sheet. I am using the 5e sheet. I can update an attribute with "native" Scriptcard syntax however I need to add-one on the fly. I get errors with either --sel(_sel) or --name(_name), thx much --@setattr|_silent _charid [*S:character_id] _PowerPoints|[$PowerPoints] _Spells|[$Spells] _unspentPowerPoints|[$PowerPoints] This is from my Shadowrun game, but is a good example.
1667961948
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Kurt J. said: Erik M. said: Kurt,&nbsp; You mentioned in Keith's Supernotes thread that Scriptcards can call these templates. How would one do that?&nbsp; Thanks! The version of Supernotes containing the templates isn't public yet (with the templates moved to be accessible outside Supernotes). When that hits, I'll have version 2.2.0 of ScriptCards ready that can use them. I have that fully functional right now, as well as a system for adding your own templates via a mule character. No one has reported any issues with it, so I will create the Pull Request for it, and it should be available after next Tuesday's merge.
1668012420
Kurt J.
Pro
API Scripter
joeuser said: Kurt, Thanks very much! I'll give it a whirl! Fantastic API script in Scriptcards btw.&nbsp; thanks again! joeuser - I've uploaded version 2.2.0a to my Github ( <a href="https://github.com/kjaegers/ScriptCards/tree/main/ScriptCards_API" rel="nofollow">https://github.com/kjaegers/ScriptCards/tree/main/ScriptCards_API</a> ), which allows you to use Keith's templates if you have his beta code installed. If all goes well, I'll submit a pull request for this update so the OneClick release matches the Supernotes release. The simplest instructions: add --#overridetemplate|templatename anywhere in your script to use a template. Template names are case sensitive (they are all lowercase so far) and, as the name suggests, completely override any other --# settings that alter the visual appearance of the output. For more details check the changelog in the github.
Kurt, I'd be happy to test it. I use Scriptcards extensively so won't be a problem. I'll post some updates shortly. thx
1668021829
Kurt J.
Pro
API Scripter
joeuser said: Kurt, I'd be happy to test it. I use Scriptcards extensively so won't be a problem. I'll post some updates shortly. thx Reading back up, I see I got my replies crossed :) Erik M. had asked about the templates :) Same info applies, though! Any testing/feedback anyone has would be greatly appreciated.
Kurt, I am assuming that all formatting is done inside the script? I put together a simple script to test. A couple of things (maybe user error). The title card works with custom text, however I cannot reference @{selected|token} in the title statement. No title statement results in Scriptcard text. Formatting of text, trying to use left alignment doesn't appear to work. The text is centered (see image). !script {{ --/Template Testing script &nbsp;--#overridetemplate|scroll --/#title|@{selected|token_name} --#title|Galen the Armorer --+|[img]<a href="https://usercontent.one/wp/kirileonard.com/wp-content/uploads/2022/05/how_to_find_an_illustrator_for_your_dnd_character.jpg[/img]" rel="nofollow">https://usercontent.one/wp/kirileonard.com/wp-content/uploads/2022/05/how_to_find_an_illustrator_for_your_dnd_character.jpg[/img]</a> --+|[l]Galen resides the in the town of Fortuna. He hails from the Dwarven city of Bil Thoram in the Vormhim Mountains. He is the proprietor of The Burnished Anvil Armory. Given his Dwarven ancestry, Galen has a reputation as fair yet shrewd bargainer.[/l] &nbsp;--#overridetemplate|scroll --x| }}
1668023138
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Depending on where formatting happens, either my templates or Kurt's script will likely come into conflict. I'm not sure which has supremacy.
Keith, Using your Supernotes script, formatting the GMNotes resolves that problem. Is that imbedded HTML? Templates look fantastic.&nbsp;
Steve H., thanks for the example. Perfect.
1668035042
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
joeuser said: Keith, Using your Supernotes script, formatting the GMNotes resolves that problem. Is that imbedded HTML? Templates look fantastic.&nbsp; Supernotes passes most embedded html that comes from GMNotes fields. The templates will override some things like margins, font sizes and choices, etc. CSS can get very complicated very quickly (witness some of the Dark Mode difficulties Roll20 has had, which I feel are mostly caused by conflicting dependencies. Using the default sheet roll templates (in Supernotes) is pretty foolproof, but the amount of formatting that the custom templates impose can cause unexpected results if you get too creative. And thank you!
1668035674

Edited 1668035694
Kurt J.
Pro
API Scripter
I have fixed the left justification problem... Version 2.2.0b is on the repo. For some reason I was using spans instead of divs - but only for left justification. Right and center were divs. Probably never got noticed because there was no need to left justify since it was the default :) I haven't been able to duplicate the token name issue unless I remove the token's name or drag an image from the Art Library directly instead of the Characters list. That creates a token without a name. !script {{ &nbsp; --/|Template Testing script &nbsp; --#overridetemplate|scroll &nbsp; --#title|@{selected|token_name} &nbsp; --+|[img]<a href="http://www.twentysidedblog.com/misc/Odug.png[/img]" rel="nofollow">http://www.twentysidedblog.com/misc/Odug.png[/img]</a> &nbsp; --+|[l]Odug has wandered the Forgotten Realms for more than a century, expanding his knowledge of the arcane arts and finding trouble wherever he goes.[br][br]He has established a small tower a few miles outside of Candlekeep to stash the products of his adventures and ensure he is close to the research facilities there.[/l] &nbsp; --x| }} Gives me (I set up Stable Diffusion so I had it generate me a portrait, and just threw in some text):
Kurt J. said: I have fixed the left justification problem... Version 2.2.0b is on the repo. For some reason I was using spans instead of divs - but only for left justification. Right and center were divs. Probably never got noticed because there was no need to left justify since it was the default :) I haven't been able to duplicate the token name issue unless I remove the token's name or drag an image from the Art Library directly instead of the Characters list. That creates a token without a name. !script {{ &nbsp; --/|Template Testing script &nbsp; --#overridetemplate|scroll &nbsp; --#title|@{selected|token_name} &nbsp; --+|[img]<a href="http://www.twentysidedblog.com/misc/Odug.png[/img]" rel="nofollow">http://www.twentysidedblog.com/misc/Odug.png[/img]</a> &nbsp; --+|[l]Odug has wandered the Forgotten Realms for more than a century, expanding his knowledge of the arcane arts and finding trouble wherever he goes.[br][br]He has established a small tower a few miles outside of Candlekeep to stash the products of his adventures and ensure he is close to the research facilities there.[/l] &nbsp; --x| }} Gives me (I set up Stable Diffusion so I had it generate me a portrait, and just threw in some text): Kurt(Odug),&nbsp; Excellent. Looks good. I'll keep testing. thx much
1668037346
Kurt J.
Pro
API Scripter
Odug Ututees is what happens when you just leave the default Roll20 generated names on your test characters :) I have a game full of mostly unpronounceable random named characters.
Kurt J. said: Odug Ututees is what happens when you just leave the default Roll20 generated names on your test characters :) I have a game full of mostly unpronounceable random named characters. Kurt, Oh sure!! :-) Been there. thx again Reijo Ruotsalainen
1668051284

Edited 1668051406
Toby
Pro
I'm having a slight issue with a value not displaying in a scriptCards, no matter what I attempt it comes out on the sheet as Undefined.&nbsp; I have checked multiple times, I have the spelling accurate, caps accurate, and have tried to have it display as both a string &amp; and a number $.&nbsp; It doesnt matter.&nbsp; Both ways seem to fail to produce an actual result. My code is as follows, only the bolded sections are relevant (i think). HTML: &lt;input type="hidden" name="attr_tou-mod" value="[[floor(@{tou-base}/10)]] [Toughness Mod]" title="Toughness Modifier"&gt; ScriptCards: !scriptcards {{ --/| === ScriptCard Layout for Damage Rolls === |\-- --/| === Dark Heresy 1e / With Homebrew&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;|\-- --/| === Version 1.0a&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=== |\-- --/| === Date: 11/09/2022&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=== |\-- --/| Local Variables --|\ --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --/| ===== Roll Queries / Information Lookup =========== |\ --&amp;AimType|?{Aim | No aim (+0),+0 | Half aim (+10),+10| Full aim (+20),+20} --=AimTypeNum|[&amp;AimType] --&amp;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} --&amp;HitLocation|?{Hit Location|Head, Head|Left Arm, LeftArm|Right Arm, RightArm|Body, Body|Left Leg, LeftLeg|Right Leg, RightLeg} --/| ===== Convert RQ Value into int variables --=AtkModNum|[&amp;AtkMod] --=AimTypeNum|[&amp;AimType] --=RangeNum|[&amp;RangeType] --=RoFNum|[&amp;RoFType] --&amp;DoSNum|?{Degrees of Success?|0} --/| ===== Degrees of Success --&amp;DoSNum|?{Degrees of Success?|0} --=DegSuccess|[&amp;DoS] --/| ===== Strings =========== |\ --&amp;AtkName|@{atkName} --/| ===== Weapon Proficiency Full Display =========== |\ --?@{wProficiency} -eq Yes|Yes --?@{wProficiency} -eq No|No --:Yes| --&amp;wProficiency|Yes --^wProficiencyDisplayDone| --:No| --&amp;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| --&amp;DmgTypeDisplay|Energy --^DMGTypeDone| --:I| --&amp;DmgTypeDisplay|Impact --^DMGTypeDone| --:R| --&amp;DmgTypeDisplay|Rending --^DMGTypeDone| --:X| --&amp;DmgTypeDisplay|Explosive --^DMGTypeDone| --:N| --&amp;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| --&amp;wClassDisplay|Basic --^wClassDisplayDone| --:Heavy| --&amp;wClassDisplay|Heavy --^wClassDisplayDone| --:Melee| --&amp;wClassDisplay|Melee --/| Melee Penalty is a stopgap measure to counter the Point Blank Bonus of the Range. --=MeleePenalty|-30 --^wClassDisplayDone| --:Pistol| --&amp;wClassDisplay|Pistol --^wClassDisplayDone| --:Thrown| --&amp;wClassDisplay|Thrown --^wClassDisplayDone| --:wClassDisplayDone| --=RLCritM|[*T:RightLegCritDam^] --/| ===== Functions =========== |\ --~sqRange|distance;@{selected|token_id};@{target|token_id} --=Range|[$sqRange] [Squares] * 1 [meters] --=RoFNum|[&amp;RoFType] --/| ===== Numbers =========== |\ --=DmgPen|@{penetration} --&amp;DamageRoll|@{damage} --&amp;DamageMod|@{damagemod} --&amp;TotalDam|@{damage}!+@{damagemod} --=FinalDamRoll|0 --=TBon|[*T:tou-mod] --=HAV|[*T:headArmourvalue] --=LAAV|[*T:LeftArmArmourvalue] --=BAV|[*T:BodyArmourvalue] --=RAAV|[*T:RightArmArmourvalue] --=LLAV|[*T:LeftLegArmourvalue] --=RLAV|[*T:RightLegArmourvalue] --=HSoak|[*T:armor-head-soak] --=LASoak|[*T:armor-leftarm-soak] --=BSoak|[*T:armor-body-soak] --=RASoak|[*T:armor-rightarm-soak] --=LLSoak|[*T:armor-leftleg-soak] --=RLSoak|[*T:armor-rightleg-soak] --=HCrit|[*T:headCritDam] --=LACrit|[*T:LeftArmCritDam] --=BCrit|[*T:BodyCritDam] --=RACrit|[*T:RightArmCritDam] --=LLCrit|[*T:LeftLegCritDam] --=RLCrit|[*T:RightLegCritDam] --=HCritM|[*T:headCritDam^] --=LACritM|[*T:LeftArmCritDam^] --=BCritM|[*T:BodyCritDam^] --=RACritM|[*T:RightArmCritDam^] --=LLCritM|[*T:LeftLegCritDam^] --=RLCritM|[*T:RightLegCritDam^] --/| ===== SOAK DETAILS ===========&nbsp; --?[&amp;HitLocation] -eqi Head|H --?[&amp;HitLocation] -eqi LeftArm|LA --?[&amp;HitLocation] -eqi Body|B --?[&amp;HitLocation] -eqi RightArm|RA --?[&amp;HitLocation] -eqi LeftLeg|LL --?[&amp;HitLocation] -eqi RightLeg|RL --:H| --&amp;LocDisplay|Head --=LocAV|[$HAV] --=LocSoak|[$HSoak] --^LocationDone| --:LA| --&amp;LocDisplay|Left Arm --=LocAV|[$LAAV] --=LocSoak|[$LASoak] --^LocationDone| --:RA| --&amp;LocDisplay|Right Arm --=LocAV|[$RAAV] --=LocSoak|[$RASoak] --^LocationDone| --:B| --&amp;LocDisplay|Body --=LocAV|[$BAV] --=LocSoak|[$BSoak] --^LocationDone| --:LL| --&amp;LocDisplay|Left Leg --=LocAV|[$LLAV] --=LocSoak|[$LLSoak] --^LocationDone| --:RL| --&amp;LocDisplay|Right Leg --=LocAV|[$RLAV] --=LocSoak|[$RLSoak] --^LocationDone| --:LocationDone| --/| === DAMAGE CALCULATIONS === --=DmgPen|@{penetration} --=LocPen|[$LocAV] - [$DmgPen] {MIN:0} --/| ===== ACCURATE QUALITY =========== |\ --=DegSuccess|[&amp;DoSNum] --=AccuracyNumDice|[$DegSuccess] / 2 {MAX:2} --?[$AimTypeNum] -gt 0 -and @{q-accurate} -eq 1|Accurate --?[$AimTypeNum] -eq 0 -or&nbsp; @{q-accurate} -eq 0|NoAccurate --:Accurate| --&amp;DmgAccurate|[$AccuracyNumDice]d10! [Accurate] --^AccurateDone| --/| Fail Catch not working..... --:NoAccurate| --&amp;DmgAccurate|0 --^AccurateDone| --:AccurateDone| --=DmgAccurate|[&amp;DmgAccurate] --/| ===== TEARING QUALITY =========== |\ --/|&nbsp; &nbsp;===== The Tearing Quality Cannot be Implemented at this Time. --/| @@@ FINAL DAMAGE ROLL ===================================== |\ --=TotalSoak|[$TBon] + [$LocPen] --=FinalDamRoll|@{damage}!+@{damagemod} --/| TITLE and FORMATTING --#title|[&amp;AtkName] Damage --#titlecardbackground|#993333 --#leftsub|LEFT SUB --#rightsub|RIGHT SUB --#emoteText|[*S:t-name] damages [*T:t-name] --=[$LocArm] --/| === 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][&amp;wClassDisplay][/c][/td][td][c][&amp;DmgTypeDisplay][/c][/td][td][c]@{damage}[/c][/td][td][c][$DmgPen][/c][/td][/tr][/t]| --+|[c] ● [&amp;LocDisplay] ● [/c] --+[t border=1 width=100%] [tr] [td][c]Toughness[/c][/td] [td][c]Armor[/c][/td] [td][c]Pen[/c][/td] [td][c]Soak[/c][/td] [/tr] [tr] [td][c][$TBon][/c][/td] [td][c][$LocArm][/c][/td] [td][c][$LocPen][/c][/td] [td][c][$TotalSoak][/c][/td] [/tr] [/t]| --+|[b]Tou:[/b] [$TBon] [b]AV:[/b] [$LocAV] [b]Weap Pen[/b] [$DmgPen] --+|[c] ● DMG Details ● [/c] --+|[f18][c][b][$FinalDamRoll] + [$DmgAccurate][/b][/c][/f] --+Degrees of Success|[$DegSuccess] }} &nbsp; Yes, I am also aware that the code is probably a mess, I will prettify it later and perhaps go over it to see if I can make it less... bulky.&nbsp; Although, I'm not truly sure that its possible.&nbsp; But it doesn't matter, the player will never see this code anyway.
Which item is undefined?
1668120329
Kurt J.
Pro
API Scripter
Version 2.2.0c is up on the repo with a small fix for a crash when loading custom templates from a template mule if the custom template is not formatted as the code was expecting. Also, 2.2.0 is now queued up to go to OneClick next week along with Keith's Supernotes mod, which will allow ScriptCards to use his templates
1668120470

Edited 1668120494
Kurt J.
Pro
API Scripter
@Toby - if you create a small script that just tries to output the value you are looking for from the character sheet, what do you get? By that, I mean: !script {{ --+|[*@{target|token_id}:tou-mod] }} (Assuming tou-mod is what you are looking to resolve.)
1668125747

Edited 1668125803
Toby
Pro
Kurt J. said: @Toby - if you create a small script that just tries to output the value you are looking for from the character sheet, what do you get? By that, I mean: !script {{ --+|[*@{target|token_id}:tou-mod] }} (Assuming tou-mod is what you are looking to resolve.) That is, and it comes out as UNDEFINED. Although, when I use --=TBon|@{targeted|tou-mod} it does seem to work. Though, I've been told that it is better to use the [*T:tou-mod] for the way the scriptcards works (dont ask why, I dont understand, they said it was about how the program processes stuff).
What do you get in the console log when you debug this miniscript? Toby said: Kurt J. said: @Toby - if you create a small script that just tries to output the value you are looking for from the character sheet, what do you get? By that, I mean: !script {{ --+|[*@{target|token_id}:tou-mod] }} (Assuming tou-mod is what you are looking to resolve.) That is, and it comes out as UNDEFINED. Although, when I use --=TBon|@{targeted|tou-mod} it does seem to work. Though, I've been told that it is better to use the [*T:tou-mod] for the way the scriptcards works (dont ask why, I dont understand, they said it was about how the program processes stuff).
1668238137

Edited 1668245923
Toby
Pro
So.. !script {{ --+|[*@{target|token_id}:tou-mod] }} No longer comes back as Undifined, I dont know what changed..&nbsp; I didnt alter it in any way, maybe a scriptCards Update?&nbsp; Instead the output in chat is: floor(tou-base/10) And the console log gives me: jquery-1.9.1.js:2796 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See <a href="https://www.chromestatus.com/feature/5745543795965952" rel="nofollow">https://www.chromestatus.com/feature/5745543795965952</a> add @ jquery-1.9.1.js:2796 jQuery.event.add @ jquery.migrate.js:394 (anonymous) @ jquery-1.9.1.js:3622 each @ jquery-1.9.1.js:648 each @ jquery-1.9.1.js:270 on @ jquery-1.9.1.js:3621 d20.token_editor.do_showRadialMenu @ vtt.bundle.js:26551 Ae @ vtt.bundle.js:24013 Hope that helps. Edit: Is this a issue with how ScriptCards is coded, or this something I am doing wrong?&nbsp; Just Curious.
1668248148
Kurt J.
Pro
API Scripter
Toby said: So.. !script {{ --+|[*@{target|token_id}:tou-mod] }} No longer comes back as Undifined, I dont know what changed..&nbsp; I didnt alter it in any way, maybe a scriptCards Update?&nbsp; Instead the output in chat is: floor(tou-base/10) And the console log gives me: jquery-1.9.1.js:2796 [Violation] Added non-passive event listener to a scroll-blocking 'touchstart' event. Consider marking event handler as 'passive' to make the page more responsive. See <a href="https://www.chromestatus.com/feature/5745543795965952" rel="nofollow">https://www.chromestatus.com/feature/5745543795965952</a> add @ jquery-1.9.1.js:2796 jQuery.event.add @ jquery.migrate.js:394 (anonymous) @ jquery-1.9.1.js:3622 each @ jquery-1.9.1.js:648 each @ jquery-1.9.1.js:270 on @ jquery-1.9.1.js:3621 d20.token_editor.do_showRadialMenu @ vtt.bundle.js:26551 Ae @ vtt.bundle.js:24013 Hope that helps. Edit: Is this a issue with how ScriptCards is coded, or this something I am doing wrong?&nbsp; Just Curious. ScriptCards doesn't have a way to deal with calculated fields like that. It is asking Roll20 for the attribute and getting the formula for the attribute instead of the end value. ScriptCards then won't know what "tou-base" is because it is a reference internal to the character sheet (it isn't identified with a character - the character sheet system knows it is the current character when processing it, but that information isn't provided outside the character sheet). If you don't need to deal with multiple tokens, the easiest thing to do is just use @{target|tou-mod}. That works around this limitation by letting the chat server figure out what the final number is and just passing that into the script. Alternatively, if you need to potentially access multiple tokens, you can simply do the calculation in ScriptCards: --=TBon|[*T:tou-base] / 10 {FLOOR} Which will result in the same number (assuming tou-base is just a number and not another calculated field). I've thought a few times about coming up with a way to convert/translate these types of fields, but every time I've tried I've run into issues with what comes back from Roll20 to the API. It is sometimes just console log spam, but I'd like to avoid that if possible.
Ah, well--that makes-- well honestly, it doesnt really make sense to me since I'm not a programmer =^.^=.&nbsp; But, I can understand that the system has limitations :D&nbsp; Thanks very much for explaining, I will use @{targeted|name} for calculated fields, until I can get my sheet workers, functioning.&nbsp; I have a template code for calculating ability scores.&nbsp; Which brings me to my next question... If I use SheetWorkers to calculate the fields, can ScriptCards handle those calculated fields? Also, is this issue possibly the reason why I cannot use quick buttons to execute repeating sections, by quick buttons I mean:&nbsp; These attack buttons function 100% as intended on the Custom Sandbox games, but when I migrate them to live, it doesn't reflect all of the values accurately.&nbsp; I'm still trying to research the issue to bring it to r20's team.&nbsp; Because, the whole point of the Custom Sandbox is to build and test games, and tbh.&nbsp; If the sheets dont function the same, its not really fulfilling its purpose. PS, I need these quick buttons so I can create templates where I can create character buttons for up to like 3-4 repeating weapons, it saves me literally hours worth of work building npcs, so I dont need to open every single sheet each time I want to make a roll. I just have to select the token and hit the button.
1668266868
Kurt J.
Pro
API Scripter
Unfortunately, I can't be much help with the workings of sheets/sheet design. I've never looked at that process. I have had a little time this morning and started reviving my code to parse attributes with nested references, and that is actually coming along, but it won't make it in with testing before the API push to OneClick next week.
can scriptcard retrieve the default image (avatar for example) of a token to be inserted in a [img] command ?
1668272788

Edited 1668272816
Kurt J.
Pro
API Scripter
Lionel V. said: can scriptcard retrieve the default image (avatar for example) of a token to be inserted in a [img] command ? It depends on what you mean by the default image. Character Avatars, yes. Token image, yes, but getting the image from a character's default token, no. This is because the _defaulttoken property of a character is a JSON string that is stored as a blob (like bio and notes) and can't be directly retrieved. For the other two, however: !script {{ --+[c]Token Image[/c]| --&amp;TokenImageURL|[*@{selected|token_id}:t-imgsrc] --+Token Image|URL:[&amp;TokenImageURL] --+|[img][&amp;TokenImageURL][/img] --+[c]Avatar[/c]| --&amp;AvatarImageURL|[*@{selected|character_id}:avatar] --+Avatar Image|URL:[&amp;AvatarImageURL] --+|[img][&amp;AvatarImageURL][/img] }} Note that while the URLs do get stored in the string variables, if you just output them, the Roll20 chat server will convert them to an image directly. That is why I have prefixed them with URL: on the --+ lines so the text will get displayed.
1668325161

Edited 1668325834
Can rollhilightcolol be used multiple times? To set the box in each output line in a seperate color? like: --#rollhilightcolornormal|#8FA4D4 --+ |@{selected|token_name} attacks with skill [$SKILL] --#rollhilightcolornormal|#FFAAAA --+ |Dealing [$DAM] damage. Only last color gets used setting all boxes in red.
1668513801
Kurt J.
Pro
API Scripter
Kaspar K. said: Can rollhilightcolol be used multiple times? To set the box in each output line in a seperate color? like: --#rollhilightcolornormal|#8FA4D4 --+ |@{selected|token_name} attacks with skill [$SKILL] --#rollhilightcolornormal|#FFAAAA --+ |Dealing [$DAM] damage. Only last color gets used setting all boxes in red. I'll check to see why it would be doing that. The setting is listed as a per-line, so I'm not sure if I got that wrong or if there is an issue with it in the code.
1668516751
Kurt J.
Pro
API Scripter
ScriptCards 2.2.0 Is Now Live on OneClick The latest version of ScriptCards is now available on OneClick&nbsp; and now supports templates that override the visual appearance of an output card. These are based on the Genre Templates in Keithcurtis' Supernotes 0.2.0 &nbsp;(also available on OneClick). If you have Supernotes installed, you will gain access to the 11 templates it contains. ScriptCards itself adds three templates to the mix, and you can define your own templates via a mule character. The image below shows the same ScriptCard script with a different override template specified for each run: To utilize a template, simply set the --#overridetemplate| option to the desired template (or "none" if you want to specify none, though that is the default setting).&nbsp; The templates from Keith's mod are: generic , dark , gothic , crt , steam , scroll , apoc , faraway , lcars , notebook and western . ScriptCards defines: dnd5e , dnd1e_green , dnd1e_amber -&nbsp; Note that these last three were really for testing purposes on extending the library and they (especially the dnd1e templates) may not be very visually appealing :) As Keith adds additional styles to Supernotes, they will be automatically become available in ScriptCards. Note that using a template really is an override - none of your appearance settings (titlefont, button styles, etc.) will be used when displaying a ScriptCard with an override template. A template consists of six sections of CSS code (Keith defines two more that aren't used by ScriptCards): boxcode , titlecode , textcode , buttonwrapper , buttonstyle , and footer . Note that in ScriptCards case, the buttonwrapper is output right before the end of the card and doesn't actually do anything with buttons - it simply allows for the footer to be in the right spot. It should still be included to match the div counts, however. If you wish to define your own templates, create a character called ScriptCards_TemplateMule (case sensitive) and create an ability with the name of your template. The text of the ability MUST be constructed carefully, and I'll include a sample below. Essentially, you need one line for each of the six sections, with all "&lt;" and "&gt;" characters replaced with "{" and "}". Note that this means you won't be able to use curly braces inside the template. Each line begins with the name of the section (ie, boxcode ) followed by two colons (::). Each line ends with two vertical bars (||). Leading spaces in the line will be removed automatically, as will line breaks. I suggest working on your styles in something like Notepad++ and pasting them over. ScriptCards does not actively monitor the template mule, so after making changes you will need to run !sc-reloadtemplates from the chat window to refresh any templates the mule contains (this happens automatically during sandbox startup as well). Here is a simple example: (I'm not saying it *looks* good :)) boxcode::{div style='background-color: #18769c; box-shadow: 0 0 3px #fff; display: block; text-align: left; font-size: 13px; padding: 5px;&nbsp; margin-bottom: 2px; color: black; font-family: sans-serif; white-space: pre-wrap; line-height:1.3em; font-style:normal'}|| titlecode::{div style='margin: 0.5em 1em 0.25em 1em; font-size: 16px; font-variant: small-caps; font-family: "Goblin One", sans-serif; color: #000;&nbsp; display: block; margin-block-start: 1em; margin-block-end: 0; margin-inline-start: 0px; margin-inline-end: 0px; font-weight: bold;'}|| textcode::{/div}{div}{div style='font-weight: normal; display: block; margin: 0 1em 0 1em;'}|| buttonwrapper::{div style='display:block;'}|| buttonstyle::style='display:inline-block; font-size: 10px; color:#000; padding: 2px 0px 2px 0px; background-color: transparent; border: 1px solid black;&nbsp; text-align: center; border-radius: 0px;'|| footer:: Several additional style line options are available on the Template Mule templates as well. These are slightly different than the Supernotes style lines but expand on them by allowing you to define style information for the subtitle, table components, and the h1..h5 HTML constructs (now parsed from [h1]...[/h1] thru [h5]...[/h5] by ScriptCards' inline formatting processor). These style lines are added to a Template Mule ability as before except that they should only include the options that would go inside a style='...' block and not use single quotes (the are used to wrap the style block). The piece keys for these styles are: subtitlestyle , tablestyle , trstyle , thstyle , tdstyle , h1style , h2style , h3style , h4style , and h5style . Example: subtitlestyle::font-size:24pt; font-family:Impact; color:red; If you give a template mule ability the same name as an existing Supernotes/ScriptCards built-in style, you can override individual pieces of the style following the guidelines above.
@Kurt (and Keith!) This is really cool! Question, though: would it be possible to change templates mid-scripting, to present two different cards with two different templates, without starting a new script?
1668625433

Edited 1668626107
Hi all, I can't seem to get token-mod to apply the damage of a previously targeted-selected ((... --i;select target|t;__;__ ...)). --@token-mod|_ids [&amp;EB-Target] _ignore-selected _set bar1_value|-[$TDAM] For context, I'm creating a card for Marvel Multiverse RPG, to: choose a power -- select a target -- input roll value (branched to crit outcome) -- apply damage full code, sorry for the mess: !scriptcard {{ --/Eye Beam, Cyclopes --#sourcetoken|-NGkazTUBF65pIkmRyPR --#reentrant|1 --#title|Eye Beam --+|[rbutton]make attack::Attack;4[/rbutton] --X| --:Attack| --i;select target|t;EB-Target;Choose Target --#title|Eye Beam vs [*[&amp;EB-Target]:t-name] --#targettoken|[&amp;EB-Target] --+|Ranged Attack, Agility +[*S:agility_action] --+|[rbutton]Regular::Roll;1[/rbutton][rbutton]Fantastic::Roll;2[/rbutton][rbutton]Marvelous::Roll;3[/rbutton] --X| --:Roll| --#emotetext| --c[&amp;reentryval]|1:&gt;Regular|2:&gt;Fantastic|3:&gt;Marvelous --X| --:Regular| --i Make Regular Attack ;roll|q;rolled;Attack Roll||q;MDIER;Marvel Die --+|[$rolled] --&lt;| --:Fantastic| --#emotetext|FANTASTIC! --iRegular Attack;roll|q;RROLLT;Attack Roll --&lt;| --:Marvelous| --#emotetext|MARVELOUS! --=REGDAM|7+[*S:agility_action] --=REGDAM2|[$REGDAM]*2 --=BONUSDAM|[$REGDAM2]*[*S:rank] --=MDAM|[$BONUSDAM] --+Damage|[$MDAM] --+|[rbutton]Damage::Damage;[$MDAM][/rbutton] --&lt;| --:Damage| --#emotetext| --=TDAM|[&amp;reentryval] --@token-mod|_ids [&amp;EB-Target] _ignore-selected _set bar1_value|-[$TDAM] --+|[$TDAM] Damage to [*T:t-name] --X| --/END }} Currently, the damage will due nothing because of '--ignore-selected'. Without it, it will do the damage to the currently selected token, instead of the token previously selected in the --:Attack branch. Also I could use pointers everywhere. Specifically I can't seem to do equations within a single line, so I've separated each math function to a different line. Is it also possible to bypass the button prompt for inputs (--i_;_|q;_;_).&nbsp;
1668634460

Edited 1668634579
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Kurt J. said: ScriptCards 2.2.0 Is Now Live on OneClick The latest version... This makes me happy. I'm glad they can be used like this by other scripts. I like the DnD5e. I'll have to make something similar for direct use in Supernotes.
I think you've made this much more complicated than it needs to be. Is there any reason that you can't identify the target at the beginning of your script? For instance: !scriptcard {{ --/Eye Beam, Cyclopes --#sourcetoken|-NGkazTUBF65pIkmRyPR --#targettoken|@{target|Eye Beam Fired at|token_id} ...rest of script Also, make sure each &nbsp;line has a | character. Your first and last lines do not. I'd also caution against hard-coding the source token, because any time you switch to a different page, the same character's token is going to be different, so the token id will change. I suppose that's not really an issue if you don't need to affect the source token, but if that's the case I don't think you need to use the source token at all? Best practice tip: your reentrant should be more particular to this particular script card, since you might have more than one script running through the sandbox at a time, and if two different scripts both use the same reentrant value, they'll collide. Lastly: it looks like not all your damage roll subroutines lead to the token-mod subroutine. Kyle D. said: Hi all, I can't seem to get token-mod to apply the damage of a previously targeted-selected ((... --i;select target|t;__;__ ...)). --@token-mod|_ids [&amp;EB-Target] _ignore-selected _set bar1_value|-[$TDAM] For context, I'm creating a card for Marvel Multiverse RPG, to: choose a power -- select a target -- input roll value (branched to crit outcome) -- apply damage full code, sorry for the mess: !scriptcard {{ --/Eye Beam, Cyclopes --#sourcetoken|-NGkazTUBF65pIkmRyPR --#reentrant|1 --#title|Eye Beam --+|[rbutton]make attack::Attack;4[/rbutton] --X| --:Attack| --i;select target|t;EB-Target;Choose Target --#title|Eye Beam vs [*[&amp;EB-Target]:t-name] --#targettoken|[&amp;EB-Target] --+|Ranged Attack, Agility +[*S:agility_action] --+|[rbutton]Regular::Roll;1[/rbutton][rbutton]Fantastic::Roll;2[/rbutton][rbutton]Marvelous::Roll;3[/rbutton] --X| --:Roll| --#emotetext| --c[&amp;reentryval]|1:&gt;Regular|2:&gt;Fantastic|3:&gt;Marvelous --X| --:Regular| --i Make Regular Attack ;roll|q;rolled;Attack Roll||q;MDIER;Marvel Die --+|[$rolled] --&lt;| --:Fantastic| --#emotetext|FANTASTIC! --iRegular Attack;roll|q;RROLLT;Attack Roll --&lt;| --:Marvelous| --#emotetext|MARVELOUS! --=REGDAM|7+[*S:agility_action] --=REGDAM2|[$REGDAM]*2 --=BONUSDAM|[$REGDAM2]*[*S:rank] --=MDAM|[$BONUSDAM] --+Damage|[$MDAM] --+|[rbutton]Damage::Damage;[$MDAM][/rbutton] --&lt;| --:Damage| --#emotetext| --=TDAM|[&amp;reentryval] --@token-mod|_ids [&amp;EB-Target] _ignore-selected _set bar1_value|-[$TDAM] --+|[$TDAM] Damage to [*T:t-name] --X| --/END }} Currently, the damage will due nothing because of '--ignore-selected'. Without it, it will do the damage to the currently selected token, instead of the token previously selected in the --:Attack branch. Also I could use pointers everywhere. Specifically I can't seem to do equations within a single line, so I've separated each math function to a different line. Is it also possible to bypass the button prompt for inputs (--i_;_|q;_;_).&nbsp;
1668654564

Edited 1668654607
Side question: I have a scriptcard I got from the forums. It calls Alterbar to auto deduct HP from the target. How would I replace the line to use TokenMod and deduct from Bar1 ? The original line is: &nbsp; --@alter|_target|@{target|token_id} _bar2| _amount|-[$Damage]
1668654632

Edited 1668698550
I am trying to get just the player characters on a page in a script that I cobbled together from other peoples scripts, to run a passive perception check on the group. The filter on pagetokens with the "pc" option I thought would do this but it doesn't work for me. User error maybe? script follows. Any help would be appreciated. thx !scriptcard {{ --#debug|0 --#title|GM Group Perception Check &nbsp;--#whisper|gm --&amp;hitPointsBar|3 --&amp;TokenType|pc --/| --~|array;pagetokens;alltokens;@{target|token_id};[&amp;TokenType] --~tokenid|array;getfirst;alltokens --?[&amp;tokenid] -eq ArrayError|endOutput --:loopCheck| &nbsp; --/|Skip targets&nbsp; --?[*[&amp;tokenid]:t-layer] -ne objects|continue --?"[*[&amp;tokenid]:t-represents]" -ninc "-"|continue --?[*[&amp;tokenid]:t-bar[&amp;hitPointsBar]_value] -le 0|continue --&gt;DoPerception|[&amp;tokenid] --:continue| --~tokenid|array;getnext;alltokens --?[&amp;tokenid] -ne ArrayError|loopCheck --X| --:DoPerception| --=PP|[*[&amp;tokenid]:passive_wisdom] ​--+[*[&amp;tokenid]:character_name]|[$PP] --&lt;| --:Exit| --X| }} resolved. Never mind :-)
1668656515

Edited 1668656795
al e. said: Side question: I have a scriptcard I got from the forums. It calls Alterbar to auto deduct HP from the target. How would I replace the line to use TokenMod and deduct from Bar1 ? The original line is: &nbsp; --@alter|_target|@{target|token_id} _bar2| _amount|-[$Damage] Try this... !script {{ &nbsp; --#hidecard| --@token-mod| _set bar1_value|-[$Damage] _ids @{selected|token_id} }}
1668659741

Edited 1668671312
Thanks Colin for the pointers, I'll make some edit now.&nbsp; I'll answer the questions and make some clarifications of my goals with this script. I'll record a .gif to communicate it more clearly, especially on what is going on right now with this script. I'll actually just make a new thread and edit this one with the link. Thanks again.&nbsp; Update
1668730475

Edited 1668737205
Kurt J. said: I'll check to see why it would be doing that. The setting is listed as a per-line, so I'm not sure if I got that wrong or if there is an issue with it in the code. !script {{ --#hideTitleCard|1 --#nominmaxhighlight|1 --=AttackRoll|3d6 --=DamageRoll|1d6+2 --#rollhilightcolornormal|#11E1A2 --+ |attack [$AttackRoll] --#rollhilightcolornormal|#6666A2 --+ |dealing [$DamageRoll] damage }} The last color specified gets applied to all boxes in all lines. Also, how do I access the max value of an atribute? @{selected|atribute_max}, @{selected|atribute|max} or @{selected|atribute^} did not work.