Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] ScriptCards - Thread #2

@Kurt J , thank you so much for that! I feel like I learned something today! I ended up inserting underscores to the skill names because it was returning "undefined" for Animal Handling and Sleight of Hand checks because of the spaces, but it otherwise works like a charm. I -- and my players, too -- appreciate your help! !script {{   --#title|Secret Check   --#sourcetoken|@{selected|token_id}   --+|@{selected|token_name} makes a secret check...   --&Skill|?{Skill?|Acrobatics|Animal_Handling|Arcana|Athletics|Deception|History|Insight|Intimidation|Investigation|Medicine|Nature|Perception|Performance|Persuasion|Religion|Sleight_of_Hand|Stealth|Survival}   --=Roll|1d20 + [*S:[&Skill]_bonus]   --*GMLine |@{selected|token_name} rolled a [$Roll] for [&Skill] }}
1703094837
vÍnce
Pro
Sheet Author
@Kurt or anyone that knows... Question; How does SC handle a repeating attribute default value that hasn't been set? (ie manually edited, "tabbed-through", or set by a sheetworker) I've noticed that while sheetworkers recognize these values internally, mods do not.  A mod macro that need those values for calculations and whatnot will fail because there isn't anything available.  Just curious if sheet authors should/must utilize a sheetworker to set the repeating defaults in order for them to be available for SC or mods in general?  TIA
1703153217

Edited 1703153567
Hi all, I'm using the Action Menu macro and a spell mule to call to custom spells that use scripcards or other API's. I have one for spell Entangle that calls a macro on the spell mule. It works fine when I'm a GM, but if I switch to player mode it give me "No ability was found for %spell_mule|Entangle". I thought maybe I had to set the spell mule to be controlled by my players, but that didn't fix the issue. Anybody have any idea? EDIT: Changed the permissions on the spell mule to All Players, and that fixed it.
While I'm here... In the Action Menu macro you can create other mule characters as well that should replace the abilities in the Action Macro menu for each of your characters. I understand the spell mule and how to get that one working and I've got an idea about how to use the PCAbility_mule and NPCAbility_mule, I just haven't gotten that far yet. What I don't understand how to use is the Macro_mule. There's a rule about an AMLIST that I'm not clear about. Can anyone shed light on how to use this?
1703160621
Kurt J.
Pro
API Scripter
vÍnce said: @Kurt or anyone that knows... Question; How does SC handle a repeating attribute default value that hasn't been set? (ie manually edited, "tabbed-through", or set by a sheetworker) I've noticed that while sheetworkers recognize these values internally, mods do not.  A mod macro that need those values for calculations and whatnot will fail because there isn't anything available.  Just curious if sheet authors should/must utilize a sheetworker to set the repeating defaults in order for them to be available for SC or mods in general?  TIA This seems to be a flaw in the API itself, unfortunately. It looks to me like the default values aren't considered when the API asks for a value from a sheet. If it hasn't been set as you describe above, I always get a null back. Depending on how complex you want to get with a ScriptCard, it would be straightforward to write a "GetSheetValue" subroutine that could be called to return a value, checking for null, and substituting the default value. Of course, that would mean the script would need to know the default for everything on the sheet. Doable, but time consuming.
1703161585
Kurt J.
Pro
API Scripter
Timothy B. said: While I'm here... In the Action Menu macro you can create other mule characters as well that should replace the abilities in the Action Macro menu for each of your characters. I understand the spell mule and how to get that one working and I've got an idea about how to use the PCAbility_mule and NPCAbility_mule, I just haven't gotten that far yet. What I don't understand how to use is the Macro_mule. There's a rule about an AMLIST that I'm not clear about. Can anyone shed light on how to use this? For the Macro Mule, I need to go back in and see what I was intending to do :) It might be something I started including by didn't finish. If that is the case, I'll either finish it up or pull it. I need to do another pass on the code anyway, as I've found some optimizations I can make to speed things up a bit when accessing characters with lots of spells.
1703161756
Kurt J.
Pro
API Scripter
DM Robert said: @Kurt J , thank you so much for that! I feel like I learned something today! I ended up inserting underscores to the skill names because it was returning "undefined" for Animal Handling and Sleight of Hand checks because of the spaces, but it otherwise works like a charm. I -- and my players, too -- appreciate your help! !script {{   --#title|Secret Check   --#sourcetoken|@{selected|token_id}   --+|@{selected|token_name} makes a secret check...   --&Skill|?{Skill?|Acrobatics|Animal_Handling|Arcana|Athletics|Deception|History|Insight|Intimidation|Investigation|Medicine|Nature|Perception|Performance|Persuasion|Religion|Sleight_of_Hand|Stealth|Survival}   --=Roll|1d20 + [*S:[&Skill]_bonus]   --*GMLine |@{selected|token_name} rolled a [$Roll] for [&Skill] }} If you change the roll line to: --=Roll|1d20 + [*S:[&Skill(replaceall, ,_)]_bonus] It will replace the spaces with underscores in the ability lookup so you can still have them look right in the dropdown.
1703177763

Edited 1703177849
vÍnce
Pro
Sheet Author
Kurt J. said: vÍnce said: @Kurt or anyone that knows... Question; How does SC handle a repeating attribute default value that hasn't been set? (ie manually edited, "tabbed-through", or set by a sheetworker) I've noticed that while sheetworkers recognize these values internally, mods do not.  A mod macro that need those values for calculations and whatnot will fail because there isn't anything available.  Just curious if sheet authors should/must utilize a sheetworker to set the repeating defaults in order for them to be available for SC or mods in general?  TIA This seems to be a flaw in the API itself, unfortunately. It looks to me like the default values aren't considered when the API asks for a value from a sheet. If it hasn't been set as you describe above, I always get a null back. Depending on how complex you want to get with a ScriptCard, it would be straightforward to write a "GetSheetValue" subroutine that could be called to return a value, checking for null, and substituting the default value. Of course, that would mean the script would need to know the default for everything on the sheet. Doable, but time consuming. Thanks Kurt.  I kinda of suspected as much in my testing.  I think I'll just need to bite the bullet and do a version check that sets existing repeats and add listeners to set the defaults for any new repeating items going forward.  Cheers
1703692297

Edited 1703699565
Hi Kurt, I'm writing a ScriptCards macro for the Summon Beast spell using the DND 5e OGL character sheet. I have everything working except for two caveats. 1. If the token bars are set to "hp" or "npc_ac" it updates the token attributes but not the sheet attributes. Removing them from the token bars and running the macro again and it updates the sheet attributes as expected. 2. Is there a way to remove or modify repeating sections? I'm using a single character sheet and the Summon Beast spell has three types of beasts; Land, Air and Water. They don't all have the same traits and so I need to remove them if they aren't applicable. I was hoping to not use ChatSetAttr script, just for cleanliness sake. I can resort to that if it's the only way. !scriptcards {{ --#title|Summon Beast --#sourceToken|@{selected|token_id} --#emoteText|[*S:character_name] Casts Summon Beast. --#bodyfontface|Helvetica --#oddrowfontcolor|#290000 --#evenrowfontcolor|#290000 --#bodyfontsize|[&bodyFontSize]px --#titlecardbackgroundcolor|#930c10 --#titlecardbackgroundcolor|#672223 --#titlefontcolor|#fffebd --#titlefontsize|1.5em --#titlefontshadow|0 --#oddrowbackground|#f7ce65 --#evenrowbackground|#f7ce65 --#oddrowbackground|#b3ab96 --#evenrowbackground|#b3ab96 --#subtitlefontcolor|#fffebd --#tablebgcolor|#fffebd --#lineheight|10pt --#Debug|1 --&SummonBeast|@{SummonBeast|character_id} -->WhatSpellSlot|>[$SlotLevel] -->GetBeast| -->CommonAttr|>[&hplvl] -->RepeatExist| -->DeductSpellSlot| --X| --:WhatSpellSlot| --=SlotLevel|?{Spell Slot Level Used?|2|3|4|5|6|7|8|9} --=SlotsTotal|0 --=SlotsExpended|[*S:lvl[$SlotLevel]_slots_expended] --?[$SlotsExpended.Total] -eq [$SlotsTotal.Total]|NoSlotsLeft --<| --:GetBeast| --=Beast|?{What Beast Type?|Land,1|Air,2|Sea,3} --?[$Beast] -eq 1|Land-Beast --?[$Beast] -eq 2|Air-Beast --?[$Beast] -eq 3|Sea-Beast --X| --:Land-Beast| --&Type|1 --&hplvl|30 --Rfind|[&SummonBeast];Pack Tactics;repeating_npctrait;name --?"[*R:name]" -ninc "Pack Tactics"|AddPT --<| --:Air-Beast| --&Type|3 --&hplvl|20 --Rfind|[&SummonBeast];Flyby;repeating_npctrait;name --?[*R:name] -ninc Flyby|AddFB --<| --:Sea-Beast| --&Type|2 --&hplvl|30 --Rfind|[&SummonBeast];Pack Tactics;repeating_npctrait;name --?"[*R:name]" -ninc "Pack Tactics"|AddPT --Rfind|[&SummonBeast];Water Breathing;repeating_npctrait;name --?"[*R:name]" -ninc "Water Breathing"|AddWater --<| --:CommonAttr| --=ACCalc|11+[$SlotLevel] --=hptotal|5 * [= [$SlotLevel] - 2] + [&hplvl] --&Speed|30ft, 30ft climb --!a:[&SummonBeast]|!npc_name:Land Beast|!npc_type:Medium Beast, Unaligned|!npc_ac:[$ACCalc]|!hp:[$hptotal]|!hp^:[$hptotal]|!strength_base:18|!dexterity_base:11|!constitution_base:16|!intelligence_base:4|!wisdom_base:14|!charisma_base:5|!npc_speed:[&Speed]|!npc_challenge: --@forselected|Spawn _name|SummonBeast _offset|1,0 _side|[&Type] --<| --:RepeatExist| --Rfind|[&SummonBeast];Maul;repeating_npcaction;name --&MaulExist|[*R:name] --?[&MaulExist] -ne Maul|RepeatSec --<| --:AddPT| --!or:[&SummonBeast]:npctrait|name:Pack Tactics|description:The beast has advantage on an attack roll against a creature if at least one of the beast’s allies is within 5 feet of the creature and the ally isn’t incapacitated. --<| --:AddFB| --!or:[&SummonBeast]:npctrait| name:Flyby| description:The beast doesn’t provoke opportunity attacks when it flies out of an enemy’s reach. --<| --:AddWater| --!or:[&SummonBeast]:npctrait| name:Water Breathing| description:The beast can breathe only underwater. --<| --:RepeatSec| --!or:[&SummonBeast]:npcaction| name:Maul| attack_flag:on| attack_type:melee| attack_target:one target| attack_range:5 ft.| attack_tohit:@{selected|spell_attack_bonus}| attack_damage:1d8 + 4 + [$SlotLevel]| attack_damagetype:piercing| attack_tohitrange:| attack_range:5ft.| attack_target:one target| attack_onhit:1d8 + 4 + [$SlotLevel]| description:The beast has advantage on an attack roll against a creature if at least one of the beast’s allies is within 5 feet of the creature and the ally isn’t incapacitated. --!or:[&SummonBeast]:npcaction|name:Multiattack|description:The beast makes a number of attacks equal to half this spell’s level (rounded down). --<| --:DeductSpellSlot| --+Debug|[%1%] --=SlotsExpended|[$SlotsExpended] - 1 --!a:[*S:character_id]|lvl[$SlotLevel]_slots_expended:[$SlotsExpended] --+|Level [$SlotLevel] Slots Left: [$SlotsExpended] --X|Full Stop --:NoSlotsLeft| --+|[*S:character_name] has no level [$SlotLevel.Total] spell slots available. --X|NoSlotsLeftStop }}
1703707910

Edited 1703708630
Ok, so someone told me about using >, ie.  [*R>name], to replace existing repeating attributes. So I've switched from !or that adds the repeating sections to !a to adjust the attributes. The problem is, it only works intermittently. I use Rfind and then Rnext to adjust the second entry, but it doesn't always work, and also Rfind seems to occasionally crash the sandbox. Here's the new code. !scriptcards {{ --#title|Summon Beast --#sourceToken|@{selected|token_id} --#emoteText|[*S:character_name] Casts Summon Beast. --#bodyfontface|Helvetica --#oddrowfontcolor|#290000 --#evenrowfontcolor|#290000 --#bodyfontsize|[&bodyFontSize]px --#titlecardbackgroundcolor|#930c10 --#titlecardbackgroundcolor|#672223 --#titlefontcolor|#fffebd --#titlefontsize|1.5em --#titlefontshadow|0 --#oddrowbackground|#f7ce65 --#evenrowbackground|#f7ce65 --#oddrowbackground|#b3ab96 --#evenrowbackground|#b3ab96 --#subtitlefontcolor|#fffebd --#tablebgcolor|#fffebd --#lineheight|10pt --#Debug|1 --&SummonBeast|@{SummonBeast|character_id} -->WhatSpellSlot|>[$SlotLevel] -->GetBeast| -->CommonAttr|>[&hplvl] -->RepeatExist| -->DeductSpellSlot| --X| --:WhatSpellSlot| --=SlotLevel|?{Spell Slot Level Used?|2|3|4|5|6|7|8|9} --=SlotsTotal|0 --=SlotsExpended|[*S:lvl[$SlotLevel]_slots_expended] --?[$SlotsExpended.Total] -eq [$SlotsTotal.Total]|NoSlotsLeft --<| --:GetBeast| --=Beast|?{What Beast Type?|Land,1|Air,2|Sea,3} --?[$Beast] -eq 1|Land-Beast --?[$Beast] -eq 2|Air-Beast --?[$Beast] -eq 3|Sea-Beast --X| --:Land-Beast| --&Type|1 --&hplvl|30 --Rfind|[&SummonBeast];Pack Tactics;repeating_npctrait;name --?"[*R:name]" -ninc "Pack Tactics"|AddPT --<| --:Air-Beast| --&Type|3 --&hplvl|20 --Rfind|[&SummonBeast];Flyby;repeating_npctrait;name --?"[*R:name]" -ninc "Flyby"|AddFB --<| --:Sea-Beast| --&Type|2 --&hplvl|30 --Rfind|[&SummonBeast];Pack Tactics;repeating_npctrait;name --?"[*R:name]" -ninc "Pack Tactics"|AddPT --Rfind|[&SummonBeast];Water Breathing;repeating_npctrait;name --?"[*R:name]" -ninc "Water Breathing"|AddWater --<| --:CommonAttr| --=ACCalc|11 + [$SlotLevel] --=hptotal|5 * [= [$SlotLevel] - 2] + [&hplvl] --&Speed|30ft, 30ft climb --!a:[&SummonBeast]|!npc_name:Land Beast|!npc_type:Medium Beast, Unaligned|!npc_ac:[$ACCalc]|!hp:[$hptotal]|!hp^:[$hptotal]|!strength_base:18|!dexterity_base:11|!constitution_base:16|!intelligence_base:4|!wisdom_base:14|!charisma_base:5|!npc_speed:[&Speed]|!npc_challenge: --@forselected|Spawn _name|SummonBeast _offset|1,0 _side|[&Type] --<| --:RepeatExist| --Rfind|[&SummonBeast];Maul;repeating_npcaction;name --&MaulExist|[*R:name] --?"[&MaulExist]" -ne "Maul"|RepeatSec --<| --:AddPT| --Rfirst|[&SummonBeast];repeating_npctrait --!a:[&SummonBeast]|[*R>name]:Pack Tactics|[*R>description]:description:The beast has advantage on an attack roll against a creature if at least one of the beast’s allies is within 5 feet of the creature and the ally isn’t incapacitated. --Rnext| --!a:[&SummonBeast]|[*R>name]:|[*R>description]:description: --<| --:AddFB| --Rfirst|[&SummonBeast];repeating_npctrait --!a:[&SummonBeast]|![*R>name]:Flyby|![*R>description]:description:The beast doesn’t provoke opportunity attacks when it flies out of an enemy’s reach. --Rnext| --!a:[&SummonBeast]|[*R>name]:|[*R>description]:description: --<| --:AddWater| --Rfirst|[&SummonBeast];repeating_npctrait --!a:[&SummonBeast]|[*R>name]:Pack Tactics|[*R>description]:description:The beast has advantage on an attack roll against a creature if at least one of the beast’s allies is within 5 feet of the creature and the ally isn’t incapacitated. --Rnext| --!a:[&SummonBeast]|[*R>name]:Water Breathing|[*R>description]:description:The beast can breathe only underwater. --<| --:RepeatSec| --!or:[&SummonBeast]:npcaction| name:Maul| attack_flag:on| attack_type:melee| attack_target:one target| attack_range:5 ft.| attack_tohit:@{selected|spell_attack_bonus}| attack_damage:1d8 + 4 + [$SlotLevel]| attack_damagetype:piercing| attack_tohitrange:| attack_range:5ft.| attack_target:one target| attack_onhit:1d8 + 4 + [$SlotLevel]| description:The beast has advantage on an attack roll against a creature if at least one of the beast’s allies is within 5 feet of the creature and the ally isn’t incapacitated. --!or:[&SummonBeast]:npcaction|name:Multiattack|description:The beast makes a number of attacks equal to half this spell’s level (rounded down). --<| --:DeductSpellSlot| --=SlotsExpended|[$SlotsExpended] - 1 --!a:[*S:character_id]|lvl[$SlotLevel]_slots_expended:[$SlotsExpended] --+|Level [$SlotLevel] Slots Left: [$SlotsExpended] --X|Full Stop --:NoSlotsLeft| --+|[*S:character_name] has no level [$SlotLevel.Total] spell slots available. --X|NoSlotsLeftStop }}
1703709585

Edited 1703737848
Sorry for the back to back posts, but I figured it out, it was my sequence logic. I worked through it and it reduced the macro size significantly. This Macro also requires SpawnDefaultToken to be installed. If anyone wants to use this, create a new npc named SummonBeast and create two dummy traits, Then create a table multi token named SummonBeast and add three different tokens to represent Land, Air and Water beasts. You may have to change the order around if you don't get it right the first time. Don't forget to assign the token to the character sheet. Otherwise it should work fine. EDIT: It still isn't editing the hp and npc_ac on the sheet when the token has those set to the bars. It's still usable as the token is what the player is going to be paying attention to, but it still seems that it might be a bug? EDIT: Added name change when selecting different beast type. !scriptcards {{ --#title|Summon Beast --#sourceToken|@{selected|token_id} --#emoteText|[*S:character_name] Casts Summon Beast. --#bodyfontface|Helvetica --#oddrowfontcolor|#290000 --#evenrowfontcolor|#290000 --#bodyfontsize|[&bodyFontSize]px --#titlecardbackgroundcolor|#930c10 --#titlecardbackgroundcolor|#672223 --#titlefontcolor|#fffebd --#titlefontsize|1.5em --#titlefontshadow|0 --#oddrowbackground|#f7ce65 --#evenrowbackground|#f7ce65 --#oddrowbackground|#b3ab96 --#evenrowbackground|#b3ab96 --#subtitlefontcolor|#fffebd --#tablebgcolor|#fffebd --#lineheight|10pt --#Debug|1 --&SummonBeast|@{SummonBeast|character_id} -->WhatSpellSlot|>[$SlotLevel] -->GetBeast| -->CommonAttr|>[&hplvl] -->RepeatExist| -->DeductSpellSlot| --X| --:WhatSpellSlot| --=SlotLevel|?{Spell Slot Level Used?|2|3|4|5|6|7|8|9} --=SlotsTotal|0 --=SlotsExpended|[*S:lvl[$SlotLevel]_slots_expended] --?[$SlotsExpended.Total] -eq [$SlotsTotal.Total]|NoSlotsLeft --<| --:GetBeast| --=Beast|?{What Beast Type?|Land,1|Air,2|Sea,3} --?[$Beast] -eq 1|Land-Beast --?[$Beast] -eq 2|Air-Beast --?[$Beast] -eq 3|Sea-Beast --X| --:Land-Beast| --&Type|1 --&hplvl|30 --!a:[&SummonBeast]|!npc_name:Land Beast --Rfirst|[&SummonBeast];repeating_npctrait --!a:[&SummonBeast]|[*R>name]:Pack Tactics|[*R>description]:The beast has advantage on an attack roll against a creature if at least one of the beast’s allies is within 5 feet of the creature and the ally isn’t incapacitated. --Rnext| --!a:[&SummonBeast]|[*R>name]:|[*R>description]:description: --<| --:Air-Beast| --&Type|3 --&hplvl|20 --!a:[&SummonBeast]|!npc_name:Air Beast --Rfirst|[&SummonBeast];repeating_npctrait --!a:[&SummonBeast]|![*R>name]:Flyby|![*R>description]:The beast doesn’t provoke opportunity attacks when it flies out of an enemy’s reach. --Rnext| --!a:[&SummonBeast]|[*R>name]:|[*R>description]:description: --<| --:Sea-Beast| --&Type|2 --&hplvl|30 --!a:[&SummonBeast]|!npc_name:Sea Beast --Rfirst|[&SummonBeast];repeating_npctrait --!a:[&SummonBeast]|[*R>name]:Pack Tactics|[*R>description]:The beast has advantage on an attack roll against a creature if at least one of the beast’s allies is within 5 feet of the creature and the ally isn’t incapacitated. --Rnext| --!a:[&SummonBeast]|[*R>name]:Water Breathing|[*R>description]:The beast can breathe only underwater. --<| --:CommonAttr| --=ACCalc|11 + [$SlotLevel] --=hptotal|5 * [= [$SlotLevel] - 2] + [&hplvl] --&Speed|30ft, 30ft climb --!a:[&SummonBeast]|!npc_type:Medium Beast, Unaligned|!npc_ac:[$ACCalc]|!hp:[$hptotal]|!hp^:[$hptotal]|!strength_base:18|!dexterity_base:11|!constitution_base:16|!intelligence_base:4|!wisdom_base:14|!charisma_base:5|!npc_speed:[&Speed]|!npc_challenge: --@forselected|Spawn _name|SummonBeast _offset|1,0 _side|[&Type] --<| --:RepeatExist| --Rfind|[&SummonBeast];Maul;repeating_npcaction;name --&MaulExist|[*R:name] --?"[&MaulExist]" -ne "Maul"|RepeatSec --<| --:RepeatSec| --!or:[&SummonBeast]:npcaction| name:Maul| attack_flag:on| attack_type:melee| attack_target:one target| attack_range:5 ft.| attack_tohit:@{selected|spell_attack_bonus}| attack_damage:1d8 + 4 + [$SlotLevel]| attack_damagetype:piercing| attack_tohitrange:| attack_range:5ft.| attack_target:one target| attack_onhit:1d8 + 4 + [$SlotLevel]| description:The beast has advantage on an attack roll against a creature if at least one of the beast’s allies is within 5 feet of the creature and the ally isn’t incapacitated. --!or:[&SummonBeast]:npcaction|name:Multiattack|description:The beast makes a number of attacks equal to half this spell’s level (rounded down). --<| --:DeductSpellSlot| --=SlotsExpended|[$SlotsExpended] - 1 --!a:[*S:character_id]|lvl[$SlotLevel]_slots_expended:[$SlotsExpended] --+|Level [$SlotLevel] Slots Left: [$SlotsExpended] --X|Full Stop --:NoSlotsLeft| --+|[*S:character_name] has no level [$SlotLevel.Total] spell slots available. --X|NoSlotsLeftStop }}
1703743020

Edited 1703751501
Is there a command to remove a repeating row? I know --!or: is used to create. What's used to delete? for more context, I was trying to remove a repeating_inventory row once an item had been used Reading from this section on the scriptcards wiki, it doesn't seem like it states a way for us to remove a row. Repeating Rows are created using the syntax: --!or:character_id:sectionName|value:current:max|value:current:max... For example, to create a language proficiency on the currently selected character (5E): --!or:@{selected|character_id}:proficiencies|prof_type:LANGUAGE|name:Abyssal The max portion is optional and can be left out if it doesn't make sense (as in the line above). A bit more complicated example is below. This creates a repeating_npcaction on the currently selected character (note that ScriptCards doesn't have a way to check to see if the section exists, it will just create the appropriate attributes on the character - again, this is a 5E example, but repeating sections on any sheet can be created as long as you know what attributes you need to specify and the name of the section): !script {{ --!or:@{selected|character_id}:npcaction| name:Mega Bite| attack_flag:on| attack_type:melee| attack_target:one target| attack_range:5 ft.| attack_tohit:8| attack_damage:1d4 + 3| attack_damagetype:piercing| attack_tohitrange:+5, Reach 5ft., one target| attack_onhit:5 (1d4 + 3) piercing damage| attack_crit:1d4 }} Note that this is all one ScriptCards line, and could be written that way. Placing each attribute/value pair on its own line makes it a bit clearer to read, though. ScriptCards will assume that the section starts with repeating_ so it should not be specified in the section parameter (hence npcaction instead of "repeating_npcaction")
1703786179
Kurt J.
Pro
API Scripter
Hanen said: Is there a command to remove a repeating row? Currently, there are not method to actually delete anything through ScriptCards. That may change in the future, but right now creation and updating are supported but not deletion. Timothy B. said: EDIT: It still isn't editing the hp and npc_ac on the sheet when the token has those set to the bars. It's still usable as the token is what the player is going to be paying attention to, but it still seems that it might be a bug? This works normally for me: !script {{ --=ACCalc|1d15+10 --!a:@{selected|character_id}|!npc_ac:[$ACCalc] }} which updates both the npc_ac attribute on the NPC character sheet and the linked bar/bars as expected.
1703839370

Edited 1703839712
Kurt J. said: Hanen said: Is there a command to remove a repeating row? Currently, there are not method to actually delete anything through ScriptCards. That may change in the future, but right now creation and updating are supported but not deletion. For future reference and archiving, this is my workaround for removing a repeating row (Inventory in this case) with the help of Chatsetattr. &reentryval is replaced by the name of the current item you want to remove from another [rbutton] entry. Thanks! --:Removeitem| --%finditemrow|0;[*R:[*S:character_id]:repeating_inventory:rowcount] --Rbyindex|[*S:character_id];repeating_inventory;[&finditemrow] --?"[*R:itemname]" -eq "[&reentryval]"|finddone --%| --:finddone| --@delattr|_charid [*S:character_id] _repeating_inventory_$[&finditemrow] --+|[*R:itemname] Removed --^proc_start|
1705761574
Kurt J.
Pro
API Scripter
Just a heads up that ScriptCards 2.6.2 is now available on the GitHub site. I've added associative arrays (key/value pairs) called hashtables to the script, along with functions to support it. This should be coming to OneClick in the next week or so, but you can grab it now at  ScriptCards/ScriptCards_API at main · kjaegers/ScriptCards (github.com)
1705863131

Edited 1705863216
#concatenationCharacter feature seems to be broken on both one click (2.4.9) and most recent github version (2.6.2). running the example script on the wiki results in overwriting the string instead of appending. !script {{ --#concatenationCharacter|_ --&test|A quick brown fox --&test|_ jumped over the lazy dog. --+Output:|[&test] }} Results in:
Well the concatentationcharacter setting was introduced in 2.6.1. Per the changelog : v 2.6.1  - New setting - concatenationcharacter, which will allow you to set an alternative to starting string assignments with "+" to append.            This setting defaults to "+", but can be set to another single character if you need to include "+" symbols at the beginning of            your string variables. This is a per-line setting, so can be changed and changed back as needed. I am running 2.6.2a in a test game and this worked for me: !script {{ --#concatentioncharacter|_ --&var|Hello --&var|_ Goodbye --#concatentioncharacter|+ --+|[&var] }} Resulted in: Perhaps confirm in the console of the API sandbox that you are seeing the 2.6.1+ version getting loaded. With a line like: "-=> ScriptCards - 2.6.2a by Kurt Jaegers Ready <=- Meta Offset : 21995"
1705865705

Edited 1705865980
I was on 2.6.2a and your code works because you correctly misspelled concatenation. The correct spelling is concatenation and that's whats on the wiki, but the feature only works if you spell it concatention, like you did in your code. My code also works when you remove the a. Thanks
1705867192

Edited 1705867243
the two spelling mistakes i found are on lines 118 and 5875 of ScriptCards 2.6.2a .js file simply adding the a on both these lines allowed the wiki example script to work
also keep up the good work, kurt. havent used scriptcards in over a year but coming back to it ive noticed a lot of nice new features
Hi ppl, I know that you can use overridetemplate to use automatic formatting and technically custom templates are not yet supported, but could you use the ScriptCards Libraries feature to do this?
Scriptcards that worked fine a year ago are breaking now, particularly macros that invoke other scripts. What should I change in the example below? Calling tokenmod direcly works fine, but not thru scriptcards (I want to use conditional statements). !token-mod --set statusmarkers|yellow !script {{ --@token-mod| _ids @{selected|token_id} _set statusmarkers|yellow }}
Kaspar, in your game have you checked that token-mod is set that players can use IDs? It's a pretty common cause of token-mod not working via ScriptCards. Per the TokenMod wiki !token-mod --config players-can-ids|on
Timothy B. said: Hi ppl, I know that you can use overridetemplate to use automatic formatting and technically custom templates are not yet supported, but could you use the ScriptCards Libraries feature to do this? Timothy, can you explain what you mean by custom templates not being supported? In the  Override Templates section of the ScriptCards wiki  there is a subsection about defining your own custom template to use with a bunch of CSS. There is also a the Save and Load mechanisms that will allow you to save settings so you can save formatting in various variables to load up in your ScriptCards. For example you could save a bunch of --# formatting settings under each player's name and then load them with the [&SendingPlayerName] variable that ScriptCards sets automatically. Alternatively you could do that in a library if you wanted as well. More than one way to accomplish formatting depending on what you prefer and what exactly you want to accomplish.
Hi Joshua, Seems I just missed that for some reason. I think I took context clues from an old post that this wasn't possible yet and missed where it became possible. Thanks Joshua.
1706195195

Edited 1706195984
Is there a more thorough example of the css code and sections under additional notes? There are sections of the template I can't seem to affect, like the subtitle background. But, when I try and use the sections under additional notes, I get "undefined" as the output. This is what I'm trying to achieve: I like the padding in the body better on the following one, but the button alignment is weird and I can't change the background color of the subtitle "absorb elements". EDIT: I really like the dnd5e template and would be really happy with that, but the buttons... those ugly buttons.
Hi, Is there a way to include a link to a handout in a script card. Maybe similar to a button where you click on it to open the handout. Thanks
FFR said: Hi, Is there a way to include a link to a handout in a script card. Maybe similar to a button where you click on it to open the handout. Thanks Yes you can have a button link to a handout. Here's a simple example: !scriptcard {{ --&amp;HandoutName|Mysterious Note --#title|Handout Links --~|array;objects:handout;HandoutArr;[&amp;HandoutName] --?[@HandoutArr(length)] -eg 0|Done --&amp;HandoutID|[@HandoutArr(0)] --+Handout Link|[button][&amp;HandoutName]::<a href="http://journal.roll20.net/handout/[&amp;HandoutID][/button]" rel="nofollow">http://journal.roll20.net/handout/[&amp;HandoutID][/button]</a> --:Done| }} This will fetch the Handout ID by filtering on the Handout Name and then including a button to a link with that ID. That's what the example above looks like and the button opens the handout.
Joshua, That works perfectly and thanks for your help
1706359742
Kurt J.
Pro
API Scripter
DoctorBub said: also keep up the good work, kurt. havent used scriptcards in over a year but coming back to it ive noticed a lot of nice new features Argh! :) Sorry. I just pushed a fix for the typo, and left "concatentioncharacter" behind as an alias name (so as not to break existing scripts). Thanks for finding this :)
1706368146
Kurt J.
Pro
API Scripter
ScriptCards 2.6.2b is Queued for OneClick Inclusion The most recent updates to ScriptCards has now been queued for inclusion in OneClick. The 2.6.2b code and changelog are available on GitHub at&nbsp; <a href="https://github.com/kjaegers/ScriptCards/tree/main/ScriptCards_API" rel="nofollow">https://github.com/kjaegers/ScriptCards/tree/main/ScriptCards_API</a> &nbsp;which will have more detail than the summary below. Additionally, the&nbsp; Script:ScriptCards - Roll20 Wiki &nbsp;is being updated (or has already been) with these features/changes. Here is a summary of the changes since 2.4.9: Added support for Hash Tables (sometimes called Associative Arrays). You can define hashtable elements with the --h command or with --~|hash functions. The reference sequence for hash table values is [:HashTableName("Key")]. As an example, this script creates a hash table called Fruits and fills in key/value pairs with both options (--~ and --h). It then uses arrays to loop through the keys and output the value: !script {{ &nbsp;--~|hash;set;Fruits;Mango-Cost==2sp;Mango-Size==Medium;Mango-Shape==Oblong &nbsp; &nbsp;--h:Fruits("Apple-Cost")|2cp &nbsp;--h:Fruits("Apple-Size")|Medium &nbsp;--h:Fruits("Apple-Shape")|Round &nbsp; &nbsp;--h:Fruits("Watermelon-Cost")|1gp &nbsp;--h:Fruits("Watermelon-Size")|Large &nbsp;--h:Fruits("Watermelon-Shape")|Oblong &nbsp; &nbsp;--h:Fruits("Grape-Cost")|1cp &nbsp;--h:Fruits("Grape-Size")|Small &nbsp;--h:Fruits("Grape-Shape")|Round &nbsp; &nbsp;--~|array;define;fruits;Apple;Mango;Watermelon;Grape &nbsp;--~|array;define;fields;Cost;Size;Shape &nbsp;--%fruit|foreach;fruits &nbsp;--%field|foreach;fields &nbsp;--+[&amp;fruit]-[&amp;field]|[:Fruits("[&amp;fruit]-[&amp;field]")] &nbsp;--%| &nbsp;--%| &nbsp;}}&nbsp; The --s and --l commands have been updated to allow for the storage of data types on a special character named "ScriptCards_Storage". After creating this character, you must restart the sandbox to use it. The new variations of --s and --l take an identifier character to determine what type of item(s) are being stored. &nbsp;--s$optionalprefix| &lt;-- Stores Roll Variables &nbsp;--s&amp;optionalprefix| &lt;-- Stores String Variables &nbsp;--s@optionalprefix| &lt;-- Stores Arrays &nbsp;--s:optionalprefix| &lt;-- Stores Hash Tables &nbsp;--s#optionalprefix| &lt;-- Stores ScriptCards Settings &nbsp;--l$optionalprefix| &lt;-- Loads Roll Variables &nbsp;--l&amp;optionalprefix| &lt;-- Loads String Variables &nbsp;--l@optionalprefix| &lt;-- Loads Arrays &nbsp;--l:optionalprefix| &lt;-- Loads Hash Tables &nbsp;--l#optionalprefix| &lt;-- Loads ScriptCards Settings &nbsp; The " optionalprefix " can be used to store multiple values with the same name (in the example below, "charactername" prefixed with "fred" &nbsp; Example 1: Store a single value &nbsp; --s&amp;|MyStringValue Example 2: Store an array with all of its values &nbsp; --s@|DonutFlavors Example 3: Store a string with a prefix, allowing you to store multiple values with the same variable name if needed &nbsp;--s&amp;fred|charactername &nbsp; Example 4: Store multile values of the same type in one line, separated by semicolons. Here we store three roll variables in a single command &nbsp;--s$|MyFirstNumber;MySecondNumber;MyThirdNumber3 &nbsp; You can now set "speakingas" with object modification by substituting a ^ charater for the pipe (|) normally used. Added the ability to specify default values for [*...] lookups for S, T, and IDs by including the desired default after a ::. For example: [*S:Height::50] will return the value of the Height attribute on the sourcetoken. If it can't find Height, it will return 50. New setting - concatenationcharacter, which will allow you to set an alternative to starting string assignments with "+" to append. This setting defaults to "+", but can be set to another single character if you need to include "+" symbols at the beginning of&nbsp; your string variables. This is a per-line setting, so can be changed and changed back as needed. Modified behavior for add:* triggers. When the roll20 event fires, not all of the information is filled in by the back-end yet, so add triggers will only return an object id and will pause for 500ms before executing the associated trigger ability from your trigger mule.
I am using the following script to auto damage a targeted token. It works great but how can I have it report the damage subtracted within the chat window? --&amp;AutoApplyDamage|true --&amp;HPBar|1 --?"[&amp;AutoApplyDamage]" -ne "true"|Done --!t:[*T:t-id]|bar[&amp;HPBar]_value:-=[$Damage] &nbsp; --^Final|
Sorry for the basic question but still learning. On the following script I saw from above, how can it be be adjusted to so that the button activates the ability "3rd Level spell" on the journal "Conjure Animals"? !scriptcard {{ --&amp;HandoutName|Mysterious Note --#title|Handout Links --~|array;objects:handout;HandoutArr;[&amp;HandoutName] --?[@HandoutArr(length)] -eg 0|Done --&amp;HandoutID|[@HandoutArr(0)] --+Handout Link|[button][&amp;HandoutName]::<a href="http://journal.roll20.net/handout/[&amp;HandoutID][/button]" rel="nofollow">http://journal.roll20.net/handout/[&amp;HandoutID][/button]</a> --:Done| }}
1706495961
Andrew R.
Pro
Sheet Author
Barry S. said: I am using the following script to auto damage a targeted token. It works great but how can I have it report the damage subtracted within the chat window? --&amp;AutoApplyDamage|true --&amp;HPBar|1 --?"[&amp;AutoApplyDamage]" -ne "true"|Done --!t:[*T:t-id]|bar[&amp;HPBar]_value:-=[$Damage] &nbsp; --^Final| You would use a —+ command,&nbsp; —+Damage|[$Damage]
1706662815
Kurt J.
Pro
API Scripter
Just a note to say that ScriptCards 2.6.2 is now live on OneClick.
1707935838
Kurt J.
Pro
API Scripter
I have uploaded ScriptCards 2.6.3 to the GitHub (<a href="https://github.com/kjaegers/ScriptCards/tree/main/ScriptCards_API" rel="nofollow">https://github.com/kjaegers/ScriptCards/tree/main/ScriptCards_API</a>) to correct a potentially incorrect detection of abilities for triggers. The incorrect detection should not have resulted in any issues, but the detection code won't hallucinate one now :)
1708278248
Kurt J.
Pro
API Scripter
Just a heads up that 2.6.4 has been pushed to the github. If you are using the recently updated syntax to supply defaults for [*...] lookups, the sequence is changing from "::" to ":::" because Roll20 uses double colons in custom status marker names. This may impact scripts using that feature, &nbsp;which I hate to do, but it is a very recent addition, and this change avoids problems when referencing status marker information.
out of curiosity, has anyone written a script for D&amp;D Punching attack that also checks for KO% based on what the attack roll result was?
1709410563

Edited 1709410580
gabriel b. said: out of curiosity, has anyone written a script for D&amp;D Punching attack that also checks for KO% based on what the attack roll result was? Hi Gabriel, Are there specific rules for such an event? I don't recall any official rules for a knock out percentage, only bringing someone to 0 hp usually knocks them out.
Timothy B. said: gabriel b. said: out of curiosity, has anyone written a script for D&amp;D Punching attack that also checks for KO% based on what the attack roll result was? Hi Gabriel, Are there specific rules for such an event? I don't recall any official rules for a knock out percentage, only bringing someone to 0 hp usually knocks them out. yeah, here you go.&nbsp; basically, depending on the roll (if it hits) it would have a certain % to KO
1709477984
Kurt J.
Pro
API Scripter
That's from 2E D&amp;D. I don't have an active 2E game right now, but the following script shows a workable example. The AttackRoll line would need to be modified to pull roll modifiers from your character sheet, and you could test for a hit vs. AC, but this will do the basics: !script {{ --~|array;define;punches;Haymaker;Wild swing;Uppercut;Hook;Rabbit punch;Glancing blow;Jab;Combination;Glancing blow;Uppercut;Combination;Glancing blow;Hook;Kidney punch;Hook;Uppercut;Jab;Glancing blow;Kidney punch;Rabbit punch;Wild swing;Haymaker --~|array;define;wrestles;Bearhun;Leg twist;Headlock;Gouge;Arm lock;Kick;Gouge;Throw;Headlock;Leg lock;Elbow smash;Gouge;Throw;Leg lock;Leg twist;Arm lock;Elbow smasg;trip;Kick;Arm twist;Bear hug --~|array;define;movedamage;2;0;2;2;2;1;2;2;1;1;1;2;1;2;1;2;1;1;1;0;2 --~|array;define;knockout;25;2;15;12;5;3;8;10;9;10;3;10;5;9;8;6;2;5;3;1;10 --/|Note - Edit the line below depending on the character sheet attributes to add bonuses, etc. --=AttackRoll|1d20 + 5 --=LookupEntry|[$AttackRoll] {CLAMP:0:20} --+Attack Roll|[$AttackRoll] --+Loopup|[$LookupEntry] --+Punch|[@punches([$LookupEntry.Raw])] --+Wrestling Move|[@wrestles([$LookupEntry.Raw])] --+Damage|[@movedamage([$LookupEntry.Raw])] --+Knockout|[@knockout([$LookupEntry.Raw])]% }}
1709478573

Edited 1709478610
Kurt J.
Pro
API Scripter
ScriptCards 2.6.6b Headed for OneClick The latest GitHub release of ScriptCards is now queued for OneClick inclusion. Here are the changes since 2.6.2c: Important &nbsp;- The default specifier for [*...] references has been changed from "::" to ":::" to avoid clashing with custom status marker names. Unfortunately this may be a breaking change if you currently use :: in your [*...] references. This feature itself is relatively new, however, so may not be widely used at this point. Small change to the way trigger abilities are detected to correct a non-optimal code pattern Borrowed a technique from Token Mod to ensure dynamic lighting gets refreshed when changing token properties Setting "night_vision_effect" to "Dimming" will automatically be updated to "Dimming_0". This setting is a single string but is split into two entities in the UI, which are converted and concatenated. The number after the _ is how may feet away from the token the dimming starts. When setting repeating section attributes, if the specified attribute doesn't exist it will be created - even without prefixing it with "!". This works around an issue with at least the 5e sheet, maybe a wider one where toggle-style attributes (check boxes) with default sheet values don't *actually"&nbsp; create the attribute on the character if the attribute isn't changed manually. This update removes the need to toggle things like global modifiers on/off once before they work in the 5E Action Menu or can be set via ScriptCards.&nbsp; Work on version 2.7.0 is currently in progress, and will support new features coming in the March 2024 API update as well as a handful of other updates and changes.
1709489142
vÍnce
Pro
Sheet Author
Kurt J. said: When setting repeating section attributes, if the specified attribute doesn't exist it will be created - even without prefixing it with "!". This works around an issue with at least the 5e sheet, maybe a wider one where toggle-style attributes (check boxes) with default sheet values don't *actually"&nbsp; create the attribute on the character if the attribute isn't changed manually. This update removes the need to toggle things like global modifiers on/off once before they work in the 5E Action Menu or can be set via ScriptCards. HI Kurt, for reasons... I've resigned to setting repeating attributes to their default values (via sheet workers) in order for them to show up for API mods.&nbsp; Do you think this update now makes this unnecessary?&nbsp; At least in regards to the SC mod?&nbsp; Curious, how does SC know what the default value should be?&nbsp; Thanks
1709577989

Edited 1709578022
Kurt J. said: That's from 2E D&amp;D. I don't have an active 2E game right now, but the following script shows a workable example. The AttackRoll line would need to be modified to pull roll modifiers from your character sheet, and you could test for a hit vs. AC, but this will do the basics: !script {{ --~|array;define;punches;Haymaker;Wild swing;Uppercut;Hook;Rabbit punch;Glancing blow;Jab;Combination;Glancing blow;Uppercut;Combination;Glancing blow;Hook;Kidney punch;Hook;Uppercut;Jab;Glancing blow;Kidney punch;Rabbit punch;Wild swing;Haymaker --~|array;define;wrestles;Bearhun;Leg twist;Headlock;Gouge;Arm lock;Kick;Gouge;Throw;Headlock;Leg lock;Elbow smash;Gouge;Throw;Leg lock;Leg twist;Arm lock;Elbow smasg;trip;Kick;Arm twist;Bear hug --~|array;define;movedamage;2;0;2;2;2;1;2;2;1;1;1;2;1;2;1;2;1;1;1;0;2 --~|array;define;knockout;25;2;15;12;5;3;8;10;9;10;3;10;5;9;8;6;2;5;3;1;10 --/|Note - Edit the line below depending on the character sheet attributes to add bonuses, etc. --=AttackRoll|1d20 + 5 --=LookupEntry|[$AttackRoll] {CLAMP:0:20} --+Attack Roll|[$AttackRoll] --+Loopup|[$LookupEntry] --+Punch|[@punches([$LookupEntry.Raw])] --+Wrestling Move|[@wrestles([$LookupEntry.Raw])] --+Damage|[@movedamage([$LookupEntry.Raw])] --+Knockout|[@knockout([$LookupEntry.Raw])]% }} thanks, Kurt.&nbsp; this helps.&nbsp; I am also getting assistance from Timothy as well.&nbsp; quick question for you (or maybe not).&nbsp; if a character is specialized or has mastery in the punching proficiency, they can choose 1-up or 1-down from the chart (for specialized in punching proficiency).&nbsp; how would you recommend I show the additional options (up 1 and down 1)?
1709582825

Edited 1709585788
huh, reading through the wiki, I believe my above is addressed by&nbsp; getnext &nbsp;and&nbsp; getprevious&nbsp; thought I am not certain how to use this yes, I am quite inexperienced in coding, but I am enjoying the discovery/learning process :)
1709589656
Kurt J.
Pro
API Scripter
vÍnce said: Kurt J. said: When setting repeating section attributes, if the specified attribute doesn't exist it will be created - even without prefixing it with "!". This works around an issue with at least the 5e sheet, maybe a wider one where toggle-style attributes (check boxes) with default sheet values don't *actually"&nbsp; create the attribute on the character if the attribute isn't changed manually. This update removes the need to toggle things like global modifiers on/off once before they work in the 5E Action Menu or can be set via ScriptCards. HI Kurt, for reasons... I've resigned to setting repeating attributes to their default values (via sheet workers) in order for them to show up for API mods.&nbsp; Do you think this update now makes this unnecessary?&nbsp; At least in regards to the SC mod?&nbsp; Curious, how does SC know what the default value should be?&nbsp; Thanks It need to do some more testing on that, but I'm hopeful it will
Reposting to specific forum I'm currently converting a set of skirmish rules to roll20, when taking a shot there are various questions that are asked, currently doing it in scriptcards like this --=AttackRoll|1d10 + ?{Aiming|No, 0|Yes, 1} + ?{Lily-Livered|No, 0|Yes, -1} + ?{Target in partial cover|No, 0|Yes, -1} + ?{Target in hard cover|No, 0|Yes, -2} + ?{Firer mounted|No, 0|Yes, -2} + ?{Target Stealthy|No, 0|Yes, -1} which is fine as far as it goes, but, it is using the roll20 parser and presents each question individually (and there are a few more to add), is there a way to have a single dialog&nbsp; type popup which allows a user to tick the options which apply to the attack and then submit and return a single figure representing the sum of each modifier?
1709718067

Edited 1709718295
Kurt J.
Pro
API Scripter
Norman said: Reposting to specific forum I'm currently converting a set of skirmish rules to roll20, when taking a shot there are various questions that are asked, currently doing it in scriptcards like this --=AttackRoll|1d10 + ?{Aiming|No, 0|Yes, 1} + ?{Lily-Livered|No, 0|Yes, -1} + ?{Target in partial cover|No, 0|Yes, -1} + ?{Target in hard cover|No, 0|Yes, -2} + ?{Firer mounted|No, 0|Yes, -2} + ?{Target Stealthy|No, 0|Yes, -1} which is fine as far as it goes, but, it is using the roll20 parser and presents each question individually (and there are a few more to add), is there a way to have a single dialog&nbsp; type popup which allows a user to tick the options which apply to the attack and then submit and return a single figure representing the sum of each modifier? One of the limitations of the Roll20 API is that API scripts ***only*** way to interact with the user is through the chat window. Even roll queries are not actually part of the API but rather the chat interface. This restriction is why you see things like ScriptCards and other APIs that use chat output with buttons to set/update options. The 5E Character Action Menu makes extensive use of this via reentrant buttons, and supports toggling options on and off via buttons for things like advantage and global modifiers. This does have the result of re-displaying the menu to the sender on every click and then sending the final result to the general chat window, but it does work. That script is here:&nbsp; ScriptCards/ScriptCards_Examples/dnd5e/5e_Character_Action_Menu.scard at main · kjaegers/ScriptCards (github.com) &nbsp;
Thanks Kurt, I'll take a look. I'm very much a beginner with the using the API and mods and am rapidly getting out of my depth :)&nbsp; anyway, I'll keep plugging away at it - best way to learn - right?