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

Chad, you might check the TokenMod setting "Player can IDs" and make sure it's turned ON.   !token-mod --help Then toggle the button " Players can IDs is currently  On/Off" [TOGGLE] so that the setting is turned ON.
1624568930

Edited 1624569886
@Chad - for token-mod the ignore selected function uses a "|" not a hyphen. _ignore|selected not _ignore-selected.  That may be the issue there.  Also, I have found that token-mod gets pretty iffy if you use [*T:token_id] instead of @{target|token_id}  in passing a parameter, this might be an issue.  Edit: You can also use "--@token-mod _config|players-can-ids" in your scriptcard macros or  " !token-mod --config|players-can-ids" outside of the scriptcard macro .  I have a specific "StartGame" macro that includes this  and similar commands for GroupCheck and 5e OGL API scripts.
1624572053

Edited 1624572082
Kurt J.
Pro
API Scripter
Michael C. said: @Chad - for token-mod the ignore selected function uses a "|" not a hyphen. _ignore|selected not _ignore-selected.  That may be the issue there.  Also, I have found that token-mod gets pretty iffy if you use [*T:token_id] instead of @{target|token_id}  in passing a parameter, this might be an issue.  Edit: You can also use "--@token-mod _config|players-can-ids" in your scriptcard macros or  " !token-mod --config|players-can-ids" outside of the scriptcard macro .  I have a specific "StartGame" macro that includes this  and similar commands for GroupCheck and 5e OGL API scripts. With the [*T:] (or [*S:] or [*-id:]) notation, you'll want to use [*T:t-id] to pull the ID property from the token. [*T:token_id] will return undefined, while [*T:t-id] will get the id you are looking for.
@Kurt - okay, that explains why I had issues.  That actually makes sense as t-id is specific to the token.  Still, if @{target|token_id} worked one would think that [*T:token_id] would also.  Thanks on the update also!  Pretty soon I might be half-a__ed on this stuff.  Won't put away my Mickey Mouse badge just yet though. 
This may be another idiot question but I didn't see any instructions on calling sound effects in the wiki. (I have been known to be unobservant so I may have missed it.)  Do we have a sound effects command line in scriptcards?
@Kurt - do you have a link to 1.3.7 or is it on Patreon?
1624574439

Edited 1624574499
@Dave/Kurt - In spells like Find Steed or summoning spells I use a mix of scriptcards for the spell and David's SpawnDefaultToken to call the warhorse to the page.  I saw Colin's  [*[&tokenid]:t-controlledby] question and wondered if there wasn't a way we could change the "t-controlledby" field as opposed to just calling the information contained in it.  Specifically, when I spawn a token (NPC or other) it would be great not to have to manually change the token's control to a player but have it incorporated in the Spawn or scriptcard or other command line.  Can do?
1624574631
Kurt J.
Pro
API Scripter
Michael C. said: @Kurt - do you have a link to 1.3.7 or is it on Patreon? Not a patreon preview... it's on the public GIST at  Public development version of ScriptCards (github.com)
1624574801
Kurt J.
Pro
API Scripter
Michael C. said: This may be another idiot question but I didn't see any instructions on calling sound effects in the wiki. (I have been known to be unobservant so I may have missed it.)  Do we have a sound effects command line in scriptcards? ScriptCards doesn't directly support sound effects, but you can call Roll20 Audio Master with the --@ command to play effects. @Dave/Kurt - In spells like Find Steed or summoning spells I use a mix of scriptcards for the spell and David's SpawnDefaultToken to call the warhorse to the page.  I saw Colin's  [*[&tokenid]:t-controlledby] question and wondered if there wasn't a way we could change the "t-controlledby" field as opposed to just calling the information contained in it.  Specifically, when I spawn a token (NPC or other) it would be great not to have to manually change the token's control to a player but have it incorporated in the Spawn or scriptcard or other command line.  Can do? You should be able to do this with token-mod. I'm not sure about how you would find the ID of the newly spawned token(s). Then again, David might already have a provision to assign controlledby on the SpawnDefaultToken command line, which would make it super easy :)
1624578391

Edited 1624578438
Kurt J. said: Michael C. said: This may be another idiot question but I didn't see any instructions on calling sound effects in the wiki. (I have been known to be unobservant so I may have missed it.)  Do we have a sound effects command line in scriptcards? ScriptCards doesn't directly support sound effects, but you can call Roll20 Audio Master with the --@ command to play effects. @Dave/Kurt - In spells like Find Steed or summoning spells I use a mix of scriptcards for the spell and David's SpawnDefaultToken to call the warhorse to the page.  I saw Colin's  [*[&tokenid]:t-controlledby] question and wondered if there wasn't a way we could change the "t-controlledby" field as opposed to just calling the information contained in it.  Specifically, when I spawn a token (NPC or other) it would be great not to have to manually change the token's control to a player but have it incorporated in the Spawn or scriptcard or other command line.  Can do? You should be able to do this with token-mod. I'm not sure about how you would find the ID of the newly spawned token(s). Then again, David might already have a provision to assign controlledby on the SpawnDefaultToken command line, which would make it super easy :) Pooh.  Thought there might be an easy solution.  I did try using the script call inside the macro: "--@roll20AM _audio,play,nomenu|Thunder" which did not work, whereas "!roll20AM --audio,play,nomenu|Thunder" outside the scriptcard portion of the macro did.  I must have the syntax wrong? -------- I, too, would love to have it in SpawnDefaultToken but I looked at David's instructions and did not find anything.  I thought of trying token-mod but, though I can find the tokenid once it is placed on the page, there is not a method to pull it down during the spawn that I know of.  Even so, not sure how I would assign a new player id to, for example, [*[-Md-MHvs2zx3jS3z1-Xg]::t-controlledby] using token-mod in or outside of scriptcards...?? 
Formatting seems to have been suddenly stripped from Base and Exploding lines No Change on Scripts - just every one now has formatting stripped from those lines One of the simpler scripts !scriptcard {{ --#title|Unarmed Attack --#emoteText|@{selected|token_name} attacks @{target|token_name} --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#titlecardbackground|#871D06 --#leftsub|Strength --#rightsub|Brawl --:InitializeVariablesBase| --=Target|7 --=BNTarget|9 --=DSuccesses|0 --=SuccessesS|0 --=SuccessesT|0 --=DamageSuccesses|0 --=KillSuccesses|0 --&BaseRolls| --&ExplodedRolls| --:InitializeVariablesSelected| --=Sneak|?{Sneak Attack|No,10|Yes,20} --?[$Sneak] -eq 10|>SneakNo|>SneakYes --=Aces|0 --=Ones|0 --=Successes|0 --=SorT|0 --?@{target|Dex} >= @{target|Wit}|>Twit|>Tdex --=NumDice|@{selected|Str} + @{selected|Brawl} - [$Defence] --=DamageTarget|5+@{target|Wound} --=KillTarget|11+@{target|Kill} --&BaseRolls| --&ExplodedRolls| -->MainRollLoop| --:CHECK FOR SUCCESSES UA| --:CheckToUA| --? [$SuccessesT] -gt 0|>UAwin|>UAlose --<| --:MainRollLoop| --=i|0 --:RollLoop| --=i|[$i]+1 -->MakeRoll|1 --?[$i] -lt [$NumDice]|RollLoop --:OUTPUT| --+Base dice:| --+|[&BaseRolls] --+Exploded Dice:| --+|[&ExplodedRolls] --+Target:|[$Target] --+[c]~~~~~~~RESULTS~~~~~~[/c]| --+[#990000]Num Ones[/#]|[$Ones] --+[#007700]Num Successes[/#]|[$Successes] --:Store Successes Selected| --?[$SorT] -eq 0|>SuccessesSelected --:Store Successes| --?[$SorT] -eq 0|SuccessesS|[$Successes] --:CHECK FOR FUMBLE| --?[$Ones] -gt [$Successes]|>Fumble --<| --PROCEDURES| --:MakeRoll| accepts boolean as parameter to determine if base roll or exploded roll --=ThisRoll|1d10 --=Aces|[$Aces] + [$ThisRoll.Aces] --=Ones|[$Ones.Total] + [$ThisRoll.Ones] --?[%1%] -eq 1|>AddBaseRoll|>AddExplodedRoll --?[$ThisRoll] -ge [$Target]|>AddSuccess --?[$ThisRoll.Aces] -eq 1|>MakeRoll;0 --<| --:AddBaseRoll| --&BaseRolls|+[$ThisRoll] --<| --:AddExplodedRoll| --&ExplodedRolls|+[$ThisRoll] --<| --:AddSuccess| --=Successes|[$Successes] + 1 --<| --:Fumble| --+[#990000]Fumble! - [/#]|[#990000][b]Things went horribly wrong.[/b][/#] --X| --:SuccessesSelected| --=SuccessesT|[$Successes] --<| --:UAwin| --#oddrowbackground|#B73E23 --#evenrowbackground|#B73E23 --+[c]Damage Roll[/c]| --#oddrowbackground|#cceecc --#evenrowbackground|#99ee99 --? [$SuccessesT] -gt 0|>win|>lose --<|End --:Tlose| --+Nope|[$SuccessesT] successes, [b]@{selected|token_name} fails to hit @{target|token_name}[/b] --<| End Macro --:lose| --+Nope|[$Successes] successes, [b]@{selected|token_name} fails to hit @{target|token_name}[/b] --<| End Macro --:win| --:DAMAGE ROLL LOOP| --=i|0 --:DamageRollLoop| --=i|[$i]+1 -->MakeDamageRoll|1 --?[$i] -lt [$Successes]|DamageRollLoop --:DAMAGEOUTPUT| --+Base dice:| --+|[&BaseDamageRolls] --+Damage Threshold:|[$DamageTarget] --+[c]~~~~DAMAGE RESULTS~~~~[/c]| --+[#222222]Num Damage Successes[/#]|[$DamageSuccesses] --:CHECK FOR SUCCESSES DAMAGE| --? [$DamageSuccesses] -gt 0|>Dwin|>Dlose --:CHECK FOR SUCCESSES KILL| --? [$KillSuccesses] -gt 0|>Kwin|>Klose --X| End Macro --DAMEAGEPROCEDURES| --:MakeDamageRoll| accepts boolean as parameter to determine if base roll or exploded roll --=ThisDamageRoll|1d10 --=Aces|[$Aces] + [$ThisDamageRoll.Aces] --=Ones|[$Ones.Total] + [$ThisDamageRoll.Ones] --?[%1%] -eq 1|>AddBaseDamageRoll|>AddExplodedDamageRoll --?[$ThisDamageRoll] -ge [$DamageTarget]|>AddDamageSuccess --?[$ThisDamageRoll] -ge [$KillTarget]|>AddKillSuccess --?[$ThisDamageRoll.Aces] -eq 1|>MakeDamageRoll;0 --<| --:AddBaseDamageRoll| --&BaseDamageRolls|+[$ThisDamageRoll] --<| --:AddExplodedDamageRoll| --&ExplodedDamageRolls|+0 --<| --:AddDamageSuccess| --=DamageSuccesses|[$DamageSuccesses] + 1 --<| --:AddKillSuccess| --=KillSuccesses|[$KillSuccesses] + 1 --<| --:Dwin| --#oddrowbackground|#B73E23 --#evenrowbackground|#B73E23 --+Yay:|[b]@{selected|token_name} deals [$DamageSuccesses] Pain Damage to @{target|token_name}[/b] --<| --:Kwin| --#oddrowbackground|#F450DB --#evenrowbackground|#F450DB --vfx_opt|@{target|token_id} burst-blood --X| End Macro --:Dlose| --+Nope|[ToHit] successes, [b]@{selected|token_name} fails to hurt @{target|token_name}[/b] --X| End Macro --:Klose| --X| End Macro --:SneakNo| --?@{target|Dex} >= @{target|Wit}|>Twit|>Tdex --<| --:SneakYes| --=Defence|0 --<| --:Twit| --=Defence|@{target|Wit}+ @{target|Def_BONUS} --<| --:Tdex| --=Defence|@{target|Dex}+ @{target|Def_BONUS} --<| }}
I had another question for the group (Kurt? Dave?) I looked at the case statement and conditional branching hoping to find a way to assign a number of possible values to a variable in a single command line.  Conditional branching only allows one additional "else" so it would be more like the --c function but instead of  direct and procedure branches it would assign values to a variable such as   --C[$Roll.Total]|1:=X;1|2:= X;2 |3:= X;3 |4:= X;4 Possible or is there another way?
1624583351

Edited 1624586094
David M.
Pro
API Scripter
Spawn currently does not have an option to change controlledby properties, but it's something I can look into this weekend. EDIT - Now that you mention it, I'm pretty sure someone (might have been Will?) had asked for something similar a while ago and it got lost in the shuffle. Re: the case statement direct assignment, I'm assuming the actual thing you want to do is more complex than your example, as what you wrote could be done in a direct assignment like --=X|[$Roll] ?
Updated the Script Cards Format Utility to support Script Cards 1.3.7 You can find it on the Scriptcards API Working and Sharing forum.  You can make some really beautiful and really ugly Scriptcards.
1624621319
Kurt J.
Pro
API Scripter
Mark C. said: Formatting seems to have been suddenly stripped from Base and Exploding lines No Change on Scripts - just every one now has formatting stripped from those lines One of the simpler scripts This appears to be an unintended side-effect of the variable replacement code rewrite. I've got a fix I'm testing, but I want to make sure it doesn't have a wider impact. If you want to try it out, you can replace line 463 of the v1.3.7 code with: thisContent = replaceVariableContent(thisContent, cardParameters, (thisTag.charAt(0) == "+" || thisTag.charAt(0) == "*" || thisTag.charAt(0) == "&")); Which should re-enable roll highlighting for --& lines.
Kurt J. said: Mark C. said: Formatting seems to have been suddenly stripped from Base and Exploding lines No Change on Scripts - just every one now has formatting stripped from those lines One of the simpler scripts This appears to be an unintended side-effect of the variable replacement code rewrite. I've got a fix I'm testing, but I want to make sure it doesn't have a wider impact. If you want to try it out, you can replace line 463 of the v1.3.7 code with: thisContent = replaceVariableContent(thisContent, cardParameters, (thisTag.charAt(0) == "+" || thisTag.charAt(0) == "*" || thisTag.charAt(0) == "&")); Which should re-enable roll highlighting for --& lines. odd says i am running latest version - but lists it as => ScriptCards - 1.3.1 by Kurt Jaegers Ready <=- Meta Offset : 3510"
1624623421

Edited 1624623577
Mark C. said: Kurt J. said: Mark C. said: Formatting seems to have been suddenly stripped from Base and Exploding lines No Change on Scripts - just every one now has formatting stripped from those lines One of the simpler scripts This appears to be an unintended side-effect of the variable replacement code rewrite. I've got a fix I'm testing, but I want to make sure it doesn't have a wider impact. If you want to try it out, you can replace line 463 of the v1.3.7 code with: thisContent = replaceVariableContent(thisContent, cardParameters, (thisTag.charAt(0) == "+" || thisTag.charAt(0) == "*" || thisTag.charAt(0) == "&")); Which should re-enable roll highlighting for --& lines. odd says i am running latest version - but lists it as => ScriptCards - 1.3.1 by Kurt Jaegers Ready <=- Meta Offset : 3510" Cracking downloaded the 1.3.7 loaded and disabled 1.3.1 - working - great. Changed line - Brill thank you
1624637772
Chad
Plus
Sheet Author
David M. said: Another thing to check is to make sure you have " Players can use --ids" checked in the token-mod settings. This solved the first problem. I didn't think of it because I'm the GM and all my tests were working just fine, but apparently when ScriptCards calls TokenMod it acts as a "player". This doesn't resolve the issue with ignore selected, still working on that one.
1624638667
Chad
Plus
Sheet Author
Hmmm... checked, not using that. Tokens are being pulled into an array from pagetokens. In all tests, the tokenid is coming through great. I'm outputting it as part of the script and it's matching, and I've copied the output code and it works fine.  I did make the change that Michael suggested and turned on allow players to use ids. I didn't consider it because I'm the GM and all my tests were working, but it looks like calls from ScriptCard act as a player.  So that fixed the ids problem. Still working on the ignore-selected Kurt J. said: With the [*T:] (or [*S:] or [*-id:]) notation, you'll want to use [*T:t-id] to pull the ID property from the token. [*T:token_id] will return undefined, while [*T:t-id] will get the id you are looking for.
Greetings all. I am trying to simplify a result by putting the total of the combined attack info at the end, Like [$Total] Here is an example that I am trying to do... --:Hit| --=Damage|1d8 + 3 + [*S:strength_mod] [STR] --=Raidant|1d8 --=Devine|2d8 --+Hit!|The attack hit @{target|token_name} for [$Damage] Slashing damage. --+Raidant!|[$Damage]+[$Raidant] [$Total] Slashing and Radiant damage toatal. --+Devine!|[$Damage]+[$Raidant]+[$Devine] [$Total] Devine Smight damage total. --^Final| Thank You all for your time.
Mongo said: Greetings all. I am trying to simplify a result by putting the total of the combined attack info at the end, Like [$Total] Here is an example that I am trying to do... --:Hit| --=Damage|1d8 + 3 + [*S:strength_mod] [STR] --=Raidant|1d8 --=Devine|2d8 --+Hit!|The attack hit @{target|token_name} for [$Damage] Slashing damage. --+Raidant!|[$Damage]+[$Raidant] [$Total] Slashing and Radiant damage toatal. --+Devine!|[$Damage]+[$Raidant]+[$Devine] [$Total] Devine Smight damage total. --^Final| Thank You all for your time. This should combine the Totals of the attack. --:Hit| --=Damage|1d8 + 3 + [*S:strength_mod] [STR] --=Raidant|1d8 [Radiant] --=Devine|2d8 [Devine] --=Total|[$Damage]+[$Raidant] --=Total2|[$Damage]+[$Raidant]+[$Devine] --+Hit!|The attack hit @{target|token_name} for [$Damage] Slashing damage. --+Raidant!|[$Damage]+[$Raidant] = [$Total] Slashing and Radiant damage total. --+Devine!|[$Damage]+[$Raidant]+[$Devine] = [$Total2] Devine Smight damage total. --^Final|
1624714338

Edited 1624714648
Snow said: Mongo said: Greetings all. I am trying to simplify a result by putting the total of the combined attack info at the end, Like [$Total] Here is an example that I am trying to do... --:Hit| --=Damage|1d8 + 3 + [*S:strength_mod] [STR] --=Raidant|1d8 --=Devine|2d8 --+Hit!|The attack hit @{target|token_name} for [$Damage] Slashing damage. --+Raidant!|[$Damage]+[$Raidant] [$Total] Slashing and Radiant damage toatal. --+Devine!|[$Damage]+[$Raidant]+[$Devine] [$Total] Devine Smight damage total. --^Final| Thank You all for your time. This should combine the Totals of the attack. --:Hit| --=Damage|1d8 + 3 + [*S:strength_mod] [STR] --=Raidant|1d8 [Radiant] --=Devine|2d8 [Devine] --=Total|[$Damage]+[$Raidant] --=Total2|[$Damage]+[$Raidant]+[$Devine] --+Hit!|The attack hit @{target|token_name} for [$Damage] Slashing damage. --+Raidant!|[$Damage]+[$Raidant] = [$Total] Slashing and Radiant damage total. --+Devine!|[$Damage]+[$Raidant]+[$Devine] = [$Total2] Devine Smight damage total. --^Final| @Snow Thank for the script help, all that did was crash the API but I am glad to see you knew where I was going with this. Any other thoughts? Ok, now it is working... but it is giving me all the information..
Hi, is there a way to have an ability call a macro from a button? The macros work fine by themselves and Light works when I use the button but Toll the Dead just posts the code in the chat. Any ideas how to solve it? !script {{   --#whisper|GM   --#title|Spells   --#titleCardBackground|#932729   --#reentrant|Spells   --+Cantrips| [c][rbutton]Toll the Dead::!
#SpellTollTheDead[/rbutton]  [rbutton]Light::!
#SpellLight[/rbutton]   --x| }} !scriptcard {{   --:Light|   --#title|Light   --#titleCardBackground|#932729   --#leftsub|1 action   --#rightsub|Range touch --+Description|You touch one object that is no larger than 10 feet in any dimension. Until the spell ends, the object sheds bright light in a 20-foot radius and dim light for an additional 20 feet. The light can be colored as you like. Completely covering the object with something opaque blocks the light. The spell ends if you cast it again or dismiss it as an action. --+|If you target an object held or worn by a hostile creature, that creature must succeed on a Dexterity saving throw to avoid the spell. }}   !script {{   --:TollTheDead|   --#title|Toll the Dead   --#titleCardBackground|#932729   --#leftsub|1 action   --#rightsub|Range 60ft --IMake a ;Wisdom Save|q;PassFail;Pass or Fail|Pass|Fail --=Toll|1d8 --=TollDamage|1d12 --=TargetHP|@{target|target|bar1} --=TargetMaxHP|@{target|target|bar1|max} --?[&PassFail] -eq Fail|Failed|Passed --+Passed!|@{target|token_name} takes no damage.  --^Final| --:Failed| --?[$TargetHP] -eq [$TargetMaxHP]|FullHealth|LostHP --:LostHP| --+Lost HP|@{target|token_name} takes [$TollDamage] necrotic damage.   --@alter|_target|@{target|token_id} _bar|1 _amount|-[$TollDamage]   --^Final| --:FullHealth| --+Full Health!|@{target|token_name} takes [$Toll] necrotic damage.  --@alter|_target|@{target|token_id} _bar|1 _amount|-[$Toll] --^Final|   --:Final| }}
Henry,  I think I see what you are trying to do, creating an initial menu of spells and then separate routines for each spell. There are a couple way's you can achieve this.  Use the reentry logic and [rbutton], and imbed it all in one large macro (I've edited your macro to show you how that works). Write a separate macro for each spell and another that lists the spells (A menu/button card), placing the macro calls in [button] logic.  This would result in 3 separately named macros (SpellList, SpellLight, SpellTollTheDead).   This is an example of #1 using the reentry logic and [rbutton].  I've not completely debugged this, but the calling routines should work the way you were looking for.   !script {{ --#whisper|GM --#title|Spells --#titleCardBackground|#932729 --#reentrant|Spells --+Cantrips| --+|[c][rbutton]Toll the Dead::TollTheDead[/rbutton] [rbutton]Light::Light[/rbutton][/c] --X| --:Light| --#title|Light --#titleCardBackground|#932729 --#leftsub|1 action --#rightsub|Range touch --+Description|You touch one object that is no larger than 10 feet in any dimension. Until the spell ends, the object sheds bright light in a 20-foot radius and dim light for an additional 20 feet. The light can be colored as you like. Completely covering the object with something opaque blocks the light. The spell ends if you cast it again or dismiss it as an action. --+|If you target an object held or worn by a hostile creature, that creature must succeed on a Dexterity saving throw to avoid the spell. --X| --:TollTheDead| --#title|Toll the Dead --#titleCardBackground|#932729 --#leftsub|1 action --#rightsub|Range 60ft --IMake a ;Wisdom Save|q;PassFail;Pass or Fail|Pass|Fail --=Toll|1d8 --=TollDamage|1d12 --=TargetHP|@{target|target|bar1} --=TargetMaxHP|@{target|target|bar1|max} --?[&PassFail] -eq Fail|Failed|Passed --+Passed!|@{target|t-name} takes no damage. --^Final| --:Failed| --?[$TargetHP] -eq [$TargetMaxHP]|FullHealth|LostHP --:LostHP| --+Lost HP|@{target|token-name} takes [$TollDamage] necrotic damage. --@alter|_target|@{target|token_id} _bar|1 _amount|-[$TollDamage] --^Final| --:FullHealth| --+Full Health!|@{target|t-name} takes [$Toll] necrotic damage. --@alter|_target|@{target|token_id} _bar|1 _amount|-[$Toll] --^Final| --:Final| --X| }}
Super Attack, Paladin weapon....  Thank you for your help, I figured out the issues and it is working great now. !scriptcard {{ --#title|Summer's Blade --#titlecardbackground|#FFD700 --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#emoteText|NPC attacks @{target|token_name} --=TargetAC|@{target|npc_ac} --?[$TargetAC.Total] -gt 0|DoneWithAC --=TargetAC|@{target|ac} --:DoneWithAC| --=AttackRoll|?{Attack|Normal,1d20 + @{selected|strength_mod} [STR] + @{selected|pb} [PROF]|Advantage,2d20kh1 + @{selected|strength_mod} [STR] + @{selected|pb} [PROF]|Disadvantage,2d20kl1 + @{selected|strength_mod} [STR] + @{selected|pb} [PROF]} --+Attack|@{selected|token_name} rolls [$AttackRoll] vs AC [$TargetAC]. --?[$AttackRoll.Base] -eq 20|Crit --?[$AttackRoll.Base] -eq 1|Fumble --?[$AttackRoll.Total] -ge [$TargetAC.Total]|Hit --+Miss|The attack missed. --X| --:Fumble| --+Fumble!|The attack went horribly wrong. --X| --:Hit| --=Damage|1d8 + 3 + [*S:strength_mod] [STR] --=Raidant|1d8 [Radiant] --=Devine|2d8 [Devine] --=Total|[$Damage]+[$Raidant] --=Total2|[$Damage]+[$Raidant]+[$Devine] --+Hit!|The attack hit @{target|token_name} for [$Damage] Slashing damage. --+Raidant!|[$Damage]+[$Raidant] = [$Total] Slashing and Radiant damage total. --+Devine!|[$Damage]+[$Raidant]+[$Devine] = [$Total2] Devine Smight damage total. --X| --:Crit| --=Damage|1d8*2 + 3 + [*S:strength_mod] [STR] --=Raidant|1d8*2 [Radiant] --=Devine|2d8*2 [Devine] --=Total|[$Damage]+[$Raidant] --=Total2|[$Damage]+[$Raidant]+[$Devine] --+Hit!|The attack hit @{target|token_name} for [$Damage] Slashing damage. --+Raidant!|[$Damage]+[$Raidant] = [$Total] Slashing and Radiant damage total. --+Devine!|[$Damage]+[$Raidant]+[$Devine] = [$Total2] Devine Smight damage total. --X| }} It works so well Again thank you
@Mongo Glad to see you got it working.
@Will M. Thanks, I was trying to avoid putting them all in the same macro because it gets you to choose a target before choosing a spell but if that's the best way I'll go with that. Cheers
@Henry,  You can always use the User Input command to avoid the automatic Select Target popup.   --I;Chat Button Caption|t;Target_TokenId;Please select a Target? I used this method in the Dawnbringer script I wrote just recently and posted in Scriptcards Working and Sharing forum.  
@David - Sorry, been out of town for the weekend.  Yes, I forgot the original thing I was working on - and it may have been an idiot question - but the idea was to take an input and make a direct assignment from a number of possible values in a single line rather than branching to get the value.  Something like: --=Weapon|?{WhatWeapon|Dagger,1|Mace,2|Sickle,3|Bazooka,4} --c[$Weapon.Total]|1:&WeaponType,"Piercing"|2:&WeaponType,"Bludgeoning"|3:&WeaponType,"Slashing"|4:&WeaponType,"Kablooie" If there were only two choices a simple If...Then...Else would work: --?[%Weapon] -eq 1|&WeaponType,"Piercing"|&WeaponType,"Bludgeoning"} but that would be the extent of it.
1624909749
Kurt J.
Pro
API Scripter
Michael C. said: @David - Sorry, been out of town for the weekend.  Yes, I forgot the original thing I was working on - and it may have been an idiot question - but the idea was to take an input and make a direct assignment from a number of possible values in a single line rather than branching to get the value.  Something like: --=Weapon|?{WhatWeapon|Dagger,1|Mace,2|Sickle,3|Bazooka,4} --c[$Weapon.Total]|1:&WeaponType,"Piercing"|2:&WeaponType,"Bludgeoning"|3:&WeaponType,"Slashing"|4:&WeaponType,"Kablooie" If there were only two choices a simple If...Then...Else would work: --?[%Weapon] -eq 1|&WeaponType,"Piercing"|&WeaponType,"Bludgeoning"} but that would be the extent of it. This should work almost exactly as you have described except with semi-colons where you have commas, and no need for the quotes: --c[$Weapon.Total]|1:&WeaponType;Piercing;|2:&WeaponType;Bludgeoning|3:&WeaponType;Slashing|4:&WeaponType;Kablooie;
1624909930
Kurt J.
Pro
API Scripter
I've gone ahead and set up a discord server to talk about ScriptCards and my other projects if folks are interested. I don't want to kill off this thread, as it is beneficial to the wider community, but if folks want to join the discussion, the discord is at&nbsp; <a href="https://discord.gg/gTzRkdvY" rel="nofollow">https://discord.gg/gTzRkdvY</a>
I'm working on a modified version of the Dawnbringer magic item script that was posted in the Working &amp; Sharing thread. !script {{ +++5E Tools+++&nbsp;&nbsp; &nbsp;&nbsp;--#title|Holy Symbol of Ravenkind &nbsp;&nbsp;--#reentrant|Holy Symbol of Ravenkind &nbsp;&nbsp;--#leftsub| &nbsp;&nbsp;--#rightsub|1d6+4 charges at dawn &nbsp;&nbsp;--#titlecardbackground|LightYellow &nbsp;&nbsp;--#titlefontsize|1.5em &nbsp;&nbsp;--#titlefontlineheight|2.0em &nbsp;&nbsp;--#titlefontface|Contrail One &nbsp;&nbsp;--#bodyfontsize|11px &nbsp;&nbsp;--#bodyfontface|Tahoma &nbsp;&nbsp;--#oddrowbackground|#00000000 &nbsp;&nbsp;--#oddrowfontcolor|#000000 &nbsp;&nbsp;--#evenrowbackground|#00000000 &nbsp;&nbsp;--#evenrowfontcolor|#000000 &nbsp;&nbsp;--#buttonbackground|DarkRed &nbsp;&nbsp;--#buttontextcolor|White &nbsp;&nbsp;--#buttonbordercolor|#999999 &nbsp;&nbsp;--#buttonfontsize|10px &nbsp;&nbsp;--#buttonfontface|Tahoma &nbsp;&nbsp;--#dicefontcolor|#1C6EA4 &nbsp;&nbsp;--#dicefontsize|3.0em &nbsp;&nbsp;--#usehollowdice|0 &nbsp;&nbsp;--#emotebackground|#f5f5ba &nbsp;&nbsp;--#emotestate|visible &nbsp;&nbsp;--#tableborderradius| 6px; &nbsp;&nbsp;--#tableshadow| 5px 3px 3px 0px #aaa; &nbsp;&nbsp;--#bodybackgroundimage| linear-gradient( to bottom, LightYellow, Yellow, Orange, DarkOrange) &nbsp;&nbsp;--#sourcetoken|@{selected|token_id} &nbsp;&nbsp;--#debug|0 &nbsp;&nbsp;--:TOP| &nbsp;&nbsp;--#whisper|self &nbsp;&nbsp;--#emotetext| &nbsp;&nbsp;--#hidecard|0 &nbsp; --&gt;Lib5e_FindResource|[*S:Character-Id];HSR Charges [l+1d6+4];ResName;ResValue &nbsp; --#leftsub|[$ResValue.Total] charges left &nbsp;&nbsp;--&amp;TokenId|@{selected|token_id} &nbsp;&nbsp;--?[$ResValue.Total] -ge 1|[--+|[c][rbutton]Hold Vampires (Action - 1 charge)::HOLD[/rbutton][/c] --]| --?[$ResValue.Total] -lt 3|[ --X| --]| &nbsp; --:TurnerCheck| &nbsp; --Rfirst|[*S:character_id];repeating_traits;name &nbsp; --:TurnLoop| &nbsp; --?"[*R:name]" -inc "Turn Undead" -or -inc "Turn the Unholy"|[--+|[c][rbutton]Turn Undead (Action - 3 charges)::TURN[/rbutton][/c] --^EndTurnCheck| --]| &nbsp; --Rnext| &nbsp; --?"[*R:name]" -ne ArrayError|TurnLoop &nbsp; --:EndTurnCheck| --?[$ResValue.Total] -lt 5|[ --X| --]| &nbsp;&nbsp;--+|[c][rbutton]Sunlight (Action - 5 charges)::SUNLIGHT[/rbutton][/c] &nbsp;&nbsp;--x| &nbsp;&nbsp;--:HOLD|Action --@modbattr|_name [*[&amp;Tokenid]:character_name] _[&amp;ResName]|-1&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;--#hidetitlecard|1 &nbsp;&nbsp;&nbsp;&nbsp;--+|Vampires and vampire spawn within 30 feet of the holy symbol when it flares must make a DC 15 Wisdom saving throw. On a failed save, a target is paralyzed for 1 minute. It can repeat the saving throw at the end of each of its turns to end the effect on itself. &nbsp; &nbsp; --~|array;define;Vamps; &nbsp;&nbsp;&nbsp;&nbsp;--~|array;pagetokens;tokens;[&amp;TokenId] &nbsp; &nbsp; --~Vamp|array;getfirst;tokens &nbsp; --:VampCheck| &nbsp; &nbsp; --~Distance|distance;[&amp;TokenId];[&amp;Vamp] &nbsp; &nbsp; --?"[*[&amp;Vamp]:npc_type]" -inc Vampire -and [$Distance] -le 6|[--~|array;add;Vamps;[&amp;Vamp] --]| &nbsp;&nbsp;&nbsp;&nbsp;--~Vamp|array;getnext;tokens &nbsp; &nbsp; --?[&amp;Vamp] -ne ArrayError|VampCheck &nbsp; &nbsp; --~|array;removeat;Vamps;0 &nbsp; &nbsp; --~Vamp|array;getfirst;Vamps &nbsp; --?[&amp;Vamp] -eq ArrayError|[ --+The Holy Symbol of Ravenkind flares with light, but appears to have no effect|[i]Are there any vampires here?[/c] --X| --]| --:WisLoop| --=Wis|d20 + [*[&amp;Vamp]:npc_wis_bonus] --?[$Wis.Total] -lt 15|[ --@forselected|cmaster _add,condition=paralyzed,duration=10,direction=-1,message=Repeat save end of turn {^&amp; select [&amp;Vamp] --]| --~Vamp|array;getnext;Vamps --?[&amp;Vamp] -eq ArrayError|DoneVamps --^WisLoop| --:DoneVamps| &nbsp;&nbsp;--X| &nbsp;&nbsp;--:TURN|Action --@modbattr|_name [*[&amp;Tokenid]:character_name] _[&amp;ResName]|-3 &nbsp;&nbsp;&nbsp;&nbsp;--#hidetitlecard|1 &nbsp;&nbsp;&nbsp;&nbsp;--+|You present the Holy Symbol of Ravenkind! &nbsp; &nbsp; &nbsp; &nbsp; --~|array;define;Undead; &nbsp;&nbsp;&nbsp;&nbsp;--~|array;pagetokens;tokens;[&amp;TokenId] &nbsp; &nbsp; --~Undead|array;getfirst;tokens --:UndeadCheck| --?[&amp;Undead] -eq ArrayError|EndUndead --~Distance|distance;[&amp;TokenID];[&amp;Undead] --?[$Distance] -le 6 -and "[*[&amp;Undead]:npc_type]" -inc undead|[--~|array;add;Undead;[&amp;Undead] --]| --~Undead|array;getnext;tokens --^UndeadCheck| --:EndUndead| --~Undead|array;getfirst;Undead --:SaveLoop| --?[&amp;Undead] -eq ArrayError|[ --X| --]| --=Save|2d20kl1 + [*[&amp;Undead]:npc_wis_save] --?[$Save.Total] -lt [*S:spell_save_dc]|[--@forselected|cmaster _add,condition=frightened,duration=10,direction=-1 {^&amp; select [&amp;Undead]} --~Undead|array;getnext;Undead --^SaveLoop &nbsp;&nbsp;--X| &nbsp;&nbsp;--:SUNLIGHT|Action --@modbattr|_name [*[&amp;Tokenid]:character_name] _[&amp;ResName]|-5 &nbsp;&nbsp;&nbsp;&nbsp;--#hidecard|1 &nbsp;&nbsp;&nbsp;&nbsp;--@token-mod|_ids [&amp;Tokenid] _ignore-selected _set emits_bright|on bright_light_distance|30 dim_light_distance|30 &nbsp;&nbsp;--X| }} The one major issue is that ResValue returns undefined, I assume because the FindResource procedure fails to locate the "HSR Charges [l+1d6+4]" resource. The resource appears correctly on the character sheet, so I conclude that the problem is the brackets in the name. These are needed in order for 5E Rest &amp; Recovery to function properly. Minor issue: Despite not changing any of the settings from the Dawnbringer script, I'm getting this, wherein the subtitles are unreadable. Can I change the font for the subtitles?
1624989362

Edited 1624989541
@Colin - The wiki hasn't been updated for this and some others (emoteFontColor, etc.) but you can set the subtitle font color with &nbsp; --#subtitleFontColor|#[hex or color name]
1624990260
David M.
Pro
API Scripter
Kurt, I'm running into an issue where if a roll variable is not spelled correctly, it crashes my sandbox. I have v1.3.7 installed.&nbsp; I've simplified an example to the bare minimum that crashes for me. Looks like it barfs on line 2111, based on the meta-offset.&nbsp; !script {{ --=var|1d20 --+roll|[$vAr] }} I tested on another game that had 1.2.9 installed, and it worked fine (just output the misspelled variable to chat). I updated that game to 1.3.7 and got the sandbox crashes again. Life has been pretty busy for me lately - have I missed some important info?
Nevermind! I was able to diagnose after walking away for a bit. Errors are mine :)
Michael C. said: @Colin - The wiki hasn't been updated for this and some others (emoteFontColor, etc.) but you can set the subtitle font color with &nbsp; --#subtitleFontColor|#[hex or color name] Thanks! I know Kurt's been very busy working on the Script, which means the wiki stays behind. I can't always find what I'm looking for surfing through the . . . wow, 28 pages in the thread.
1624995045

Edited 1624995341
Kurt J.
Pro
API Scripter
David M. said: Kurt, I'm running into an issue where if a roll variable is not spelled correctly, it crashes my sandbox. I have v1.3.7 installed.&nbsp; I've simplified an example to the bare minimum that crashes for me. Looks like it barfs on line 2111, based on the meta-offset.&nbsp; !script {{ --=var|1d20 --+roll|[$vAr] }} I tested on another game that had 1.2.9 installed, and it worked fine (just output the misspelled variable to chat). I updated that game to 1.3.7 and got the sandbox crashes again. Life has been pretty busy for me lately - have I missed some important info? Probably a bug in my rewritten variable code. I'll take a look. Edit: Yep, I'm not checking for an undefined variable if you certain cases. I've got a fix in my code and will release an update with this and a few other fixes/enhancements later tonight.
Hey folks,&nbsp; I'm not sure if I'm having a TokenMod issue or a ScriptCard issue (or both, who knows?). I am trying to move a specific token, by ID, 1 grid space.&nbsp; If I use&nbsp; !token-mod --ignore-selected --ids -MdJCBssBbku99-nD3GX --move 1g The token moves up 1 square as expected.&nbsp; If I put it into a ScriptCard !scriptcard {{ --@token-mod|_ignore-selected _ids -MdJCBssBbku99-nD3GX _move 1g }} Nothing happens. Am I calling the API in the card wrong?
1625002647

Edited 1625003085
Erik, you might check the TokenMod setting "Player can IDs" and make sure it's turned ON.&nbsp;&nbsp; !token-mod --help Then toggle the button " Players can IDs is currently&nbsp; On/Off" [TOGGLE] so that the setting is turned ON. When called from within ScriptCards, TokenMod doesn't know it's coming from the GM and therefore ignores your command. @Kurt - I wonder if it might make sense to add a Warnings or Caveats: section on your Wiki associated with the --@ command about interacting with a number of the most common API scripts like TokenMod as this seems to be a common newcomers to your script encounter.&nbsp;&nbsp;
1625003026

Edited 1625016824
Yup, ran that and it was indeed already turned on.&nbsp;
1625005033
Kurt J.
Pro
API Scripter
I made a sweep through the settings to add missing ones and sorted the list alphabetically. I also added a note to the --@ command about how API scripts call other scripts.
1625005569
Kurt J.
Pro
API Scripter
ScriptCards version 1.3.8 Now Available The Development GIST has been updated with version 1.3.8. Primarily this is a bug fix release: Bug Fix : --&amp; lines now include roll variable formatting for .Total (or blank) roll formats. This was the default behavior before the variable substitution rewrite, and .Base or .Raw should be used if&nbsp;these values are needed in string assignments without roll formatting. Bug Fix : Fixed a sandbox crash when using a non-existant variable name in a line that does roll&nbsp;formatting. New Function : Added "getraw" to the system/date function set. This returns the raw date/time as a number of seconds since Jan 1, 1970 at Midnight. Convenience : Added support for setting name aliases... since I can't seem to keep "nominmaxhilight" and&nbsp;"nominmaxhighlight" straight... There are a handful of settings that now accept different names, like "nominmaxhilight" (as opposed to highlight). Functionally they just set the base "correct" setting name when used. Cleanup : Minor code formatting changes to make things more readable.
Will M. said: Erik, you might check the TokenMod setting "Player can IDs" and make sure it's turned ON.&nbsp;&nbsp; !token-mod --help Then toggle the button " Players can IDs is currently&nbsp; On/Off" [TOGGLE] so that the setting is turned ON. When called from within ScriptCards, TokenMod doesn't know it's coming from the GM and therefore ignores your command. Erik M. said: Yup, ran that and it was indeed already turned on.&nbsp; With some further testing, it looks like ChatSetAttr and AlterBars are having the same issue. Everything works fine when I'm logged in as a player and just call the API directly, but fails within a Scriptcard. Both ChatSetAttr and TokenMod are set up to allow players to affect tokens other then the ones they control.&nbsp; I then moved to a different campaign and both work just fine. Is there a campaign setting that I'm over looking or do I need to remake my whole game? If it matters, I'm using the one-click 1.3.1 version and tried on the new 1.3.8 version from the GIST as well.&nbsp;
I'm working on a card for sorcerer metamagic. At the moment, I'm stuck on Empowered Spell. For reference: When you roll damage for a spell, you can spend 1 sorcery point to reroll a number of the damage dice up to your Charisma modifier (minimum of one). You must use the new rolls.&nbsp; So, for example, if I cast fireball with 8d6, I might roll poorly: (&nbsp; 5&nbsp; +&nbsp; 4&nbsp; +&nbsp; 2&nbsp; +&nbsp; 4&nbsp; +&nbsp; 2&nbsp; +&nbsp; 1&nbsp; +&nbsp; 5&nbsp; +&nbsp; 6 ) And want to reroll the 1 and the 2s. I'm thinking something like: --~|array;define;damage; --=i|1 --=Max|8 --:EmpowerLoop| --=Die[$i.Total]|d6 --~|array;add;damage;[$Die[$i.Total].Total] --=i|[$i] + 1 --?[$i.Total] -lt [$Max.Total]|EmpowerLoop --~|array;removeat;damage;0 --~Damage|array;stringify;damage And then I could output the &amp;Damage string using the visual dice ( which I can't remember how to do! ) and have each one serve as a button to both remove from the array and then reroll and add back in. Does that make sense? Suggestions welcome!
1625162939

Edited 1625163229
Why not build one of the following dice formulas and let Roll20 Dice Mechanics do the work for you? Replace all 1s with 2s: {[[d6]],[[d6]], [[d6]], [[d6]], [[d6]], [[d6]], [[d6]], [[d6]], 2,2,2,2,2,2,2,2}kh8 Replace all 1s and 2s with 3s: {[[d6]],[[d6]], [[d6]], [[d6]], [[d6]], [[d6]], [[d6]], [[d6]], 3,3,3,3,3,3,3,3}kh8 Reroll 1s and 2s: 8d6r&lt;2 Reroll 1s and 2s (only once): 8d6ro&lt;2 Example Visual Dice syntax is:&nbsp; [d6]5[/d6] should display the number 5 on a 6 dice font.&nbsp;&nbsp; Colin C. said: I'm working on a card for sorcerer metamagic. At the moment, I'm stuck on Empowered Spell. For reference: When you roll damage for a spell, you can spend 1 sorcery point to reroll a number of the damage dice up to your Charisma modifier (minimum of one). You must use the new rolls.&nbsp; So, for example, if I cast fireball with 8d6, I might roll poorly: (&nbsp; 5&nbsp; +&nbsp; 4&nbsp; +&nbsp; 2&nbsp; +&nbsp; 4&nbsp; +&nbsp; 2&nbsp; +&nbsp; 1&nbsp; +&nbsp; 5&nbsp; +&nbsp; 6 ) And want to reroll the 1 and the 2s. I'm thinking something like: --~|array;define;damage; --=i|1 --=Max|8 --:EmpowerLoop| --=Die[$i.Total]|d6 --~|array;add;damage;[$Die[$i.Total].Total] --=i|[$i] + 1 --?[$i.Total] -lt [$Max.Total]|EmpowerLoop --~|array;removeat;damage;0 --~Damage|array;stringify;damage And then I could output the &amp;Damage string using the visual dice ( which I can't remember how to do! ) and have each one serve as a button to both remove from the array and then reroll and add back in. Does that make sense? Suggestions welcome!
Because it's not automatic. The player has to look at the dice rolls and decide which dice to reroll, if any, up to Charisma Mod, and get stuck with the new roll. Setting a floor doesn't work because a 2 could be come a 1. If the roll is really bad (e.g., all 1s), you can't reroll all of them. The player may decide that they don't want to spend the sorcery point, or may decide that, despite being below average on the total, it's close enough and not worth the risk of getting worse. Will M. said: Why not build one of the following dice formulas and let Roll20 Dice Mechanics do the work for you? Replace all 1s with 2s: {[[d6]],[[d6]], [[d6]], [[d6]], [[d6]], [[d6]], [[d6]], [[d6]], 2,2,2,2,2,2,2,2}kh8 Replace all 1s and 2s with 3s: {[[d6]],[[d6]], [[d6]], [[d6]], [[d6]], [[d6]], [[d6]], [[d6]], 3,3,3,3,3,3,3,3}kh8 Reroll 1s and 2s: 8d6r&lt;2 Reroll 1s and 2s (only once): 8d6ro&lt;2 Example Visual Dice syntax is:&nbsp; [d6]5[/d6] should display the number 5 on a 6 dice font.&nbsp;&nbsp; This also didn't work.
1625164541

Edited 1625165041
David M.
Pro
API Scripter
EDIT - ninja'd I think the issue is that the sorcerer ability is optional (and uses a resource) and can be used on any die rolls - it's not an auto-reroll of 1's &amp; 2's. Colin, I'm not sure if the visual dice can be made into a button in scriptcards. One of the CSS wizards would have to chime in. One thing you could do is to write the results of your damage rolls to persistent storage using the stateitem function. You could store it as a comma-delimited string (maybe roll1, die1, roll2, die2, etc.), and I would sort the die rolls first. Output an Empowered Spell button along with your initial damage output. On click, query for the number of rolls to re-roll, load the previous rolls&nbsp; and dice from the state object, and replace the N lowest rolls in the array before outputting again.&nbsp;
Just tested and the Dice Fonts do work on Buttons. &nbsp;&nbsp;&nbsp;&nbsp;--+|[rbutton][d6]1[/d6] Reroll?::REROLL[/rbutton] You could easily implement a solution with Reentry logic, storing your roll results in a delimited list and using the split function in the Reentry function.
1625165357
David M.
Pro
API Scripter
For visual dice based on a roll variable, it looks like you need to use .Raw, like this: !script {{ --=roll1|1d10 --=roll2|1d4 --+roll1|[d10][$roll1.Raw][/d10] --+roll2|[d4][$roll2.Raw][/d4] }} When I tried .Total it always displayed a 0.