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

1613418612
David M.
Pro
API Scripter
Wow, that's a lot! The case statement is a great idea! Also, the single-line functions (return statements on same line) are handy. Not sure if we could always do that, but good to know! Thanks for the nod with the &SendingPlayerID string variable, btw. That meta-data (potentially combined with getSelected) helps out with certain subordinate script calls. The Procedure Library is another really interesting idea, just a lot to take in at first glance. I usually like to see everything that is happening in a given macro on the same page, but I can see how it could make complex scriptcard generation easier once you got the hang of it. 
1613419116
David M.
Pro
API Scripter
Side note: I think the wiki is missing some --# parameters. For example, titleFontColor seems to be a valid parameter but is missing from the wiki. Not sure if there are others. I tried a couple from your defaultParameters constant within the script code (e.g. titleFontColor, subtitleFontColor, tableBorderRadius), with mixed results. I didn't do a full cross-check, though, so not sure how many others are missing documentation.
1613419259
Kurt J.
Pro
API Scripter
David M. said: Wow, that's a lot! The case statement is a great idea! Also, the single-line functions (return statements on same line) are handy. Not sure if we could always do that, but good to know! Thanks for the nod with the &SendingPlayerID string variable, btw. That meta-data (potentially combined with getSelected) helps out with certain subordinate script calls. The Procedure Library is another really interesting idea, just a lot to take in at first glance. I usually like to see everything that is happening in a given macro on the same page, but I can see how it could make complex scriptcard generation easier once you got the hang of it.  The single-line functions were always possible... I just started writing them that way for the library to make the post shorter :) Whitespace isn't too critical in a ScriptCard since it all gets jammed onto a single line when processing anyway.
1613419347
Kurt J.
Pro
API Scripter
David M. said: Side note: I think the wiki is missing some --# parameters. For example, titleFontColor seems to be a valid parameter but is missing from the wiki. Not sure if there are others. I tried a couple from your defaultParameters constant within the script code (e.g. titleFontColor, subtitleFontColor, tableBorderRadius), with mixed results. I didn't do a full cross-check, though, so not sure how many others are missing documentation. Yea, some are definitely unused as the original list was copied over from PowerCards. I removed most of the ones I didn't end up using, but you are right... There are some that work but are missing from the Wiki. I'll do a full review of them and update the Wiki.
1613420597
David M.
Pro
API Scripter
I figure that was the case. No worries, you've had your hands full! With so many features, stuff was bound to fall through the cracks re: documentation.
1613424646
Kurt J.
Pro
API Scripter
I've posted the beginnings of my 5E Tools library on the Wiki. It includes three procedures : Lib5E_CheckDamageModifiers (show in the post above), Lib5E_DeductSpellSlot (fairly obvious), and Lib5E_FindResource (which will take a resource name and bring back the attribute names for the name and value attributes as well as the value itself. It checks both the repeating and the non-repeating resources, so it should be a one-stop-shop for accessing resources).
1613425084

Edited 1613425169
David M.
Pro
API Scripter
You might want to list any script dependencies to the library list on the wiki. Looks like DeductSpellSlot requires ChatSetAttr. EDIT - I just saw the note in the actual library code, but might be good to put it in the description above it anyway.
1613432091
David M.
Pro
API Scripter
Kurt, can you give a simple example of the string replace function is use? I'm sure I am missing something stupid with these built-in functions. Also, not sure if this has been addressed, but looks like the roll tooltip is adding an extra + or - sign when there are scalar modifiers or roll+roll math. !script {{ --=Roll1|1d6 + 2 --=Roll2|1d6 - 4 --=Roll3|[$Roll1]+[$Roll2] --+Roll1 =|[$Roll1] --+Roll2 =|[$Roll2] --+Roll3 =|[$Roll3] }}
1613435541
Kurt J.
Pro
API Scripter
David M. said: Kurt, can you give a simple example of the string replace function is use? I'm sure I am missing something stupid with these built-in functions. Also, not sure if this has been addressed, but looks like the roll tooltip is adding an extra + or - sign when there are scalar modifiers or roll+roll math. !script {{ --=Roll1|1d6 + 2 --=Roll2|1d6 - 4 --=Roll3|[$Roll1]+[$Roll2] --+Roll1 =|[$Roll1] --+Roll2 =|[$Roll2] --+Roll3 =|[$Roll3] }} I'm not sure where that is coming from :) I'll have to trace through the roll parser, but I'll get it fixed. As far as the replace function, here is my full script for testing the string functions: !script {{ --#title|String Manipulation --&Test|Hello World! --~length|stringfuncs;strlength;[&Test] --~before|stringfuncs;before; ;[&Test] --~after|stringfuncs;after; ;[&Test] --~replace|stringfuncs;replace;World;There;[&Test] --~left|stringfuncs;left;5;[&Test] --~right|stringfuncs;right;6;[&Test] --~substring|stringfuncs;substring;3;5;[&Test] --~splits|stringfuncs;split; ;[&Test] --~badleft|stringfuncs;left;5;[&doesnotexist] --~badright|stringfuncs;right;5;[&doesnotexist] --~badbefore|stringfuncs;before; ;[&doesnotexist] --~badafter|stringfuncs;after; ;[&doesnotexist] --~badreplace|stringfuncs;replace;World;There;[&doesnotexist] --~badsubstring|stringfuncs;substring;3;5;[&doesnotexist] --~badsplits|stringfuncs;split; ;[&doesnotexist] --~allspaces|stringfuncs;replace; ; ;[&doesnotexist] --+Length|[$length] --+After|[&after] --+Before|[&before] --+Replace|[&replace] --+Left|[&left] --+Right|[&right] --+Substring|[&substring] --+Splits|[$splitsCount] --+Splits1|[&splits1] --+Splits2|[&splits2] }} There are some statements in here intentionally wrong so I can see if a bad entry crashes the sandbox, but here is the relevant line: --~replace|stringfuncs;replace;World;There;[&Test] So after "stringfuncs" (which can be just "string" or "strings", and "replace" is what text you are looking for in the string, followed by what you want to replace that text with (so in this case, we'll look for "World" and replace it with There". The last parameter is the string we are checking. The source string isn't modified, but the result is returned to a new variable (&replace) in this case.
Kurt J.  said: Here is an example of handling damage modifications (resistance, vulnerability, and immunity) in D&D 5E with a library: !script {{     +++5E Tools+++     --#|Damage Modifiers Test     --#targettoken|@{target|token_id}     -->Lib5E_CheckDamageModifiers|ResistType;fire     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] fire damage       -->Lib5E_CheckDamageModifiers|ResistType;cold     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] cold damage       -->Lib5E_CheckDamageModifiers|ResistType;poison     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] poison damage     -->Lib5E_CheckDamageModifiers|ResistType;acid     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] acid damage     --X| }} Library content (In a handout called “ScriptCards Library 5E Tools”  NOTE:  Paste into Notepad first and then paste into the handout in Roll20 to avoid bringing over HTML formatting from the web site) : --/|ScriptCards Library: 5E Tools version 0.0.1 --/|Provides various utility procedures for D&D 5E games   --/|Lib5E_CheckDamageModifiers handle damage resistance, vulnerability, and immunity. --/|Pass a string variable to be filled with a string to be appended to a dice roll and the damage type     --:Lib5E_CheckDamageModifiers|damageVariableName;damageType --&[%1%]| --?"[*T:npc_vulnerabilities]" -inc "[%2%]"|>_Lib5E_IsVulnerable;[%1%] --?"[*T:npc_resistances]" -inc "[%2%]"|>_Lib5E_IsResistant;[%1%] --?"[*T:npc_immunities]" -inc"[%2%]"|>_Lib5E_IsImmune;[%1%] --<| --:_Lib5E_IsVulnerable| --&[%1%]| * 2 [Vulnerable] --<| --:_Lib5E_IsResistant| --&[%1%]| \ 2 [Resistant] --<| --:_Lib5E_IsImmune| --&[%1%]| * 0 [Immune] --<| T he idea is that the functions in the library create a string that can be appended to a roll to modify the output based on resistances, so you pass Lib5E_CheckDamageModifiers the name of the string variable you want to use and the damage type. The variable (ResistType in this case) will include either nothing, “* 2 [Vulnerable]”, “\ 2 [Resistant]”, or “* 0 [Immune]” which can be included in a roll assignment (--=) to modify the damage as appropriate. The order here might be important if an NPC is misconfigured to be both resistant and immune to the same damage type. Since immune is an absolute, having it last ensures that it will override resistant or vulnerable. A creature that is both vulnerable and resistant (again, misconfigured) will come back as resistant since that condition is checked after vulnerable. First of all, this is AWESOME! Im sorry to bother u man, but im noob with scripts!! Everything working, except for immunities... but i cant get why!
1613512538
Kurt J.
Pro
API Scripter
Bicio said: Kurt J.  said: Here is an example of handling damage modifications (resistance, vulnerability, and immunity) in D&D 5E with a library: !script {{     +++5E Tools+++     --#|Damage Modifiers Test     --#targettoken|@{target|token_id}     -->Lib5E_CheckDamageModifiers|ResistType;fire     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] fire damage       -->Lib5E_CheckDamageModifiers|ResistType;cold     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] cold damage       -->Lib5E_CheckDamageModifiers|ResistType;poison     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] poison damage     -->Lib5E_CheckDamageModifiers|ResistType;acid     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] acid damage     --X| }} Library content (In a handout called “ScriptCards Library 5E Tools”  NOTE:  Paste into Notepad first and then paste into the handout in Roll20 to avoid bringing over HTML formatting from the web site) : --/|ScriptCards Library: 5E Tools version 0.0.1 --/|Provides various utility procedures for D&D 5E games   --/|Lib5E_CheckDamageModifiers handle damage resistance, vulnerability, and immunity. --/|Pass a string variable to be filled with a string to be appended to a dice roll and the damage type     --:Lib5E_CheckDamageModifiers|damageVariableName;damageType --&[%1%]| --?"[*T:npc_vulnerabilities]" -inc "[%2%]"|>_Lib5E_IsVulnerable;[%1%] --?"[*T:npc_resistances]" -inc "[%2%]"|>_Lib5E_IsResistant;[%1%] --?"[*T:npc_immunities]" -inc"[%2%]"|>_Lib5E_IsImmune;[%1%] --<| --:_Lib5E_IsVulnerable| --&[%1%]| * 2 [Vulnerable] --<| --:_Lib5E_IsResistant| --&[%1%]| \ 2 [Resistant] --<| --:_Lib5E_IsImmune| --&[%1%]| * 0 [Immune] --<| T he idea is that the functions in the library create a string that can be appended to a roll to modify the output based on resistances, so you pass Lib5E_CheckDamageModifiers the name of the string variable you want to use and the damage type. The variable (ResistType in this case) will include either nothing, “* 2 [Vulnerable]”, “\ 2 [Resistant]”, or “* 0 [Immune]” which can be included in a roll assignment (--=) to modify the damage as appropriate. The order here might be important if an NPC is misconfigured to be both resistant and immune to the same damage type. Since immune is an absolute, having it last ensures that it will override resistant or vulnerable. A creature that is both vulnerable and resistant (again, misconfigured) will come back as resistant since that condition is checked after vulnerable. First of all, this is AWESOME! Im sorry to bother u man, but im noob with scripts!! Everything working, except for immunities... but i cant get why! Can you post your script and what creature you are evaluating?
And to think... I literally just got to the point I can actually kinda use power cards. (I am really bad at macroing/API's) now there is something more powerful but what about the macro system, I was using to use with power cards? would a simple change to script cards on the macro simply change the use or will I have to learn a whole new system? I am very green at learning this. 
1613551362

Edited 1613551806
So I found this thread today and I had fun making a price rolling script to check how much items cost, then one of my players got an Artifact which requires them to roll 1d6 twice to determine their alignment. I thought, cool! I can make a script for that, maybe. Long story short, I'm stuck. Please help? !scriptcard {{ --#title|Rowan's Alignment --#titlecardbackground|#606c9b --#whisper|gm --=RollFirst|1d6 --=RollSecond|1d6 --?[$RollFirst] -eq 1|>Lawful --?[$RollFirst] -eq 2|>Lawful --?[$RollFirst] -eq 3|>Neutral1 --?[$RollFirst] -eq 4|>Neutral1 --?[$RollFirst] -eq 5|>Chaotic --?[$RollFirst] -eq 6|>Chaotic --:SecondR --?[$RollSecond] -eq 1| ?Second|Good --?[$RollSecond] -eq 2| ?Second|Good --?[$RollSecond] -eq 3| &Second|Neutral --?[$RollSecond] -eq 4| &Second|Neutral --?[$RollSecond] -eq 5| &Second|Evil --?[$RollSecond] -eq 6| &Second|Evil --|>Result --:Lawful| --&FirstA|Lawful --|> SecondR --:Neutral1| --&FirstA|Neutral --|> SecondR --:Chaotic| --&FirstA|Chaotic --|> SecondR --:Result| --+|Today you rolled [$RollFirst] and [$RollSecond]. --+|This means you are [&FirstA] [$Second] today. }} This is as far as I've got, once I finally got it to output text I wanted with [&FirstA] I decided to extend and add Neutral and Chaotic, but now all it does is return Chaotic. I thought I had got around it by telling it to go back up to --:SecondR and once done with it to go to Result, buuuuut it's not working. Do I need to move the whole of the SecondR section below the Law/Neutral/Chaotic stuff? I'll give that a go, maybe it doesn't like going backward to do SecondR stuff I FIGURED IT OUT. !scriptcard {{ --#title|Rowan's Alignment --#titlecardbackground|#606c9b --#whisper|gm --=RollFirst|1d6 --=RollSecond|1d6 --?[$RollFirst] -eq 1|>Lawful --?[$RollFirst] -eq 2|>Lawful --?[$RollFirst] -eq 3|>Neutral1 --?[$RollFirst] -eq 4|>Neutral1 --?[$RollFirst] -eq 5|>Chaotic --?[$RollFirst] -eq 6|>Chaotic --?[$RollSecond] -eq 1|>Good --?[$RollSecond] -eq 2|>Good --?[$RollSecond] -eq 3|>Neutral2 --?[$RollSecond] -eq 4|>Neutral2 --?[$RollSecond] -eq 5|>Evil --?[$RollSecond] -eq 6|>Evil -->Result| --:Lawful| --&FirstA|Lawful --<| --:Neutral1| --&FirstA|Neutral --<| --:Chaotic| --&FirstA|Chaotic --<| --:Good| --&SecondA|Good --<| --:Neutral2| --&SecondA|Neutral --<| --:Evil| --&SecondA|Evil --<| --:Result| --+|Today you rolled [$RollFirst] and [$RollSecond]. --+|This means you are [b][&FirstA] [&SecondA][/b] today. }} I love this api script, I'm looking forward to doing other things with it.
1613559210
David M.
Pro
API Scripter
Great, Zayvi! Vayne, most of the syntax is going to be different, but it's also pretty intuitive. The biggest thing to get used to if you don't have a programming background is the use of procedures. However, they are not required, and you could jump around with gotos if you wanted to. Another big difference that might be a little different to get used to if you're coming from Powercards is that you can't directly assign a variable or print output on the same line as a conditional. You will have to call a branch (procedure or goto). So, "If my roll is a 20, print this line" might become, "If my roll is a 20, call this function that prints a line". Overall I think it's worth the investment to learn, though. Check out the examples in the wiki and on this thread, and feel free to post here if you have specific questions. Good luck!  
1613560041
Duncan R.
Pro
Sheet Author
David M. said: Great, Zayvi! Vayne, most of the syntax is going to be different, but it's also pretty intuitive. The biggest thing to get used to if you don't have a programming background is the use of procedures. However, they are not required, and you could jump around with gotos if you wanted to. Another big difference that might be a little different to get used to if you're coming from Powercards is that you can't directly assign a variable or print output on the same line as a conditional. You will have to call a branch (procedure or goto). So, "If my roll is a 20, print this line" might become, "If my roll is a 20, call this function that prints a line". Overall I think it's worth the investment to learn, though. Check out the examples in the wiki and on this thread, and feel free to post here if you have specific questions. Good luck!   Never used Powercards myself, jumped straight into Scripcards, but I wonder if it is worth Kurt putting a 'Migrating from Powercard differences' section in the wiki.
1613566488
Kurt J.
Pro
API Scripter
Duncan R. said: David M. said: Great, Zayvi! Vayne, most of the syntax is going to be different, but it's also pretty intuitive. The biggest thing to get used to if you don't have a programming background is the use of procedures. However, they are not required, and you could jump around with gotos if you wanted to. Another big difference that might be a little different to get used to if you're coming from Powercards is that you can't directly assign a variable or print output on the same line as a conditional. You will have to call a branch (procedure or goto). So, "If my roll is a 20, print this line" might become, "If my roll is a 20, call this function that prints a line". Overall I think it's worth the investment to learn, though. Check out the examples in the wiki and on this thread, and feel free to post here if you have specific questions. Good luck!   Never used Powercards myself, jumped straight into Scripcards, but I wonder if it is worth Kurt putting a 'Migrating from Powercard differences' section in the wiki. I started a section in the Wiki on this. It is a work in progress, and of course anyone is free to update it as well.
1613570287
David M.
Pro
API Scripter
Kurt, what are your thoughts on adding a "does not include" string comparison to complement -inc? I know we could probably use an if/then/else with -inc and just leave the true branch blank or send to a null procedure, but it would be more succinct if "does not include" was its own option.
1613572485

Edited 1613583539
Kurt J. said: Bicio said: Kurt J.  said: Here is an example of handling damage modifications (resistance, vulnerability, and immunity) in D&D 5E with a library: !script {{     +++5E Tools+++     --#|Damage Modifiers Test     --#targettoken|@{target|token_id}     -->Lib5E_CheckDamageModifiers|ResistType;fire     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] fire damage       -->Lib5E_CheckDamageModifiers|ResistType;cold     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] cold damage       -->Lib5E_CheckDamageModifiers|ResistType;poison     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] poison damage     -->Lib5E_CheckDamageModifiers|ResistType;acid     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] acid damage     --X| }} Library content (In a handout called “ScriptCards Library 5E Tools”  NOTE:  Paste into Notepad first and then paste into the handout in Roll20 to avoid bringing over HTML formatting from the web site) : --/|ScriptCards Library: 5E Tools version 0.0.1 --/|Provides various utility procedures for D&D 5E games   --/|Lib5E_CheckDamageModifiers handle damage resistance, vulnerability, and immunity. --/|Pass a string variable to be filled with a string to be appended to a dice roll and the damage type     --:Lib5E_CheckDamageModifiers|damageVariableName;damageType --&[%1%]| --?"[*T:npc_vulnerabilities]" -inc "[%2%]"|>_Lib5E_IsVulnerable;[%1%] --?"[*T:npc_resistances]" -inc "[%2%]"|>_Lib5E_IsResistant;[%1%] --?"[*T:npc_immunities]" -inc"[%2%]"|>_Lib5E_IsImmune;[%1%] --<| --:_Lib5E_IsVulnerable| --&[%1%]| * 2 [Vulnerable] --<| --:_Lib5E_IsResistant| --&[%1%]| \ 2 [Resistant] --<| --:_Lib5E_IsImmune| --&[%1%]| * 0 [Immune] --<| T he idea is that the functions in the library create a string that can be appended to a roll to modify the output based on resistances, so you pass Lib5E_CheckDamageModifiers the name of the string variable you want to use and the damage type. The variable (ResistType in this case) will include either nothing, “* 2 [Vulnerable]”, “\ 2 [Resistant]”, or “* 0 [Immune]” which can be included in a roll assignment (--=) to modify the damage as appropriate. The order here might be important if an NPC is misconfigured to be both resistant and immune to the same damage type. Since immune is an absolute, having it last ensures that it will override resistant or vulnerable. A creature that is both vulnerable and resistant (again, misconfigured) will come back as resistant since that condition is checked after vulnerable. First of all, this is AWESOME! Im sorry to bother u man, but im noob with scripts!! Everything working, except for immunities... but i cant get why! Can you post your script and what creature you are evaluating? Im running the ''TEST'' script u linked with the 5E Library handout. On an ancient white dragon, a mummy and a specter (5e sheet)! !script {{     +++5E Tools+++     --#|Damage Modifiers Test     --#targettoken|@{target|token_id}     -->Lib5E_CheckDamageModifiers|ResistType;fire     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] fire damage       -->Lib5E_CheckDamageModifiers|ResistType;cold     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] cold damage       -->Lib5E_CheckDamageModifiers|ResistType;poison     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] poison damage     -->Lib5E_CheckDamageModifiers|ResistType;acid     --=DamageRoll|2d10 [&ResistType]     --+Test:|[$DamageRoll] acid damage     --X| }} And tbh im not able to incorporate this in a macro.... could u make an example? maybe with different types of damage in a single attack (like piercing and fire or something like that)? Thanks! EDIT: I got how to incorporate it! Thanks anyway! Still i cant understand why IMMUNE is not working while RESISTANT or VULNERABLE are. Here's my macro: !scriptcard {{ +++5E Tools+++ --#title|Thunder Gauntlets --#leftsub|Melee Attack --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#emoteText|@{selected|token_name} attacks @{target|token_name} --=TargetAC|@{target|npc_ac} --?[$TargetAC.Total] -gt 0|DoneWithAC --=TargetAC|@{target|ac} --:DoneWithAC| --=AttackRoll|?{Attack|Standard,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1} + @{selected|intelligence_mod} [INT] + @{selected|pb} [PROF] --+Attack|@{selected|token_name} rolls [$AttackRoll] vs AC. --?[$AttackRoll.Base] -eq 20|Crit --?[$AttackRoll.Base] -eq 1|Fumble --?[$AttackRoll.Total] -ge [$TargetAC.Total]|Hit --+Miss|The attack missed. --^Final| --:Fumble| --+Fumble!|The attack went horribly wrong. --@roll20AM|_audio,play,nomenu|Epic Fail --^Final| --:Hit| -->Lib5E_CheckDamageModifiers|ResistType;thunder --=Damage|1d8 + @{selected|intelligence_mod} [INT] [&ResistType] --+Hit!|The attack hit @{target|token_name} for [$Damage] thunder damage. --@alter|_target|@{target|token_id} _bar|1 _amount|-[$Damage] --^Final| --:Crit| -->Lib5E_CheckDamageModifiers|ResistType;thunder --=Damage|1d8 + @{selected|intelligence_mod} [INT] + 1d8 [CRIT] [&ResistType] --+Critical Hit!|The attack hit @{target|token_name} for [$Damage] thunder damage. --@roll20AM|_audio,play,nomenu|Thunder --@alter|_target|@{target|token_id} _bar|1 _amount|-[$Damage] --:Final| }}
This will make one project I've been putting off with PowerCards much easier to handle! I have several players who are not good at remembering what they are able to do with their action economy. At a physical table, it's easy enough to deal with just by putting someone next to them who is better at that aspect of the game: they can talk quietly and not interrupt the flow. But playing remotely, cross-talk is terrible, and focus lags. My solution has been to develop a combat reminder macro that fires on the token's turn. Using CombatMaster2.0, I can tell it to run the macro at the start of the turn. With ScriptCards, I can make this interface much more succinctly. However: I run into entirely unrelated problems when attempting to run an API without any parameters. So, for example, this fails: !scriptcard {{ --@short-rest| }} The !short-rest command comes from "5E Resting in Style" -- no parameters are required.
Colin C. said: This will make one project I've been putting off with PowerCards much easier to handle! I have several players who are not good at remembering what they are able to do with their action economy. At a physical table, it's easy enough to deal with just by putting someone next to them who is better at that aspect of the game: they can talk quietly and not interrupt the flow. But playing remotely, cross-talk is terrible, and focus lags. My solution has been to develop a combat reminder macro that fires on the token's turn. Using CombatMaster2.0, I can tell it to run the macro at the start of the turn. With ScriptCards, I can make this interface much more succinctly. However: I run into entirely unrelated problems when attempting to run an API without any parameters. So, for example, this fails: !scriptcard {{ --@short-rest| }} The !short-rest command comes from "5E Resting in Style" -- no parameters are required. I've had similar issues with the !longrest command from the OGL Companion (which also doesn't require parameters) failing when called from within a Scriptcard. 
Can anyone advise on how to create a Scriptcard for player initiative? How would one call the &{tracker} option from within a scriptcard? 
1613598624
Kurt J.
Pro
API Scripter
Colin C. said: This will make one project I've been putting off with PowerCards much easier to handle! I have several players who are not good at remembering what they are able to do with their action economy. At a physical table, it's easy enough to deal with just by putting someone next to them who is better at that aspect of the game: they can talk quietly and not interrupt the flow. But playing remotely, cross-talk is terrible, and focus lags. My solution has been to develop a combat reminder macro that fires on the token's turn. Using CombatMaster2.0, I can tell it to run the macro at the start of the turn. With ScriptCards, I can make this interface much more succinctly. However: I run into entirely unrelated problems when attempting to run an API without any parameters. So, for example, this fails: !scriptcard {{ --@short-rest| }} The !short-rest command comes from "5E Resting in Style" -- no parameters are required. I'll look into how to fix this, but in the mean time, you might be able to do this: --e|!short-rest The --e command just sends whatever you send it along to chat, If you need to send "as" someone, you might need to include the sender in the tag: --eFred the Wizard|!short-rest or --e@{selected|character_name}|!short-rest
1613600209
David M.
Pro
API Scripter
I was looking into --e| (though not for script calls), and seems like it is not *quite* the same as sending directly to chat. For example, inline rolls are not parsed properly by the chat parser (printing [[$0]] in chat window, and stuff like the initiative tracker Jay was asking about doesn't seem to register either. My original thought was maybe using scriptcards for logic only (using --#hideCard), but outputting with a character sheet template. Even with html replacements, it just printed the text of the template rather than the formatted output. Probably just how the character sheets intercept such messages. 
1613601873

Edited 1613601948
Kurt J.
Pro
API Scripter
David M. said: I was looking into --e| (though not for script calls), and seems like it is not *quite* the same as sending directly to chat. For example, inline rolls are not parsed properly by the chat parser (printing [[$0]] in chat window, and stuff like the initiative tracker Jay was asking about doesn't seem to register either. My original thought was maybe using scriptcards for logic only (using --#hideCard), but outputting with a character sheet template. Even with html replacements, it just printed the text of the template rather than the formatted output. Probably just how the character sheets intercept such messages.  It also can't send information about selected tokens along since that isn't something the API can manipulate. The issue with inline rolls is that they are getting processed by the chat server before you get to echo them (before ScriptCards gets them - scriptcards actually sees the [[$0]] instead of the roll). You can work around this by doing something like --&String|[ --&String|+[1d20] --&String|+] --e|[&String] Though that is a little inconvenient :) Oh, and yea, -ninc is on my list for the next update :)
David M. said: I was looking into --e| (though not for script calls), and seems like it is not *quite* the same as sending directly to chat. For example, inline rolls are not parsed properly by the chat parser (printing [[$0]] in chat window, and stuff like the initiative tracker Jay was asking about doesn't seem to register either. My original thought was maybe using scriptcards for logic only (using --#hideCard), but outputting with a character sheet template. Even with html replacements, it just printed the text of the template rather than the formatted output. Probably just how the character sheets intercept such messages.  Thanks for checking, David. I'll likely just stick with my non-scriptcard initiative macro for now, then. It's a purely aesthetic issue, in any case; I just dislike how the rolls appear in the OGL roll template. :)
1613610226
David M.
Pro
API Scripter
Kurt J. said: Oh, and yea, -ninc is on my list for the next update :) :D
1613616675

Edited 1613619990
How can I add a new line to content without a new line in the script? I'm trying to do something like: !scriptcard {{ --+Tag|Content <br> More Content }} I know I could  do !scriptcard {{ --+Tag|Content --+|More Content }} But that makes it so I have to break up string variables. In slightly longer form: !scriptcard {{ --&String|Content --&String|+ More Content --+Tag|[&String] }} But I want the string to appear on two separate lines when the card is output. I might be able to work it with using the string functions, like maybe delimiters? But I'm not sure the most succinct way to structure the direct output lines so that I capture all of the pieces without knowing in advance how many pieces there would be. Would something like an output loop work for that? Similar to the resource find loop, or the health check loop? The point of this exercise is that I want to create a "Combat Reminder" macro for my more, *ahem* absent-minded  players, that will check their various class abilities and put them into a card for them to reference on their turn. E.g., Barb 3/Paladin 2/Rogue 7 has various actions, bonus actions, and reactions. This seems to work: !scriptcard {{ --#whisper|gm --&String|+^^Text --&String|+^^Texty Text --&String|+^^TexMex Texty Text --&String|+^^TexMex Text --&String|+^^Tex --+Final String|[&String] --=Num|2 --~String|string;split;^^;[&String] --+StringCount|[$StringCount] --:StringLoop| --?[$Num.Total] -gt [$StringCount]|Done --+String Piece [$Num.Total]|[&String[$Num.Total]] --=Num|[$Num] + 1 -->StringLoop| --:Done| --+Done| --X| }} I had to cheat a little and start with 2, rather than 1, because I'm starting with a delimiter, but I have to because I would only ever append text to the string variable--I'd never just start with anything other than a blank string.
1613622239

Edited 1613622289
David M.
Pro
API Scripter
EDIT - ninja'd! That's what I get for not refreshing after I walk away from the computer! Something like this should work !scriptcard {{ --&String|Element1/Element2/Element3/Element4 --+Full String =|[&String] --:CREATE ARRAY OF STRING VARIABLES| --~splits|string;split;/;[&String] --:SET COUNTER AND START LOOPING| --=NumLoops|[$splitsCount]+1 --=i|1 --:Loop| --+Item [$i.Total]|[&splits[$i.Total]] --=i|[$i]+1 --?[$i] -lt [$NumLoops]|Loop --X|End macro }}
Just wanted to pop in an ask a quick question. Does the Spawn script work with Scriptcards? I just can't seem to get it to work through scriptcards. 
1613651027
David M.
Pro
API Scripter
DM Goss: not yet, but allowing Spawn to be called from another script has been on my list of things to do. Shouldn't be too hard, though, with the mods in v1.0 or later of Scriptcards (thanks, Kurt!). I've still gotta figure out what's going on with my repo, though. My last pull request was approved but the one-click wasn't updated. Keep tabs on the Spawn thread for progress.
Thanks, David.
1613656030

Edited 1613656073
David M.
Pro
API Scripter
Hmm, thinking about this a bit more, I have a question for Kurt: Many of my scripts use vertical pipes between commands and arguments. I'm guessing this is going to cause problems when calling from a scriptcard? Token-mod often has these delimiting characters in them, as well. A couple of examples: !Spawn --name|imp --offset|1,0 !token-mod --set statusmarkers|blue|broken-shield Scriptcards uses a "_" substitution for "--", but could we get one for vertical pipe "|", as well? Or is there already a way to handle this? Related: There might be a way for the user to trigger Spawn from scriptcards without requiring a code change for Spawn (using the "!forselected+" command of the latest version of SelectManager, see below), but I'm thinking the pipes will still cause problems from a scriptcard currently. This following works in chat (1st line only if there is a character sheet in the journal named "imp" that has a default token) !forselected+ Spawn --name|imp --offset|1,0 !forselected+ token-mod --set statusmarkers|blue|broken-shield But this doesn't (though I might have some other syntax wrong - I've actually never called a script from scriptcards) !scriptcard {{ --#hideCard|1 --@forselected+|Spawn _name|imp _offset|1,0 --@forselected+|token-mod _set statusmarkers|blue|broken-shield }} Thoughts?
Colin C. said: How can I add a new line to content without a new line in the script? I'm trying to do something like: !scriptcard {{ --+Tag|Content <br> More Content }} I know I could  do !scriptcard {{ --+Tag|Content --+|More Content }} But that makes it so I have to break up string variables. In slightly longer form: !scriptcard {{ --&String|Content --&String|+ More Content --+Tag|[&String] }} But I want the string to appear on two separate lines when the card is output. I might be able to work it with using the string functions, like maybe delimiters? But I'm not sure the most succinct way to structure the direct output lines so that I capture all of the pieces without knowing in advance how many pieces there would be. Would something like an output loop work for that? Similar to the resource find loop, or the health check loop? The point of this exercise is that I want to create a "Combat Reminder" macro for my more, *ahem* absent-minded  players, that will check their various class abilities and put them into a card for them to reference on their turn. E.g., Barb 3/Paladin 2/Rogue 7 has various actions, bonus actions, and reactions. This seems to work: !scriptcard {{ --#whisper|gm --&String|+^^Text --&String|+^^Texty Text --&String|+^^TexMex Texty Text --&String|+^^TexMex Text --&String|+^^Tex --+Final String|[&String] --=Num|2 --~String|string;split;^^;[&String] --+StringCount|[$StringCount] --:StringLoop| --?[$Num.Total] -gt [$StringCount]|Done --+String Piece [$Num.Total]|[&String[$Num.Total]] --=Num|[$Num] + 1 -->StringLoop| --:Done| --+Done| --X| }} I had to cheat a little and start with 2, rather than 1, because I'm starting with a delimiter, but I have to because I would only ever append text to the string variable--I'd never just start with anything other than a blank string. If you get your ScriptCard working, can you post it to this group?  This could be very handy.  Also, any thought of adding a ScriptCards repository/database for those of us that don't have the time, knowledge, or the programming chops?   
1613661597

Edited 1613661917
Kurt J.
Pro
API Scripter
David M. said: Hmm, thinking about this a bit more, I have a question for Kurt: Many of my scripts use vertical pipes between commands and arguments. I'm guessing this is going to cause problems when calling from a scriptcard? Token-mod often has these delimiting characters in them, as well. A couple of examples: !Spawn --name|imp --offset|1,0 !token-mod --set statusmarkers|blue|broken-shield Scriptcards uses a "_" substitution for "--", but could we get one for vertical pipe "|", as well? Or is there already a way to handle this? Related: There might be a way for the user to trigger Spawn from scriptcards without requiring a code change for Spawn (using the "!forselected+" command of the latest version of SelectManager, see below), but I'm thinking the pipes will still cause problems from a scriptcard currently. This following works in chat (1st line only if there is a character sheet in the journal named "imp" that has a default token) !forselected+ Spawn --name|imp --offset|1,0 !forselected+ token-mod --set statusmarkers|blue|broken-shield But this doesn't (though I might have some other syntax wrong - I've actually never called a script from scriptcards) !scriptcard {{ --#hideCard|1 --@forselected+|Spawn _name|imp _offset|1,0 --@forselected+|token-mod _set statusmarkers|blue|broken-shield }} Thoughts? Vertical bars are fine in the content portion of a ScriptCard and get passed along as normal to whatever API is being called. For example, here is the apply damage using token-mod from the expanded magic missile script: --@token-mod|_ignore-selected _ids [%1%] _set bar[%2%]_value|[%3%] I'm not too familiar with SelectManager (yet! it looks like something I need to check out), but by the time ScriptCards calls it, it is likely nothing is selected. It is likely necessary to use !foreselected prior to calling ScriptCards rather that within the card (just a guess though - I haven't tried it), so !forselected+ ScriptCard {{...}} ( note that I might be completely misunderstanding selectmanager :))
1613664696
David M.
Pro
API Scripter
Ah, good to know! Thanks for the example. You're probably right about losing the selected tokens. Interesting idea with !forselected+ ScriptCard {{...}}. Though, it doesn't appear that !forselected accepts double bracket syntax currently, and the thought of a scriptcard all on one line makes me want to vomit, haha! I'll ping timmaugh about it in case it is a simple update, but the likely solution is for me to stop trying to weasel my way out of it and just modify my scripts ;) Spawn is a little weird in that it handles multiple simultaneous targets and selected(s) which at the time required some chat menu button shenanigans that I won't bore you with (it predated SelectManager). This might be a more significant modification that I was originally thinking. Anyway, thanks for the help, as always!
Will M. said: Colin C. said: How can I add a new line to content without a new line in the script? I'm trying to do something like: !scriptcard {{ --+Tag|Content <br> More Content }} I know I could  do !scriptcard {{ --+Tag|Content --+|More Content }} But that makes it so I have to break up string variables. In slightly longer form: !scriptcard {{ --&String|Content --&String|+ More Content --+Tag|[&String] }} But I want the string to appear on two separate lines when the card is output. I might be able to work it with using the string functions, like maybe delimiters? But I'm not sure the most succinct way to structure the direct output lines so that I capture all of the pieces without knowing in advance how many pieces there would be. Would something like an output loop work for that? Similar to the resource find loop, or the health check loop? The point of this exercise is that I want to create a "Combat Reminder" macro for my more, *ahem* absent-minded  players, that will check their various class abilities and put them into a card for them to reference on their turn. E.g., Barb 3/Paladin 2/Rogue 7 has various actions, bonus actions, and reactions. This seems to work: !scriptcard {{ --#whisper|gm --&String|+^^Text --&String|+^^Texty Text --&String|+^^TexMex Texty Text --&String|+^^TexMex Text --&String|+^^Tex --+Final String|[&String] --=Num|2 --~String|string;split;^^;[&String] --+StringCount|[$StringCount] --:StringLoop| --?[$Num.Total] -gt [$StringCount]|Done --+String Piece [$Num.Total]|[&String[$Num.Total]] --=Num|[$Num] + 1 -->StringLoop| --:Done| --+Done| --X| }} I had to cheat a little and start with 2, rather than 1, because I'm starting with a delimiter, but I have to because I would only ever append text to the string variable--I'd never just start with anything other than a blank string. If you get your ScriptCard working, can you post it to this group?  This could be very handy.  Also, any thought of adding a ScriptCards repository/database for those of us that don't have the time, knowledge, or the programming chops?    In the spirit of sharing, here's a "powers" menu that I came up with for my party's druid. It lists the character's abilities and powers, and how many are remaining (including Hit Dice), tracks remaining spell slots, and features short rest and long rest buttons. I've done similar menus for the other characters in the group. I hope it's useful as a reference, if nothing else. The weird symbols are emojis that don't display correctly in the forum. ;) !script {{     --#title|  Druid Powers    --#leftsub|@{selected|token_name}   --#sourceToken|@{selected|token_id}   --#emoteText|*@{selected|token_name} takes stock of her powers.*   --Lsettings|@{selected|token_name}   --=AttributeA|0   --=HitDiceCount|@{selected|hit_dice}   --=ResourceExpended|FF0000   --=AttributeColor|00C301   --=Level1|[*S:lvl1_slots_expended]   --=Level2|[*S:lvl2_slots_expended]   --=Level3|[*S:lvl3_slots_expended]   --=Level4|[*S:lvl4_slots_expended]   -->CheckAttributes|   --:Power1|   --?[$AttributeA.Total] -ge 1|DisplayButton   --+  |Wild Shape [b][#[$ResourceExpended.RollText]][$AttributeA.Total][/#][/b]   --^HideButton|   --:DisplayButton|   --+  |Wild Shape [b][#[$AttributeColor.RollText]][$AttributeA.Total][/#] Left[/b]   --:HideButton|   --?[$Level1] -le 0|Level1Skip   --=Level1Color|00C301   --^L2|   --:Level1Skip|   --=Level1Color|FF0000   --:L2|   --?[$Level2] -le 0|Level2Skip   --=Level2Color|00C301   --^L3|   --:Level2Skip|   --=Level2Color|FF0000   --:L3|   --?[$Level3] -le 0|Level3Skip   --=Level3Color|00C301   --^L4|   --:Level3Skip|   --=Level3Color|FF0000   --:L4|   --?[$Level4] -le 0|Level4Skip   --=Level4Color|00C301   --^DisplaySlots|   --:Level4Skip|   --=Level4Color|FF0000   --:DisplaySlots|   --+  |Spell Slots ① [b][#[$Level1Color.RollText]][$Level1.Total][/#][/b] ② [b][#[$Level2Color.RollText]][$Level2.Total][/#][/b] ③ [b][#[$Level3Color.RollText]][$Level3.Total][/#][/b] ④ [b][#[$Level4Color.RollText]][$Level4.Total][/#][/b]   --?[$HitDiceCount.Total] -ge 1|DisplayButton2   --+  |Hit Dice [b][#[$ResourceExpended.RollText]][$HitDiceCount.Total][/#] Left[/b]   --^Rest|   --:DisplayButton2|   --=AttributeColor|00C301   --+  |Hit Dice [b][#[$AttributeColor.RollText]][$HitDiceCount.Total][/#] Left[/b]   --:Rest|   --+|[c] 律 [button]Short Rest::~Leonora Duarte|ShortRest[/button]  [button]Long Rest::~Leonora Duarte|LongRest[/button][/c]   --:CheckAttributes|   --Rfirst|@{selected|character_id};repeating_resource   --:ResourceLoop|   --?"[*R:resource_left_name]" -inc "Wild Shape"|>SetA;[*R:resource_left]     --?"[*R:resource_right_name]" -inc "Wild Shape"|>SetA;[*R:resource_right]   --Rnext|   --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|ResourceLoop   --<|   --:SetA|   --=AttributeA|[%1%]   --<| }}
Will M. said: If you get your ScriptCard working, can you post it to this group?  This could be very handy.  Also, any thought of adding a ScriptCards repository/database for those of us that don't have the time, knowledge, or the programming chops? For sure! I started off just dealing with Extra Attack, since that's among the most straightforward and common abilities to account for. So far, this works: !scriptcard {{ --#title|Action Card Loops --#whisper|gm --#sourcetoken|@{selected|token_id} --&Actions|You have no actions from your race or class. --&Bonus|You have no bonus actions from your abilities/spells. --&Reactions|You have no reactions from your abilities/spells. --&Special|You have no special combat features from your race or class. --+Class|[*S:class] --+Level|[*S:level] --?[*S:class] -eq Barbarian -or [*S:class] -eq Fighter -or [*S:class] -eq Monk -or [*S:class] -eq Paladin -or [*S:class] -eq Ranger -and [*S:level] -ge 5|>ActionsLoop;When you take the Attack action, you can make one additional weapon attack as part of that action. -->DisplayLoop|Actions --:EndCard| --+Fin| --X| --:ActionsLoop|Which feature to append --&Actions|+^^[%1%] --<| --:BonusLoop|Which feature to append --&Bonus|+^^[%1%] --<| --:ReactionsLoop|Which feature to append --&Reactions|+^^[%1%] --<| --:SpecialLoop|Which feature to append --&Special|+^^[%1%] --<| --:DisplayLoop|Which action economy --+[%1%]| --=Num|2 --~[%1%]|string;split;^^;[&[%1%]] --?[$[%1%]Count] -eq 1|>NoExtras;[%1%] --:StringLoop| --?[$Num.Total] -gt [$[%1%]Count]|EndStringLoop --+|[&[%1%][$Num.Total]] --=Num|[$Num] + 1 -->StringLoop|[%1%] --:EndStringLoop| --C[%1%]|Actions:>DisplayLoop;Bonus|Bonus:>DisplayLoop;Reactions|Reactions:>DisplayLoop;Special|Special:EndCard --:NoExtras| --+|[&[%1%]] -->EndStringLoop|[%1%] }} I have discovered problem when running this with a multiclass character, however. In that instance, [*S:class] and [*S:level] read out as undefined [not blank--undefined]. I'm also borrowing from the PowerCards materials to do a display of things like attributes, speed, spells slots, etc. (Sort of like what Jay R. has.) I have that working separate from this loop series for now, but since they work independently, I will work on integrating them for formatting and stuff like that. Future developments will include far more abilities than Extra Attack, of course (i.e., Rage, Channel Divinity, listing Bonus Action Spells (specifically under Bonus Actions--it can be difficult for even experienced players to remember all of their BA spells vs regular spells)). I'll also be working to make buttons out of things so that, in theory, almost everything a character can do could in combat be run from the chat menu rather than opening a character sheet. Using magic items this way is going to be more challenging, I think. I'm still experimenting with SpellMaster and haven't decided what I prefer to focus on yet. I'm inclined to think running the majority of magic stuff is probably better through SpellMaster rather than the chat window, but we'll see. 
Jay R. said: In the spirit of sharing, here's a "powers" menu that I came up with for my party's druid. It lists the character's abilities and powers, and how many are remaining (including Hit Dice), tracks remaining spell slots, and features short rest and long rest buttons. I've done similar menus for the other characters in the group. I hope it's useful as a reference, if nothing else. The weird symbols are emojis that don't display correctly in the forum. ;) How do you get emojis in there and where do you get them?
Colin C. said: Jay R. said: In the spirit of sharing, here's a "powers" menu that I came up with for my party's druid. It lists the character's abilities and powers, and how many are remaining (including Hit Dice), tracks remaining spell slots, and features short rest and long rest buttons. I've done similar menus for the other characters in the group. I hope it's useful as a reference, if nothing else. The weird symbols are emojis that don't display correctly in the forum. ;) How do you get emojis in there and where do you get them? You can just paste them into your scriptcard from wherever you'd normally get emojis. I bring up the Show Emoji & Symbols menu on macOS, select Copy Character Info, paste into the scriptcard, and delete everything pasted except the emoji itself.
Colin C. said: Will M. said: If you get your ScriptCard working, can you post it to this group?  This could be very handy.  Also, any thought of adding a ScriptCards repository/database for those of us that don't have the time, knowledge, or the programming chops? For sure! I started off just dealing with Extra Attack, since that's among the most straightforward and common abilities to account for. So far, this works: !scriptcard {{ --#title|Action Card Loops --#whisper|gm --#sourcetoken|@{selected|token_id} --&Actions|You have no actions from your race or class. --&Bonus|You have no bonus actions from your abilities/spells. --&Reactions|You have no reactions from your abilities/spells. --&Special|You have no special combat features from your race or class. --+Class|[*S:class] --+Level|[*S:level] --?[*S:class] -eq Barbarian -or [*S:class] -eq Fighter -or [*S:class] -eq Monk -or [*S:class] -eq Paladin -or [*S:class] -eq Ranger -and [*S:level] -ge 5|>ActionsLoop;When you take the Attack action, you can make one additional weapon attack as part of that action. -->DisplayLoop|Actions --:EndCard| --+Fin| --X| --:ActionsLoop|Which feature to append --&Actions|+^^[%1%] --<| --:BonusLoop|Which feature to append --&Bonus|+^^[%1%] --<| --:ReactionsLoop|Which feature to append --&Reactions|+^^[%1%] --<| --:SpecialLoop|Which feature to append --&Special|+^^[%1%] --<| --:DisplayLoop|Which action economy --+[%1%]| --=Num|2 --~[%1%]|string;split;^^;[&[%1%]] --?[$[%1%]Count] -eq 1|>NoExtras;[%1%] --:StringLoop| --?[$Num.Total] -gt [$[%1%]Count]|EndStringLoop --+|[&[%1%][$Num.Total]] --=Num|[$Num] + 1 -->StringLoop|[%1%] --:EndStringLoop| --C[%1%]|Actions:>DisplayLoop;Bonus|Bonus:>DisplayLoop;Reactions|Reactions:>DisplayLoop;Special|Special:EndCard --:NoExtras| --+|[&[%1%]] -->EndStringLoop|[%1%] }} I have discovered problem when running this with a multiclass character, however. In that instance, [*S:class] and [*S:level] read out as undefined [not blank--undefined]. I'm also borrowing from the PowerCards materials to do a display of things like attributes, speed, spells slots, etc. (Sort of like what Jay R. has.) I have that working separate from this loop series for now, but since they work independently, I will work on integrating them for formatting and stuff like that. Future developments will include far more abilities than Extra Attack, of course (i.e., Rage, Channel Divinity, listing Bonus Action Spells (specifically under Bonus Actions--it can be difficult for even experienced players to remember all of their BA spells vs regular spells)). I'll also be working to make buttons out of things so that, in theory, almost everything a character can do could in combat be run from the chat menu rather than opening a character sheet. Using magic items this way is going to be more challenging, I think. I'm still experimenting with SpellMaster and haven't decided what I prefer to focus on yet. I'm inclined to think running the majority of magic stuff is probably better through SpellMaster rather than the chat window, but we'll see.  This is great! I really like the idea of flagging abilities and spells that only take bonus actions (or reactions, etc.). I might modify what I've got to reflect that.
Hi Kurt, I have an issue. In my script I wanna check if target's got a shield (bouclier in french). To do so I do a Rfind in its repeating_protection section. If he hasn't got any, fine its defense should be Body + Prot (Corps + Prot in french) If he has, 2 options : He can shelter behind its shield (A couvert) or not. If he decides so , its defense gets further increased by the shield protection My problem is that I always get presented with the query for ACouvert even if my guy doesn't have a shield....! I surely have a branching issue but I can't seem to spot it... here's my script !scriptcard  {{   --#title|Pistolet-Mitrailleur1   --#leftsub|Armes humaines   --#sourceToken|@{selected|token_id}   --#targetToken|@{target|token_id}   --Rfind|[*S:character_id];Pistolet-Mitrailleur1;repeating_armement;aname   --=ABonus|[*R:abonus]   --=Atk|?{Score|0} [SCORE]+ [*S:ArmesHumainesPJ_Bonus] [SPE]+ [$ABonus] [ACQUIS]+ ?{Bonus-Malus|0} [BONUS]    --#emoteText|[*S:character_name] attaque [*T:character_name]   --Rfind|[*T:character_id];Bouclier;repeating_protection;ptype   --?"[*R:ptype]" -eq NoRepeatingAttributeLoaded|PasdeBouclier|Bouclier      --:PasdeBouclier|   --=Def|[*T:corps] [CORPS] +[*T:totaldef_corps] [DEFENSE]   --+Résultat|[*S:character_name] obtient un total de [$Atk] à opposer à la défense de [*T:character_name] qui est de [$Def]   --X|      --:Bouclier|   --=DefB|[*T:corps] [CORPS] +[*T:totaldef_corps] [DEFENSE] +?{A couvert?|Non, 0 |Oui, [*R:pcorps]} [COUVERT]   --+Résultat|[*S:character_name] obtient un total de [$Atk] à opposer à la défense de [*T:character_name] qui est de [$DefB]   --X| }}
Here's a cavalier fighter menu, with uses remaining for each power and Use buttons that disappear if the power is at 0. Action types are indicated by right-justified letter symbols for extra visual impact (though they may not display correctly in the code block). !script {{     --#title| ⚔️ Fighter Powers ⚔️   --#leftsub|@{selected|token_name}   --#sourceToken|@{selected|token_id}   --#emoteText|*@{selected|token_name} takes stock of her powers.*   --Lsettings|@{selected|token_name}   --=AttributeA|0   --=AttributeB|0   --=AttributeC|0   --=AttributeD|0   --=HitDiceCount|@{selected|hit_dice}   --=ResourceExpended|FF0000   -->CheckAttributes|   --:Power1|   --?[$AttributeA.Total] -ge 1|DisplayButton   --+  |[#[$ResourceExpended.RollText]]Action Surge[/#]   --^HideButton|   --:DisplayButton|   --+  |[button]Use::~Melody Litchfield|ActionSurge[/button] Action Surge [r] [/r]   --:HideButton|   --:Power2|   --?[$AttributeB.Total] -ge 1|DisplayButton2   --+ ⚡️ |[#[$ResourceExpended.RollText]]Second Wind[/#]   --^HideButton2|   --:DisplayButton2|   --+ ⚡️ |[button]Use::~Melody Litchfield|SecondWind[/button] Second Wind [r]  [/r]   --:HideButton2|   --:Power3|   --?[$AttributeC.Total] -ge 1|DisplayButton3   --+  |Unwavering Mark Attack [b][#[$ResourceExpended.RollText]][$AttributeC.Total][/#][/b]   --^HideButton3|   --:DisplayButton3|   --=AttributeColor|00C301   --+  |[button]Use::~Melody Litchfield|UnwaveringMarkAttack[/button] Unwavering Mark Attack [b][#[$AttributeColor.RollText]][$AttributeC.Total][/#][/b] [r]  [/r]   --:HideButton3|   --:Power4|   --?[$AttributeD.Total] -ge 1|DisplayButton4   --+  |Warding Maneuver [b][#[$ResourceExpended.RollText]][$AttributeD.Total][/#][/b]   --^HideButton4|   --:DisplayButton4|   --=AttributeColor|00C301   --+  |[button]Use::~Melody Litchfield|WardingManeuver[/button] Warding Maneuver [b][#[$AttributeColor.RollText]][$AttributeD.Total][/#][/b] [r] [/r]   --:HideButton4|   --?[$HitDiceCount.Total] -ge 1|DisplayHD   --+  |Hit Dice [b][#[$ResourceExpended.RollText]][$HitDiceCount.Total][/#] Left[/b]   --^Rest|   --:DisplayHD|   --=AttributeColor|00C301   --+  |Hit Dice [b][#[$AttributeColor.RollText]][$HitDiceCount.Total][/#][/b] [r] 律 [/r]   --:Rest|   --+|[c] 律 [button]Short Rest::~Melody Litchfield|ShortRest[/button]  [button]Long Rest::~Melody Litchfield|LongRest[/button][/c]   --:CheckAttributes|   --Rfirst|@{selected|character_id};repeating_resource   --:ResourceLoop|   --?"[*R:resource_left_name]" -eq "Action Surge"|>SetA;[*R:resource_left]     --?"[*R:resource_right_name]" -eq "Action Surge"|>SetA;[*R:resource_right]   --?"[*R:resource_left_name]" -eq "Second Wind"|>SetB;[*R:resource_left]     --?"[*R:resource_right_name]" -eq "Second Wind"|>SetB;[*R:resource_right]   --?"[*R:resource_left_name]" -inc "Unwavering"|>SetC;[*R:resource_left]     --?"[*R:resource_right_name]" -inc "Unwavering"|>SetC;[*R:resource_right]   --?"[*R:resource_left_name]" -inc "Warding"|>SetD;[*R:resource_left]     --?"[*R:resource_right_name]" -inc "Warding"|>SetD;[*R:resource_right]   --Rnext|   --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|ResourceLoop   --<|   --:SetA|   --=AttributeA|[%1%]   --<|   --:SetB|   --=AttributeB|[%1%]   --<|   --:SetC|   --=AttributeC|[%1%]   --<|   --:SetD|   --=AttributeD|[%1%]   --<| }}
Mangouste said: !scriptcard  {{   --#title|Pistolet-Mitrailleur1   --#leftsub|Armes humaines   --#sourceToken|@{selected|token_id}   --#targetToken|@{target|token_id}   --Rfind|[*S:character_id];Pistolet-Mitrailleur1;repeating_armement;aname   --=ABonus|[*R:abonus]   --=Atk| ?{Score|0} [SCORE]+ [*S:ArmesHumainesPJ_Bonus] [SPE]+ [$ABonus] [ACQUIS]+ ?{Bonus-Malus|0} [BONUS]    --#emoteText|[*S:character_name] attaque [*T:character_name]   --Rfind|[*T:character_id];Bouclier;repeating_protection;ptype   --?"[*R:ptype]" -eq NoRepeatingAttributeLoaded|PasdeBouclier|Bouclier      --:PasdeBouclier|   --=Def|[*T:corps] [CORPS] +[*T:totaldef_corps] [DEFENSE]   --+Résultat|[*S:character_name] obtient un total de [$Atk] à opposer à la défense de [*T:character_name] qui est de [$Def]   --X|      --:Bouclier|   --=DefB|[*T:corps] [CORPS] +[*T:totaldef_corps] [DEFENSE] + ?{A couvert?|Non, 0 |Oui, [*R:pcorps]} [COUVERT]   --+Résultat|[*S:character_name] obtient un total de [$Atk] à opposer à la défense de [*T:character_name] qui est de [$DefB]   --X| }} I've bolded your culprits. These are formatted as roll queries, which means they got processed by the chat server before the scriptcard is processed at all. ScriptCards then  takes the result of that query and uses it in processing the card. If you have a roll query, you will always be prompted for it. Another note on the formatting: when you are defining roll variables, make sure there are spaces between each part of the definition. So, for one example: --=DefB|[*T:corps] [CORPS] +[*T:totaldef_corps] [DEFENSE] +?{A couvert?|Non, 0 |Oui, [*R:pcorps]} [COUVERT] Should be: --=DefB|[*T:corps] [CORPS] + [*T:totaldef_corps] [DEFENSE] + ?{A couvert?|Non, 0 |Oui, [*R:pcorps]} [COUVERT] As for how to incorporate the choice making mechanism in your overall script, you might be better off using ChatSetAttr and SetAbility creating new attributes and abilities. I do this with Rage: !setattr --replace --charid @{selected|character_id} --global_damage_mod_flag|1 --repeating_damagemod_-CREATE_global_damage_damage|\lbrak\lbrak({{\at{base_level},0}>9}*(3-2) + 2 + {{\at{base_level},0}>16}*(3-2))*\at{Rage}\rbrak\rbrak --repeating_damagemod_-CREATE_global_damage_name|Rage Damage --repeating_damagemod_-CREATE_global_damage_type|Rage --repeating_damagemod_-CREATE_global_damage_active_flag|1 --repeating_damagemod_-CREATE_global_damage_critical_damage|0 --subsubclass|n/a !setability --replace --charid @{selected|character_id} --RageSwitch#!condition toggle raging --RageMod#!modbattr ~-name \at{selected|character_name} ~-Rage|\[abs(\at{selected|Rage}-1)-\at{selected|Rage}\] ~-class_resource|-\[abs(\at{selected|Rage}-1)\] ~-fb-content _CUR1_ Rages left ~-fb-header You Have ~-fb-from GM --RageEmote#!power {{ ~-?? \at{selected|rage} == 0 ?? api_emas|\at{selected|character_name} begins frothing at the mouth! ~-?? \at{selected|rage} == 1 ?? api_emas|\at{selected|character_name} has a sense of calm wash over him }} --SubSubClass#!setattr ~--name \at{selected|character_name} ~-subsubclass|\q{Storm or Totem Path\?|Desert|Sea|Tundra| |Bear|Eagle|Elk|Tiger|Wolf} !setability --replace --token --charid @{selected|character_id} --Rage-Toggle#\p{@{selected|character_name}|RageSwitch} 
 \p{@{selected|character_name}|RageMod} 
  \p{@{selected|character_name}|RageEmote} This doesn't work exactly the way I want because the SetAbility function doesn't properly insert line returns between the ability calls in the Rage-Toggle ability, which means the abilities run into each other and misfire. So, I manually edit the Barbarian's Rage-Toggle ability to put those in. What this allows my Barbarian to do is click the Rage-Toggle button to turn "Rage" on or off--which sets the Rage attribute to 1 or 0. I then have the global damage modifier multiplied by the Rage attribute--which turns it to 0 if Rage is off. You could do something similar by having a hidden toggle attribute for "a couvert" and then use multiplication to give you the result you want. That means the decision has to be made before the ScriptCard runs at all.
1613679804

Edited 1613679839
David M.
Pro
API Scripter
EDIT - ninja'd Mangouste, queries get executed and parsed by chat before scriptcards even runs. So, every query in the scriptcard will result in a prompt, even if they are located inside a branch that is never touched due to conditionals.
1613681617

Edited 1613682503
Kurt J.
Pro
API Scripter
David M. said: EDIT - ninja'd Mangouste, queries get executed and parsed by chat before scriptcards even runs. So, every query in the scriptcard will result in a prompt, even if they are located inside a branch that is never touched due to conditionals. I just had an idea... but do I really want to go down this road? :) I'm wondering if I created an "ask the user something" statement type that stashed the current script, stacks, variables and program counter in memory and created a new API command that prompted the response and jumped back into scriptcards and retrieved the stashed data from memory and resumed running it...............................
Kurt J. said: I just had an idea... but do I really want to go down this road? :) I'm wondering if I created an "ask the user something" statement type that stashed the current script, stacks, variables and program counter in memory and created a new API command that prompted the response and jumped back into scriptcards and retrieved the stashed data from memory and resumed running it............................... I understood all of those words, but not most of those sentences. A programmer I am not.
Question: how does one call a macro from within a scriptcard? Not another API script, mind you, just a macro, like say, an attack macro on a character's sheet? Only way I can see of doing it is through buttons, but I want this macro to trigger immediately when a scriptcard is run.
1613685061

Edited 1613685200
David M.
Pro
API Scripter
Kurt J. said: I just had an idea... but do I really want to go down this road? :) I'm wondering if I created an "ask the user something" statement type that stashed the current script, stacks, variables and program counter in memory and created a new API command that prompted the response and jumped back into scriptcards and retrieved the stashed data from memory and resumed running it............................... I mean.... you'd be a hero, but yeah I completely understand your hesitation haha! Sounds kinda like what I had to go through with Spawn in the good-old pre-SelectManager days. Although I was only doing it for one value. Depending on initial commands (if need both selected and targets), a chat button is created that prompts for targets and then Spawn calls itself again, grabbing the original selectedIDs from a local registry. In case you're interested, see lines 70-94 and then again starting at line 1315 of the one-click version ( GitHub ). Much help from TheAaron on that one. Some comments, including a forum link for the "please help me!" discussion I had: &nbsp;//Due to a bug in the API, if a @{target|...} is supplied, the API does not acknowledge msg.selected anymore &nbsp; &nbsp; &nbsp; &nbsp; //This code block helps enable the user to pass both selected and target info into the script &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //---The initial api call will create a chat button that stores the original msg.content &amp; selected tokenID as a "memento"... &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //...clicking this button will trigger a second api call that will prompt for a number of targets.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //"--qty" number of tokens will spawn for EACH origin token (determined by selected or targeted) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Trick developed by TheAaron.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Forum thread here : <a href="https://app.roll20.net/forum/post/8998098/can-you-pass-both-a-selected-and-target-tokenid-to-an-api-script/?pageforid=8998098#post-8998098" rel="nofollow">https://app.roll20.net/forum/post/8998098/can-you-pass-both-a-selected-and-target-tokenid-to-an-api-script/?pageforid=8998098#post-8998098</a> Think I had about a month of js experience at that point, so I wouldn't try to follow anything else in that code ;)
1613685182
David M.
Pro
API Scripter
Jay R. said: Question: how does one call a macro from within a scriptcard? Not another API script, mind you, just a macro, like say, an attack macro on a character's sheet? Only way I can see of doing it is through buttons, but I want this macro to trigger immediately when a scriptcard is run. Maybe try the echo to chat command (--e|)?
1613686048
Kurt J.
Pro
API Scripter
David M. said: Jay R. said: Question: how does one call a macro from within a scriptcard? Not another API script, mind you, just a macro, like say, an attack macro on a character's sheet? Only way I can see of doing it is through buttons, but I want this macro to trigger immediately when a scriptcard is run. Maybe try the echo to chat command (--e|)? I *think* you have to use the html escape notation for the # sign (I haven't played with it) to prevent the chat server from expanding it.