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

1612831554

Edited 1612831575
Kurt J.
Pro
API Scripter
Duncan R. said: Looks good, thanks for all the effort. I have added in the new API script version but getting a bit late here now, so a test 'the repeat function' tomorrow task now. The -eqi and -nei change made me think. Is the Rfind case sensitive, I couldn't see it in the Wiki, I assume it is? It is, because of the way it asks roll20 for the object information. Fortunately for compendium drags the text should be fairly consistent.
Trying to call a repeating resource value and I'm running into trouble. I can use Rfind to get the resource itself by name. The problem is when I want to reference the value of the repeating resource: !scriptcard  {{   --Rfind|@{selected|character_id};Potion of Superior Healing;repeating_resource;name   --+Potions of Superior Healing|[*R:WHAT_DO_I_PUT_HERE] }} I can't put the name, because it will just spit out the resource name in chat. I want to obtain the current value (not the max) from the resource field (which is 0, in this instance), but when I mouse over the 0 in the character sheet, all I get is {repeating_resource_right}. I'm sure I'm missing something basic here. How does one reference the value for a repeating resource without using the "repeating_resource_$0_resource_right" syntax?
1612874788

Edited 1612874850
Kurt J.
Pro
API Scripter
Jay R. said: Trying to call a repeating resource value and I'm running into trouble. I can use Rfind to get the resource itself by name. The problem is when I want to reference the value of the repeating resource: !scriptcard  {{   --Rfind|@{selected|character_id};Potion of Superior Healing;repeating_resource;name   --+Potions of Superior Healing|[*R:WHAT_DO_I_PUT_HERE] }} I can't put the name, because it will just spit out the resource name in chat. I want to obtain the current value (not the max) from the resource field (which is 0, in this instance), but when I mouse over the 0 in the character sheet, all I get is {repeating_resource_right}. I'm sure I'm missing something basic here. How does one reference the value for a repeating resource without using the "repeating_resource_$0_resource_right" syntax? Repeating Resources on the 5E sheet are kinda oddball because each row is actually two resources (right and left). Here is a script that will run through all of the resource rows and build a list of available healing potions. For my test setup, I named Healing Potions "Healing Potion" and the others "Greater Healing", "Superior Healing", and "Supreme Healing". Except for the first one, I could then just use "-inc" to look for the keywords instead of the full names. The script uses --Rfirst and --Rnext to loop through all of the repeating_resource rows on the character sheet to summarize the available healing potions. Here is the output: and the script: !script {{ --#title|Healing Potion Report --#leftsub|@{selected|token_name} --=Healing|0 --=Greater|0 --=Superior|0 --=Supreme|0 -->CheckPotions| --+Healing|[$Healing.Total] --+Greater Healing|[$Greater.Total] --+Superior Healing|[$Superior.Total] --+Supreme Healing|[$Supreme.Total] --X| --:CheckPotions| --Rfirst|@{selected|character_id};repeating_resource --:ResourceLoop| --?"[*R:resource_left_name]" -eq "Healing Potion"|>SetHealing;[*R:resource_left] --?"[*R:resource_right_name]" -eq "Healing Potion"|>SetHealing;[*R:resource_right] --?"[*R:resource_left_name]" -inc "greater"|>SetGreater;[*R:resource_left] --?"[*R:resource_right_name]" -inc "greater"|>SetGreater;[*R:resource_right] --?"[*R:resource_left_name]" -inc "superior"|>SetSuperior;[*R:resource_left] --?"[*R:resource_right_name]" -inc "superior"|>SetSuperior;[*R:resource_right] --?"[*R:resource_left_name]" -inc "supreme"|>SetSupreme;[*R:resource_left] --?"[*R:resource_right_name]" -inc "supreme"|>SetSupreme;[*R:resource_right] --Rnext| --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|ResourceLoop --<| --:SetHealing| --=Healing|[%1%] --<| --:SetGreater| --=Greater|[%1%] --<| --:SetSuperior| --=Superior|[%1%] --<| --:SetSupreme| --=Supreme|[%1%] --<| }} Since we might not be sure which side of the row we have our data on, we just check each left and right to see if it matches the string we are looking for and call the appropriate "Set" procedure, passing it the number.
Kurt J. said: Jay R. said: Trying to call a repeating resource value and I'm running into trouble. I can use Rfind to get the resource itself by name. The problem is when I want to reference the value of the repeating resource: !scriptcard  {{   --Rfind|@{selected|character_id};Potion of Superior Healing;repeating_resource;name   --+Potions of Superior Healing|[*R:WHAT_DO_I_PUT_HERE] }} I can't put the name, because it will just spit out the resource name in chat. I want to obtain the current value (not the max) from the resource field (which is 0, in this instance), but when I mouse over the 0 in the character sheet, all I get is {repeating_resource_right}. I'm sure I'm missing something basic here. How does one reference the value for a repeating resource without using the "repeating_resource_$0_resource_right" syntax? Repeating Resources on the 5E sheet are kinda oddball because each row is actually two resources (right and left). Here is a script that will run through all of the resource rows and build a list of available healing potions. For my test setup, I named Healing Potions "Healing Potion" and the others "Greater Healing", "Superior Healing", and "Supreme Healing". Except for the first one, I could then just use "-inc" to look for the keywords instead of the full names. The script uses --Rfirst and --Rnext to loop through all of the repeating_resource rows on the character sheet to summarize the available healing potions. Here is the output: and the script: !script {{ --#title|Healing Potion Report --#leftsub|@{selected|token_name} --=Healing|0 --=Greater|0 --=Superior|0 --=Supreme|0 -->CheckPotions| --+Healing|[$Healing.Total] --+Greater Healing|[$Greater.Total] --+Superior Healing|[$Superior.Total] --+Supreme Healing|[$Supreme.Total] --X| --:CheckPotions| --Rfirst|@{selected|character_id};repeating_resource --:ResourceLoop| --?"[*R:resource_left_name]" -eq "Healing Potion"|>SetHealing;[*R:resource_left] --?"[*R:resource_right_name]" -eq "Healing Potion"|>SetHealing;[*R:resource_right] --?"[*R:resource_left_name]" -inc "greater"|>SetGreater;[*R:resource_left] --?"[*R:resource_right_name]" -inc "greater"|>SetGreater;[*R:resource_right] --?"[*R:resource_left_name]" -inc "superior"|>SetSuperior;[*R:resource_left] --?"[*R:resource_right_name]" -inc "superior"|>SetSuperior;[*R:resource_right] --?"[*R:resource_left_name]" -inc "supreme"|>SetSupreme;[*R:resource_left] --?"[*R:resource_right_name]" -inc "supreme"|>SetSupreme;[*R:resource_right] --Rnext| --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|ResourceLoop --<| --:SetHealing| --=Healing|[%1%] --<| --:SetGreater| --=Greater|[%1%] --<| --:SetSuperior| --=Superior|[%1%] --<| --:SetSupreme| --=Supreme|[%1%] --<| }} Since we might not be sure which side of the row we have our data on, we just check each left and right to see if it matches the string we are looking for and call the appropriate "Set" procedure, passing it the number. Ah, thank you! I've modified this a bit because I'm using other_resource to track regular potions of healing on my party's character sheets, and also used eq with full name for greater and superior because class abilities (such as the battlemaster's superiority dice) might mess results up using inc. But now potion numbers display correctly for all my characters!
Quick question: does Scriptcards support the ability to receive variable input at runtime, similar to how one would use the ?[Menu|Option X|Option Y] syntax to allow such input in regular macros?
1612884640
David M.
Pro
API Scripter
Yep! You can assign query values directly to a roll or string variable, or use it later in the macro !scriptcards {{ --=Roll_1|1d20 + ?{Modifier|0} --+Roll with Mod|[$Roll_1] --+Mod entered|?{Modifier} --=Roll_2|[$Roll_1] + ?{Modifier} --+Add the Mod Again|[$Roll_2] --&Text| I just entered ?{Enter Text|SomeDefaultText} --+Text|[&Text] }}
David M. said: Yep! You can assign query values directly to a roll or string variable, or use it later in the macro !scriptcards {{ --=Roll_1|1d20 + ?{Modifier|0} --+Roll with Mod|[$Roll_1] --+Mod entered|?{Modifier} --=Roll_2|[$Roll_1] + ?{Modifier} --+Add the Mod Again|[$Roll_2] --&Text| I just entered ?{Enter Text|SomeDefaultText} --+Text|[&Text] }} Sweet! Thank you.
1612892732
Duncan R.
Pro
Sheet Author
Kurt J. said: Duncan R. said: Looks good, thanks for all the effort. I have added in the new API script version but getting a bit late here now, so a test 'the repeat function' tomorrow task now. The -eqi and -nei change made me think. Is the Rfind case sensitive, I couldn't see it in the Wiki, I assume it is? It is, because of the way it asks roll20 for the object information. Fortunately for compendium drags the text should be fairly consistent. That works exactly how I wanted. Thanks. Now I just need to get those macros written and tested for Saturday's game.
Kurt J. said: Jay R. said: Trying to call a repeating resource value and I'm running into trouble. I can use Rfind to get the resource itself by name. The problem is when I want to reference the value of the repeating resource: !scriptcard  {{   --Rfind|@{selected|character_id};Potion of Superior Healing;repeating_resource;name   --+Potions of Superior Healing|[*R:WHAT_DO_I_PUT_HERE] }} I can't put the name, because it will just spit out the resource name in chat. I want to obtain the current value (not the max) from the resource field (which is 0, in this instance), but when I mouse over the 0 in the character sheet, all I get is {repeating_resource_right}. I'm sure I'm missing something basic here. How does one reference the value for a repeating resource without using the "repeating_resource_$0_resource_right" syntax? Repeating Resources on the 5E sheet are kinda oddball because each row is actually two resources (right and left). Here is a script that will run through all of the resource rows and build a list of available healing potions. For my test setup, I named Healing Potions "Healing Potion" and the others "Greater Healing", "Superior Healing", and "Supreme Healing". Except for the first one, I could then just use "-inc" to look for the keywords instead of the full names. The script uses --Rfirst and --Rnext to loop through all of the repeating_resource rows on the character sheet to summarize the available healing potions. Here is the output: and the script: !script {{ --#title|Healing Potion Report --#leftsub|@{selected|token_name} --=Healing|0 --=Greater|0 --=Superior|0 --=Supreme|0 -->CheckPotions| --+Healing|[$Healing.Total] --+Greater Healing|[$Greater.Total] --+Superior Healing|[$Superior.Total] --+Supreme Healing|[$Supreme.Total] --X| --:CheckPotions| --Rfirst|@{selected|character_id};repeating_resource --:ResourceLoop| --?"[*R:resource_left_name]" -eq "Healing Potion"|>SetHealing;[*R:resource_left] --?"[*R:resource_right_name]" -eq "Healing Potion"|>SetHealing;[*R:resource_right] --?"[*R:resource_left_name]" -inc "greater"|>SetGreater;[*R:resource_left] --?"[*R:resource_right_name]" -inc "greater"|>SetGreater;[*R:resource_right] --?"[*R:resource_left_name]" -inc "superior"|>SetSuperior;[*R:resource_left] --?"[*R:resource_right_name]" -inc "superior"|>SetSuperior;[*R:resource_right] --?"[*R:resource_left_name]" -inc "supreme"|>SetSupreme;[*R:resource_left] --?"[*R:resource_right_name]" -inc "supreme"|>SetSupreme;[*R:resource_right] --Rnext| --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|ResourceLoop --<| --:SetHealing| --=Healing|[%1%] --<| --:SetGreater| --=Greater|[%1%] --<| --:SetSuperior| --=Superior|[%1%] --<| --:SetSupreme| --=Supreme|[%1%] --<| }} Since we might not be sure which side of the row we have our data on, we just check each left and right to see if it matches the string we are looking for and call the appropriate "Set" procedure, passing it the number. OK, so I have the display up and running. My next question: is it possible to modify a repeating resource using Rfind and modbattr (command from ChatSetAttr)? I'm running into the same problem as before, where I need to let ChatSetAttr know which repeating resource to use for a healing potion (let's say greater healing) but without using the row index method (repeating_resource_$0_left, etc.). 
Jay R. said: OK, so I have the display up and running. My next question: is it possible to modify a repeating resource using Rfind and modbattr (command from ChatSetAttr)? I'm running into the same problem as before, where I need to let ChatSetAttr know which repeating resource to use for a healing potion (let's say greater healing) but without using the row index method (repeating_resource_$0_left, etc.).  After thinking about it, I might just revamp what I have to use attributes instead of repeating resources for this particular set of scriptcards. (and, I am now not sure why I didn't think of using attributes to track potion use like, years ago, lol)
1612921127
Kurt J.
Pro
API Scripter
Jay R. said: Kurt J. said: Jay R. said: Trying to call a repeating resource value and I'm running into trouble. I can use Rfind to get the resource itself by name. The problem is when I want to reference the value of the repeating resource: !scriptcard  {{   --Rfind|@{selected|character_id};Potion of Superior Healing;repeating_resource;name   --+Potions of Superior Healing|[*R:WHAT_DO_I_PUT_HERE] }} I can't put the name, because it will just spit out the resource name in chat. I want to obtain the current value (not the max) from the resource field (which is 0, in this instance), but when I mouse over the 0 in the character sheet, all I get is {repeating_resource_right}. I'm sure I'm missing something basic here. How does one reference the value for a repeating resource without using the "repeating_resource_$0_resource_right" syntax? Repeating Resources on the 5E sheet are kinda oddball because each row is actually two resources (right and left). Here is a script that will run through all of the resource rows and build a list of available healing potions. For my test setup, I named Healing Potions "Healing Potion" and the others "Greater Healing", "Superior Healing", and "Supreme Healing". Except for the first one, I could then just use "-inc" to look for the keywords instead of the full names. The script uses --Rfirst and --Rnext to loop through all of the repeating_resource rows on the character sheet to summarize the available healing potions. Here is the output: and the script: !script {{ --#title|Healing Potion Report --#leftsub|@{selected|token_name} --=Healing|0 --=Greater|0 --=Superior|0 --=Supreme|0 -->CheckPotions| --+Healing|[$Healing.Total] --+Greater Healing|[$Greater.Total] --+Superior Healing|[$Superior.Total] --+Supreme Healing|[$Supreme.Total] --X| --:CheckPotions| --Rfirst|@{selected|character_id};repeating_resource --:ResourceLoop| --?"[*R:resource_left_name]" -eq "Healing Potion"|>SetHealing;[*R:resource_left] --?"[*R:resource_right_name]" -eq "Healing Potion"|>SetHealing;[*R:resource_right] --?"[*R:resource_left_name]" -inc "greater"|>SetGreater;[*R:resource_left] --?"[*R:resource_right_name]" -inc "greater"|>SetGreater;[*R:resource_right] --?"[*R:resource_left_name]" -inc "superior"|>SetSuperior;[*R:resource_left] --?"[*R:resource_right_name]" -inc "superior"|>SetSuperior;[*R:resource_right] --?"[*R:resource_left_name]" -inc "supreme"|>SetSupreme;[*R:resource_left] --?"[*R:resource_right_name]" -inc "supreme"|>SetSupreme;[*R:resource_right] --Rnext| --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|ResourceLoop --<| --:SetHealing| --=Healing|[%1%] --<| --:SetGreater| --=Greater|[%1%] --<| --:SetSuperior| --=Superior|[%1%] --<| --:SetSupreme| --=Supreme|[%1%] --<| }} Since we might not be sure which side of the row we have our data on, we just check each left and right to see if it matches the string we are looking for and call the appropriate "Set" procedure, passing it the number. OK, so I have the display up and running. My next question: is it possible to modify a repeating resource using Rfind and modbattr (command from ChatSetAttr)? I'm running into the same problem as before, where I need to let ChatSetAttr know which repeating resource to use for a healing potion (let's say greater healing) but without using the row index method (repeating_resource_$0_left, etc.).  Funny you should mention that... I was just working on it when you posted ;) ScriptCards v 0.0.13a - Repeating Section Attribute Names It is now possible to use the syntax [*R>fieldname] to access the real attribute names for repeating row fields. Once you have retrieved a repeating section row with --Rfind, --Rfirst or --Rnext, you can reference the attribute value of a field with [*R:fieldname] and the attribute name with [*R>fieldname] (the > is supposed to look like a pointer. :) Here is a healing potion script that user chatsetattr. It assumes your repeatihng resources for potions are "Healing Potion", "Greater Healing Potion", "Superior Healing Potion" and "Supreme Healing Potion". This script also makes use of string variables to hold the references and the dice formula before it is rolled: !scriptcard {{ --#Use Healing Potion -->FindPotionType|?{What type of potion?|Healing Potion|Greater Healing Potion|Superior Healing Potion|Supreme Healing Potion} --?[$PotionCount] -le 0|NoPotion --=PotionsLeft|[$PotionCount] - 1 --=HealingAmount|[&DieRoll] --+|You gulp a [&PotionType] and are healed for [$HealingAmount] HP! --@setattr|_charid @{selected|character_id} _[&AttributeRef]|[$PotionsLeft] _silent --X| --:NoPotion| --+|You don't have any [&PotionType]s left. --X| --:FindPotionType| --Rfirst|@{selected|character_id};repeating_resource --:ResourceLoop| --?"[*R:resource_left_name]" -eq "?{What type of potion?}"|>SetPotionInfo;?{What type of potion?};[*R>resource_left];[*R:resource_left] --?"[*R:resource_right_name]" -eq "?{What type of potion?}"|>SetPotionInfo;?{What type of potion?};[*R>resource_right];[*R:resource_right] --Rnext| --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|ResourceLoop --<| --:SetPotionInfo|Params are Text Name;Attribute Reference;Attribute value --&PotionType|[%1%] --PotionType|[&PotionType] --&AttributeRef|[%2%] --=PotionCount|[%3%] --?"[&PotionType]" -eq "Healing Potion"|>SetDiceRoll;2d4 + 2 --?"[&PotionType]" -eq "Greater Healing Potion"|>SetDiceRoll;4d4 + 4 --?"[&PotionType]" -eq "Supreme Healing Potion"|>SetDiceRoll;8d4 + 8 --?"[&PotionType]" -eq "Supreme Healing Potion"|>SetDiceRoll;10d4 + 20 --<| --:SetDiceRoll|Param is die roll type --&DieRoll|[%1%] --<| }}
Kurt J. said: Jay R. said: Kurt J. said: Jay R. said: Trying to call a repeating resource value and I'm running into trouble. I can use Rfind to get the resource itself by name. The problem is when I want to reference the value of the repeating resource: !scriptcard  {{   --Rfind|@{selected|character_id};Potion of Superior Healing;repeating_resource;name   --+Potions of Superior Healing|[*R:WHAT_DO_I_PUT_HERE] }} I can't put the name, because it will just spit out the resource name in chat. I want to obtain the current value (not the max) from the resource field (which is 0, in this instance), but when I mouse over the 0 in the character sheet, all I get is {repeating_resource_right}. I'm sure I'm missing something basic here. How does one reference the value for a repeating resource without using the "repeating_resource_$0_resource_right" syntax? Repeating Resources on the 5E sheet are kinda oddball because each row is actually two resources (right and left). Here is a script that will run through all of the resource rows and build a list of available healing potions. For my test setup, I named Healing Potions "Healing Potion" and the others "Greater Healing", "Superior Healing", and "Supreme Healing". Except for the first one, I could then just use "-inc" to look for the keywords instead of the full names. The script uses --Rfirst and --Rnext to loop through all of the repeating_resource rows on the character sheet to summarize the available healing potions. Here is the output: and the script: !script {{ --#title|Healing Potion Report --#leftsub|@{selected|token_name} --=Healing|0 --=Greater|0 --=Superior|0 --=Supreme|0 -->CheckPotions| --+Healing|[$Healing.Total] --+Greater Healing|[$Greater.Total] --+Superior Healing|[$Superior.Total] --+Supreme Healing|[$Supreme.Total] --X| --:CheckPotions| --Rfirst|@{selected|character_id};repeating_resource --:ResourceLoop| --?"[*R:resource_left_name]" -eq "Healing Potion"|>SetHealing;[*R:resource_left] --?"[*R:resource_right_name]" -eq "Healing Potion"|>SetHealing;[*R:resource_right] --?"[*R:resource_left_name]" -inc "greater"|>SetGreater;[*R:resource_left] --?"[*R:resource_right_name]" -inc "greater"|>SetGreater;[*R:resource_right] --?"[*R:resource_left_name]" -inc "superior"|>SetSuperior;[*R:resource_left] --?"[*R:resource_right_name]" -inc "superior"|>SetSuperior;[*R:resource_right] --?"[*R:resource_left_name]" -inc "supreme"|>SetSupreme;[*R:resource_left] --?"[*R:resource_right_name]" -inc "supreme"|>SetSupreme;[*R:resource_right] --Rnext| --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|ResourceLoop --<| --:SetHealing| --=Healing|[%1%] --<| --:SetGreater| --=Greater|[%1%] --<| --:SetSuperior| --=Superior|[%1%] --<| --:SetSupreme| --=Supreme|[%1%] --<| }} Since we might not be sure which side of the row we have our data on, we just check each left and right to see if it matches the string we are looking for and call the appropriate "Set" procedure, passing it the number. OK, so I have the display up and running. My next question: is it possible to modify a repeating resource using Rfind and modbattr (command from ChatSetAttr)? I'm running into the same problem as before, where I need to let ChatSetAttr know which repeating resource to use for a healing potion (let's say greater healing) but without using the row index method (repeating_resource_$0_left, etc.).  Funny you should mention that... I was just working on it when you posted ;) ScriptCards v 0.0.13a - Repeating Section Attribute Names It is now possible to use the syntax [*R>fieldname] to access the real attribute names for repeating row fields. Once you have retrieved a repeating section row with --Rfind, --Rfirst or --Rnext, you can reference the attribute value of a field with [*R:fieldname] and the attribute name with [*R>fieldname] (the > is supposed to look like a pointer. :) Here is a healing potion script that user chatsetattr. It assumes your repeatihng resources for potions are "Healing Potion", "Greater Healing Potion", "Superior Healing Potion" and "Supreme Healing Potion". This script also makes use of string variables to hold the references and the dice formula before it is rolled: !scriptcard {{ --#Use Healing Potion -->FindPotionType|?{What type of potion?|Healing Potion|Greater Healing Potion|Superior Healing Potion|Supreme Healing Potion} --?[$PotionCount] -le 0|NoPotion --=PotionsLeft|[$PotionCount] - 1 --=HealingAmount|[&DieRoll] --+|You gulp a [&PotionType] and are healed for [$HealingAmount] HP! --@setattr|_charid @{selected|character_id} _[&AttributeRef]|[$PotionsLeft] _silent --X| --:NoPotion| --+|You don't have any [&PotionType]s left. --X| --:FindPotionType| --Rfirst|@{selected|character_id};repeating_resource --:ResourceLoop| --?"[*R:resource_left_name]" -eq "?{What type of potion?}"|>SetPotionInfo;?{What type of potion?};[*R>resource_left];[*R:resource_left] --?"[*R:resource_right_name]" -eq "?{What type of potion?}"|>SetPotionInfo;?{What type of potion?};[*R>resource_right];[*R:resource_right] --Rnext| --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|ResourceLoop --<| --:SetPotionInfo|Params are Text Name;Attribute Reference;Attribute value --&PotionType|[%1%] --PotionType|[&PotionType] --&AttributeRef|[%2%] --=PotionCount|[%3%] --?"[&PotionType]" -eq "Healing Potion"|>SetDiceRoll;2d4 + 2 --?"[&PotionType]" -eq "Greater Healing Potion"|>SetDiceRoll;4d4 + 4 --?"[&PotionType]" -eq "Supreme Healing Potion"|>SetDiceRoll;8d4 + 8 --?"[&PotionType]" -eq "Supreme Healing Potion"|>SetDiceRoll;10d4 + 20 --<| --:SetDiceRoll|Param is die roll type --&DieRoll|[%1%] --<| }} Ha, this is awesome, Kurt! :) I just finished converting what I had to use attributes instead of repeating resources, but I may come back and steal/modify your scriptcard, since this obviously more elegant and concise than the mess I have right now!
For what it's worth, here's a modified version of a scriptcard Kurt posted upthread. It conditionally shows buttons for drinking a potion/pouring a potion down an ally's throat and potion transfer depending on whether the character has at least one of a given potion type. Please forgive the bloat and clunkiness of my additions -- I am not a programmer, and I don't play one on TV either. !script {{ --#title|離 Healing Potion Report 離 --#leftsub|@{selected|token_name} --=Healing|[*@{selected|character_id}:potion_healing] --=Greater|[*@{selected|character_id}:potion_greater_healing] --=Superior|[*@{selected|character_id}:potion_superior_healing] --=Supreme|[*@{selected|character_id}:potion_supreme_healing] --:Healing| --=HealingColor|00C301 --?[$Healing.Total] -ge 1|DisplayButton --=HealingColor|FF0000 --+Healing| 2d4+2 [b][#[$HealingColor.RollText]][$Healing.Total][/#][/b] --^HideButton| --:DisplayButton| --+Healing| 2d4+2 [b][#[$HealingColor.RollText]][$Healing.Total][/#][/b] [button]Drink/Pour::~Healing Macros|PotionHealing[/button] [button]Transfer::~Healing Macros|TransferPotionHealing[/button] --:HideButton| --:GreaterHealing| --=GreaterHealingColor|00C301 --?[$Greater.Total] -ge 1|DisplayGreaterButton --=GreaterHealingColor|FF0000 --+Greater|4d4+4 [b][#[$GreaterHealingColor.RollText]][$Greater.Total][/#][/b] --^HideGreaterButton| --:DisplayGreaterButton| --+Greater|4d4+4 [b][#[$GreaterHealingColor.RollText]][$Greater.Total][/#][/b] [button]Drink/Pour::~Healing Macros|PotionGreaterHealing[/button] [button]Transfer::~Healing Macros|TransferPotionGreaterHealing[/button] --:HideGreaterButton| --:SuperiorHealing| --=SuperiorHealingColor|00C301 --?[$Superior.Total] -ge 1|DisplaySuperiorButton --=SuperiorHealingColor|FF0000 --+Superior| 8d4+8 [b][#[$SuperiorHealingColor.RollText]][$Superior.Total][/#][/b] --^HideSuperiorButton| --:DisplaySuperiorButton| --+Superior| 8d4+8 [b][#[$SuperiorHealingColor.RollText]][$Superior.Total][/#][/b] [button]Drink/Pour::~Healing Macros|PotionSuperiorHealing[/button] [button]Transfer::~Healing Macros|TransferPotionSuperiorHealing[/button] 8d4+8 --:HideSuperiorButton| --:SupremeHealing| --=SupremeHealingColor|00C301 --?[$Supreme.Total] -ge 1|DisplaySupremeButton --=SupremeHealingColor|FF0000 --+Supreme| 10d4+20 [b][#[$SupremeHealingColor.RollText]][$Supreme.Total][/#][/b] --^HideSupremeButton| --:DisplaySupremeButton| --+Supreme| 10d4+20 [b][#[$SupremeHealingColor.RollText]][$Supreme.Total][/#][/b] [button]Drink/Pour::~Healing Macros|PotionSupremeHealing[/button] [button]Transfer::~Healing Macros|TransferPotionSupremeHealing[/button] --:HideSupremeButton| --X| }} The output looks like this:
1612930054
David M.
Pro
API Scripter
Would anyone else be interested in an option to format all die rolls the same (e.g. basic yellow)? Sometimes the Red/Green/Blue for min/max/mixed rolls can be a little distracting (See this example of re-skinning the MM macro for treasure generation).  I found that you can force the die rolls to always be yellow by re-assigning the roll value as 0+CurrentValue, like this:       --=ThisPiece|3d6 * 100       --=ThisPiece|0+[$ThisPiece] but for cases where there are many die rolls it might be nice if there was just a one-time roll formatting option to ensure all rolls look the same. Not a high priority since there is a workaround, just a thought.
Question: Is there a way to declare multiple targets in the same card? For example: The Magic Missile spell allows you to hit multiple creatures. Is it possible to somehow select different tokens to take damage from an individual missile, while only deducting one spell slot from the player? 
Jay R. said: For what it's worth, here's a modified version of a scriptcard Kurt posted upthread. It conditionally shows buttons for drinking a potion/pouring a potion down an ally's throat and potion transfer depending on whether the character has at least one of a given potion type. Please forgive the bloat and clunkiness of my additions -- I am not a programmer, and I don't play one on TV either. !script {{ --#title|離 Healing Potion Report 離 --#leftsub|@{selected|token_name} --=Healing|[*@{selected|character_id}:potion_healing] --=Greater|[*@{selected|character_id}:potion_greater_healing] --=Superior|[*@{selected|character_id}:potion_superior_healing] --=Supreme|[*@{selected|character_id}:potion_supreme_healing] --:Healing| --=HealingColor|00C301 --?[$Healing.Total] -ge 1|DisplayButton --=HealingColor|FF0000 --+Healing| 2d4+2 [b][#[$HealingColor.RollText]][$Healing.Total][/#][/b] --^HideButton| --:DisplayButton| --+Healing| 2d4+2 [b][#[$HealingColor.RollText]][$Healing.Total][/#][/b] [button]Drink/Pour::~Healing Macros|PotionHealing[/button] [button]Transfer::~Healing Macros|TransferPotionHealing[/button] --:HideButton| --:GreaterHealing| --=GreaterHealingColor|00C301 --?[$Greater.Total] -ge 1|DisplayGreaterButton --=GreaterHealingColor|FF0000 --+Greater|4d4+4 [b][#[$GreaterHealingColor.RollText]][$Greater.Total][/#][/b] --^HideGreaterButton| --:DisplayGreaterButton| --+Greater|4d4+4 [b][#[$GreaterHealingColor.RollText]][$Greater.Total][/#][/b] [button]Drink/Pour::~Healing Macros|PotionGreaterHealing[/button] [button]Transfer::~Healing Macros|TransferPotionGreaterHealing[/button] --:HideGreaterButton| --:SuperiorHealing| --=SuperiorHealingColor|00C301 --?[$Superior.Total] -ge 1|DisplaySuperiorButton --=SuperiorHealingColor|FF0000 --+Superior| 8d4+8 [b][#[$SuperiorHealingColor.RollText]][$Superior.Total][/#][/b] --^HideSuperiorButton| --:DisplaySuperiorButton| --+Superior| 8d4+8 [b][#[$SuperiorHealingColor.RollText]][$Superior.Total][/#][/b] [button]Drink/Pour::~Healing Macros|PotionSuperiorHealing[/button] [button]Transfer::~Healing Macros|TransferPotionSuperiorHealing[/button] 8d4+8 --:HideSuperiorButton| --:SupremeHealing| --=SupremeHealingColor|00C301 --?[$Supreme.Total] -ge 1|DisplaySupremeButton --=SupremeHealingColor|FF0000 --+Supreme| 10d4+20 [b][#[$SupremeHealingColor.RollText]][$Supreme.Total][/#][/b] --^HideSupremeButton| --:DisplaySupremeButton| --+Supreme| 10d4+20 [b][#[$SupremeHealingColor.RollText]][$Supreme.Total][/#][/b] [button]Drink/Pour::~Healing Macros|PotionSupremeHealing[/button] [button]Transfer::~Healing Macros|TransferPotionSupremeHealing[/button] --:HideSupremeButton| --X| }} The output looks like this: one of five characters gives me this error :-/ not sure why  10:51AM rror - No Line Tag Specified: Error - No Line Content Specified Error - No Line Content Specified Error - No Line Content Specified Error - No Line Content Specified
Klobass said: one of five characters gives me this error :-/ not sure why  10:51AM rror - No Line Tag Specified: Error - No Line Content Specified Error - No Line Content Specified Error - No Line Content Specified Error - No Line Content Specified That's odd. I tested it and received no error. I should, specify, though, that you need to create attributes for each of the four potion types (potion_healing, potion_greater_healing, and so on) on whatever character sheet represents the player. And the drink/pour and transfer buttons point to scriptcards stored on the same character sheet as this scriptcard. Here they are for the basic healing potion (haven't done them for all four types yet, but the syntax is very similar). The weird character in the #leftsub line is actually a potion emoji that didn't past into the message properly. :) Drink/pour (potion of healing): !scriptcard   {{   --#title|Potion of Healing   --#leftsub| 離   --#sourceToken|@{selected|token_id}   --#targetToken|@{target|token_id}   --#emoteText|*@{selected|token_name} uses a potion of healing.*   --=HealingAmount|2d4+2   --&PotionName|healing   --=PotionCount|[*@{selected|token_name}:potion_healing]   --?[$PotionCount] le 0|NoPotion   --:UsePotion|   --@modbattr|_name @{selected|character_name} _potion_healing|-1 _silent   --=HealingNumber|@{selected|potion_healing}-1   --=HealingColor|00C301   --+@{target|token_name}| heals [b][#[$HealingColor.RollText]][$HealingAmount][/#][/b] hit points.   --@token-mod|_ids @{target|token_id} _set bar1_value|+[$HealingAmount]!   --?[$HealingNumber] -ge 1|HealingSkip   --=HealingColor|FF0000   --:HealingSkip|   --+@{selected|token_name}|has [b][#[$HealingColor.RollText]][$HealingNumber.Total][/#][/b] potion(s) of [&PotionName] remaining.   --^Final|   --:NoPotion   --+|[i]@{selected|token_name} does not have any potions of [&PotionName] to use![/i]   --:Final| }} Transfer potion of healing: !scriptcard {{ --#title|Transfer Potion of Healing --#leftsub|離 --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#emoteText|*@{selected|token_name} volunteers to give healing potions to @{target|token_name}.* --&PotionName|healing --=SourceCount|[*@{selected|token_name}:potion_healing] --=TransferNumber|?{Transfer|0} --?[$TransferNumber] -gt @{selected|potion_healing} -or @{selected|potion_healing} -le 0|NoPotion --:UsePotion| --@modbattr|_name @{selected|character_name} _potion_healing|-[$TransferNumber] _silent --=SourceCountNew|@{selected|potion_healing}-[$TransferNumber] --@modbattr|_name @{target|character_name} _potion_healing|+[$TransferNumber] _silent --=TargetCountNew|@{target|potion_healing}+[$TransferNumber] --=HealingColor|00C301 --+[b]@{target|token_name}[/b]|receives [b][#[$HealingColor.RollText]][$TransferNumber.Total][/#][/b] potion(s) of [&PotionName] from [b]@{selected|token_name}[/b]. --+[b]@{target|token_name}[/b]|now has [b][#[$HealingColor.RollText]][$TargetCountNew.Total][/#][/b] potion(s) of [&PotionName] in their inventory. --?[$SourceCountNew] -ge 1|HealingSkip --=HealingColor|FF0000 --:HealingSkip| --+[b]@{selected|token_name}[/b]|has [b][#[$HealingColor.RollText]][$SourceCountNew.Total][/#][/b] potion(s) of [&PotionName] remaining. --^Final| --:NoPotion --+|[i]@{selected|token_id} does not have that many potions of [&PotionName] to transfer![/i] --:Final| }}
1612959075
Duncan R.
Pro
Sheet Author
Is there any way to add comments into scriptcard for both debugging purposes, and for use by future me to remember what things are doing? I didn't spot a way to add a comment.
1612959975
Kurt J.
Pro
API Scripter
David M. said: Would anyone else be interested in an option to format all die rolls the same (e.g. basic yellow)? Sometimes the Red/Green/Blue for min/max/mixed rolls can be a little distracting (See this example of re-skinning the MM macro for treasure generation).  I found that you can force the die rolls to always be yellow by re-assigning the roll value as 0+CurrentValue, like this:       --=ThisPiece|3d6 * 100       --=ThisPiece|0+[$ThisPiece] but for cases where there are many die rolls it might be nice if there was just a one-time roll formatting option to ensure all rolls look the same. Not a high priority since there is a workaround, just a thought. The no-highlighting should be an easy enough option to add. I'll put it on the list for 0.0.14. Phillip K. said: Question: Is there a way to declare multiple targets in the same card? For example: The Magic Missile spell allows you to hit multiple creatures. Is it possible to somehow select different tokens to take damage from an individual missile, while only deducting one spell slot from the player?  You could write a macro to do that. You would need to store the token IDs of multiple targets (you can ask the player for multiple targets by including a target name like this : @{target|1st|token_id}. The user would need to pick 9 targets (even if they are casting a level 1 missile) and a target would need to be selected once for each missile they were going to get. It would be a little complicated, but certainly doable. Duncan R. said: Is there any way to add comments into scriptcard for both debugging purposes, and for use by future me to remember what things are doing? I didn't spot a way to add a comment. I usually put comments on label lines. You can create any number of labels, and if you don't jump to them, they don't actually do anything. I'll generally put a quick summary in the label name and comments after the |, I do the same for labels for subroutines that take parameters... I'll list what the parameters are used for in the subroutine label's content area since it is unused.
1612960733

Edited 1612960844
David M.
Pro
API Scripter
EDIT - Ninja'd Comments can be added with Branch Labels, e.g. --:This can be a Comment| You can put more details here  I use "caveman" debugging, adding Direct Output lines when needed, then just remove the debug statements when done. !scriptcards {{ --+debugSomeFunc|About to call SomeFunc -->SomeFunc|?{Enter Arg|0} --+Var=|[$Var] --X| --:SomeFunc| --+debugArg|[%1%] --=Var|[%1] --<| }}
1612961069
Kurt J.
Pro
API Scripter
David M. said: EDIT - Ninja'd Comments can be added with Branch Labels, e.g. --:This can be a Comment| You can put more details here  I use "caveman" debugging, adding Direct Output lines when needed, then just remove the debug statements when done. !scriptcards {{ --+debugSomeFunc|About to call SomeFunc -->SomeFunc|?{Enter Arg|0} --+Var=|[$Var] --X| --:SomeFunc| --+debugArg|[%1%] --=Var|[%1] --<| }} There is also an "undocumented" setting: --#debug|1 that will output additional information to the API console that can be helpful in figuring out what might be going wrong. I'm open to adding additional debug outputs when this is turned on as well.
1612961592
David M.
Pro
API Scripter
Oh that's handy, thx!
1612963214
Duncan R.
Pro
Sheet Author
Thanks both. I wasn't looking for the debug option (yet) but that is very useful to know. What I meant by using comments for debugging was I usually might want to just temporary comment a line out while testing something. I am use to doing '#' or '//' etc. I shall create a macro in the text editor to put in a --:Comment| Assuming sticking the label in front of an existing valid scriptcard command doesn't cause an issue with the interpreter I shall do that.
1612964490
David M.
Pro
API Scripter
Ahh, gotcha. Unfortunately, it looks like adding --:Comment| in front of another valid command does not seem to work as you are intending, though.  Being able to "comment out" lines using // or similar would be pretty useful. Next up: Intellisense autocompletion! haha you got this, Kurt! ;)
1612966408
Duncan R.
Pro
Sheet Author
David M. said: Next up: Intellisense autocompletion! haha you got this, Kurt! ;) 'Scriptcards' returns nothing in extensions in Visual Studio Code :-)
1612969825

Edited 1612969902
Hi all I just have a coupe of questions 1. Is it possible to search through description text for key words - example:  string Sdescription: @(selected|spellselected_description)  if Sdescription == Stun{  call mod token to change stats icon / other things like visual effects type and color } 2. Is there a way to ask the player how many targets they want to hit before roll20 asks for a selection of a target example: TSeclection:"How many targets? 1|2|3|4|.." if TSeclection == 2{     target|@{Target|T1|token_id} , @{Target|T2|token_id}  } if TSeclection == 3{     target|@{Target|T1|token_id}, @{Target|T2|token_id}, @{Target|T3|token_id} } And after this point the player selects the associated targets? Thanks for any help
1612971661

Edited 1612972540
David M.
Pro
API Scripter
Robert, for your first question: yes, that is possible by using -inc in a conditional. For the second, I don't believe there is support for that (I tried putting the @{target...} into a function, but it fires immediately before querying for target count). Seems like an order of operations limitation by the ROll20 macro parser. Pretty sure even in std macros, you can't have an arbitrary number of targets and you end up having to create a hella query for each possible case. Could be wrong, though.  You *can* explicitly assign targets. This example does both (note using the 5e OGL sheet) !scriptcards {{ --&Race|@{selected|race} --?[&Race] -inc Firbolg|>DisplayFirbolg|>DisplayElse --&Name_1|@{target|1st|token_name} --&Name_2|@{target|2nd|token_name} --+Target 1|[&Name_1] --+Target 2|[&Name_2] --X| --:DisplayFirbolg| --+Race|I'm a Firbolg! --<| --:DisplayElse| --+Race|Sadly, I'm not a Firbolg :( --<| }}
1612974239

Edited 1612974408
Awesome thanks for the fast reply now I can make a script for 98% of all the spells sadly I guess I still have to have individual api scripts for magic missle and scorching ray  tall order but i don't suppose there is support using a for each loop
1612974917

Edited 1612975886
Duncan R.
Pro
Sheet Author
I got my original idea for scriptcards working fine. I can now click the macro and the relevant weapon will be picked from the list to hit, damage, stun points etc. But because of all the extra features Kurt has added I thought rather than a button for each weapon type, I can just have one button that calls a macro for the relevant weapon, that works. Then I though the macro for each weapon is effectively identical, if I could just pass a parameter to a macro (which I know you can't do) then I could boil the whole lot down to 2 scripts. Also if scriptcard could process the (not possible) macro parameter I could have a self-reference macro and only need one macro that would dynamically handle any weapon in the repeating list. Nice and neat. As I can't do macro parameters is there another way to do this? Edit: Perhaps I could use the Save and Load (--s and --l) Feature. And test if it is set when the scriptcard runs.
Kurt J. said: ScriptCards v 0.0.13a - Repeating Section Attribute Names It is now possible to use the syntax [*R>fieldname] to access the real attribute names for repeating row fields. Once you have retrieved a repeating section row with --Rfind, --Rfirst or --Rnext, you can reference the attribute value of a field with [*R:fieldname] and the attribute name with [*R>fieldname] (the > is supposed to look like a pointer. :) Here is a healing potion script that user chatsetattr. It assumes your repeatihng resources for potions are "Healing Potion", "Greater Healing Potion", "Superior Healing Potion" and "Supreme Healing Potion". This script also makes use of string variables to hold the references and the dice formula before it is rolled: !scriptcard {{ --#Use Healing Potion -->FindPotionType|?{What type of potion?|Healing Potion|Greater Healing Potion|Superior Healing Potion|Supreme Healing Potion} --?[$PotionCount] -le 0|NoPotion --=PotionsLeft|[$PotionCount] - 1 --=HealingAmount|[&DieRoll] --+|You gulp a [&PotionType] and are healed for [$HealingAmount] HP! --@setattr|_charid @{selected|character_id} _[&AttributeRef]|[$PotionsLeft] _silent --X| --:NoPotion| --+|You don't have any [&PotionType]s left. --X| --:FindPotionType| --Rfirst|@{selected|character_id};repeating_resource --:ResourceLoop| --?"[*R:resource_left_name]" -eq "?{What type of potion?}"|>SetPotionInfo;?{What type of potion?};[*R>resource_left];[*R:resource_left] --?"[*R:resource_right_name]" -eq "?{What type of potion?}"|>SetPotionInfo;?{What type of potion?};[*R>resource_right];[*R:resource_right] --Rnext| --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|ResourceLoop --<| --:SetPotionInfo|Params are Text Name;Attribute Reference;Attribute value --&PotionType|[%1%] --PotionType|[&PotionType] --&AttributeRef|[%2%] --=PotionCount|[%3%] --?"[&PotionType]" -eq "Healing Potion"|>SetDiceRoll;2d4 + 2 --?"[&PotionType]" -eq "Greater Healing Potion"|>SetDiceRoll;4d4 + 4 --?"[&PotionType]" -eq "Supreme Healing Potion"|>SetDiceRoll;8d4 + 8 --?"[&PotionType]" -eq "Supreme Healing Potion"|>SetDiceRoll;10d4 + 20 --<| --:SetDiceRoll|Param is die roll type --&DieRoll|[%1%] --<| }} Hey Kurt. The scriptcard you posted doesn't work for me. It returns an error about PotionType and does not decrement the appropriate field using ChatSetAttr. I am also having trouble using the > and : operators with the R command. Using > gives me the attribute name (the full ID), and using : gives me the value for that field (in my test case, Potion of Greater Healing). But I can't figure out a way to access the number of potions in the field. 
1612976020
David M.
Pro
API Scripter
Robert L. said: tall order but i don't suppose there is support using a for each loop To clarify, loops are supported, it's just the @{target...} that gets parsed by Roll20 before the scriptcard even starts executing.
1612976563
Kurt J.
Pro
API Scripter
Robert L. said: Awesome thanks for the fast reply now I can make a script for 98% of all the spells sadly I guess I still have to have individual api scripts for magic missle and scorching ray  tall order but i don't suppose there is support using a for each loop You could create a could of macros like "MagicMissile1Target", "MagicMissile2Targets", etc... to limit the selection. You would need to add additional roll queries for "Target 1 Number of Missiles", "Target 2 Number of Missiles", etc. You could then use that information to assign damage. David M. said: Ahh, gotcha. Unfortunately, it looks like adding --:Comment| in front of another valid command does not seem to work as you are intending, though.  Being able to "comment out" lines using // or similar would be pretty useful. Next up: Intellisense autocompletion! haha you got this, Kurt! ;) Ha! :) I use Visual Studio Code myself to write scriptcards... I hadn't thought about writing a language extension for helping with actual scripts. I have no idea how to do that, but it might be fun to learn :) Duncan R. said: I got my original idea for scriptcards working fine. I can now click the macro and the relevant weapon will be picked from the list to hit, damage, stun points etc. But because of all the extra features Kurt has added I thought rather than a button for each weapon type, I can just have one button that calls a macro for the relevant weapon, that works. Then I though the macro for each weapon is effectively identical, if I could just pass a parameter to a macro (which I know you can't do) then I could boil the whole lot down to 2 scripts. Also if scriptcard could process the (not possible) macro parameter I could have a self-reference macro and only need one macro that would dynamically handle any weapon in the repeating list. Nice and neat. As I can't do macro parameters is there another way to do this? Could you show us what you have now? I know macros can't take parameters but there might be some trickery that could be pulled :) Jay R. said: Hey Kurt. The scriptcard you posted doesn't work for me. It returns an error about PotionType and does not decrement the appropriate field using ChatSetAttr. I am also having trouble using the > and : operators with the R command. Using > gives me the attribute name (the full ID), and using : gives me the value for that field (in my test case, Potion of Greater Healing). But I can't figure out a way to access the number of potions in the field.  I assume you updated the lower portion to match the names of your repeating resources. As written above the matches are case sensitive (changing -eq to -eqi would make them non-case sensitive). Repeating Resources are the oddest repeating sections to deal with on the 5E character sheet because of the whole left/right thing. Remeber that repeating resources are set up is that "repeating_resource_-blahblahblah_resource_left_name" will be the attribute that says "Potion of Greater Healing", etc. The numeric value is stored in "repeating_resource_-blahblahblah_resource_left" so that is what you want to look at for the number. These are referenced as [*R:resource_left_name] and [*R:resource_left] for the VALUES, and [*R>resource_left_name] and [*R>resource_left] for the attribute names.
1612977236
Duncan R.
Pro
Sheet Author
Kurt J. said: As I can't do macro parameters is there another way to do this? Could you show us what you have now? I know macros can't take parameters but there might be some trickery that could be pulled :) I don't particularly have anything, as I started and then realised I didn't have any way forward. I just used the code in this thread to create a button and then wondered how I was going to get the button to do something useful with the  [*R:attack-name] pulled from the repeating list. So all I wrote was --Rfirst|@{selected|character_id};repeating_attack-list --:DisplayLoop| --?"[*R:attack-name]" -eq NoRepeatingAttributeLoaded|Done --+Attack| [b]Some Text[/b] [button][*R:attack-name]::!
#Attack[/button] --Rnext| -->DisplayLoop| --:Done| And then scratch my head where to go next
Kurt J. said: I assume you updated the lower portion to match the names of your repeating resources. As written above the matches are case sensitive (changing -eq to -eqi would make them non-case sensitive). Repeating Resources are the oddest repeating sections to deal with on the 5E character sheet because of the whole left/right thing. Remeber that repeating resources are set up is that "repeating_resource_-blahblahblah_resource_left_name" will be the attribute that says "Potion of Greater Healing", etc. The numeric value is stored in "repeating_resource_-blahblahblah_resource_left" so that is what you want to look at for the number. These are referenced as [*R:resource_left_name] and [*R:resource_left] for the VALUES, and [*R>resource_left_name] and [*R>resource_left] for the attribute names. Yeah, I've tried a whole bunch of things, including the combinations you suggested, and experiencing only marginal success. Now I'm just trying to figure out where I'm going wrong. !scriptcard  {{   --Rfind|@{selected|character_id};Potion of Greater Healing;repeating_resource;name   --+Attribute1|[*R>resource_left_name]   --+Attribute2|[*R>resource_left]   --+Attribute3|[*R:name]   --+Attribute4|[*R:fieldname] }} In the above, i'm just trying to get the number of potions in the Potion of Greater Healing repeating resource field to show up in one of the direct output lines (so I can get clear in my mind what's what). Attributes 1, 2 and 4 spit out the big row ID with the letters and numbers. Attribute3 returns the name Potion of Greater Healing (which is good!). But I cannot for the life of me figure out how to access the number of potions (5, in in this particular field).
1612980005
Kurt J.
Pro
API Scripter
Jay R. said: Kurt J. said: I assume you updated the lower portion to match the names of your repeating resources. As written above the matches are case sensitive (changing -eq to -eqi would make them non-case sensitive). Repeating Resources are the oddest repeating sections to deal with on the 5E character sheet because of the whole left/right thing. Remeber that repeating resources are set up is that "repeating_resource_-blahblahblah_resource_left_name" will be the attribute that says "Potion of Greater Healing", etc. The numeric value is stored in "repeating_resource_-blahblahblah_resource_left" so that is what you want to look at for the number. These are referenced as [*R:resource_left_name] and [*R:resource_left] for the VALUES, and [*R>resource_left_name] and [*R>resource_left] for the attribute names. Yeah, I've tried a whole bunch of things, including the combinations you suggested, and experiencing only marginal success. Now I'm just trying to figure out where I'm going wrong. !scriptcard  {{   --Rfind|@{selected|character_id};Potion of Greater Healing;repeating_resource;name   --+Attribute1|[*R>resource_left_name]   --+Attribute2|[*R>resource_left]   --+Attribute3|[*R:name]   --+Attribute4|[*R:fieldname] }} In the above, i'm just trying to get the number of potions in the Potion of Greater Healing repeating resource field to show up in one of the direct output lines (so I can get clear in my mind what's what). Attributes 1, 2 and 4 spit out the big row ID with the letters and numbers. Attribute3 returns the name Potion of Greater Healing (which is good!). But I cannot for the life of me figure out how to access the number of potions (5, in in this particular field). Ah, I see. The problem is you can't deal with repeating_resources this way because of the whole left/right thin... There is no "name" field in a repeating resource row. there is "resource_left_name" and "resource_right_name", and the find command is doing its best to locate something that matches. What you get back, though ONLY has a field called "name" that it fills in with the closest match. When dealing with repeating resources because of this, you really need to use the Rfirst and Rnext commands. Right now, trying to Rfind something that doesn't return a row crashes the sandbox (my bad... I'll fix that). but you would need to search the resource_left_name and resource_right_name fields, not just "name".
Kurt J. said: Ah, I see. The problem is you can't deal with repeating_resources this way because of the whole left/right thin... There is no "name" field in a repeating resource row. there is "resource_left_name" and "resource_right_name", and the find command is doing its best to locate something that matches. What you get back, though ONLY has a field called "name" that it fills in with the closest match. When dealing with repeating resources because of this, you really need to use the Rfirst and Rnext commands. Right now, trying to Rfind something that doesn't return a row crashes the sandbox (my bad... I'll fix that). but you would need to search the resource_left_name and resource_right_name fields, not just "name". Thanks! OK, so that makes sense to me, and I was able to get those eight fields (left and right) to output in chat. However, when I try to run the following scriptcard, the target token heals, but ChatSetAttr doesn't fire, and it tells me, incorrectly, that the source token has -1 potions remaining. !scriptcard {{ --#title|Potion of Greater Healing --#leftsub|離離 --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#emoteText|*@{selected|token_name} uses a potion of greater healing.* --=HealingAmount|4d4+4 --&PotionName|greater healing --:FindPotionType| --Rfirst|@{selected|character_id};repeating_resource --:ResourceLoop| --?"[*R:resource_left_name]" -eq "Potion of Greater Healing"|>SetPotionInfo;[*R>resource_left];[*R:resource_left] --?"[*R:resource_right_name]" -eq "Potion of Greater Healing"|>SetPotionInfo;[*R>resource_right];[*R:resource_right] --Rnext| --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|ResourceLoop --<| --:SetPotionInfo|Params are Attribute Reference;Attribute value --&AttributeRef|[%1%] --=PotionCount|[%2%] --<| --?[$PotionCount] le 0|NoPotion --:UsePotion| --=PotionsLeft|[$PotionCount]-1 --@modbattr|_name @{selected|character_name} _[&AttributeRef]|[$PotionCount] _silent --=HealingColor|00C301 --+@{target|token_name}| heals [b][#[$HealingColor.RollText]][$HealingAmount][/#][/b] hit points. --@token-mod|_ids @{target|token_id} _set bar1_value|+[$HealingAmount]! --?[$PotionsLeft] -ge 1|HealingSkip --=HealingColor|FF0000 --:HealingSkip| --+@{selected|token_name}|has [b][#[$HealingColor.RollText]][$PotionsLeft.Total][/#][/b] potion(s) of [&PotionName] remaining. --^Final| --:NoPotion --+|[i]@{selected|token_name} does not have any potions of [&PotionName] to use![/i] --:Final| }} EDIT: After a lot of testing, I had success by using branch labels (--^) instead of returns (-->) and using a hard calculation for the modbattr command (-1 instead of the [$PotionCount] variable)! Phew.
@Kurt just wanted to thank you for the macro idea and show my appreciation for the wonderful script you have written,  the videos you post (those really, really help), and the time and patience you take to answer so many questions including the time you take to ad features people here have requests @Everyone else thank you so much for being a knowledgeable and helpful community  :)
Robert L. said: @Kurt just wanted to thank you for the macro idea and show my appreciation for the wonderful script you have written,  the videos you post (those really, really help), and the time and patience you take to answer so many questions including the time you take to ad features people here have requests @Everyone else thank you so much for being a knowledgeable and helpful community  :) Seconding the props to Kurt, who has built an amazing script that I can't wait to implement in my games, and who is patient with user queries and extremely responsive to feedback about features. I learned this from his excellent EncounterHelper script, which I highly recommend!
1613008930
Kurt J.
Pro
API Scripter
Robert L. said: @Kurt just wanted to thank you for the macro idea and show my appreciation for the wonderful script you have written,  the videos you post (those really, really help), and the time and patience you take to answer so many questions including the time you take to ad features people here have requests @Everyone else thank you so much for being a knowledgeable and helpful community  :) Jay R. said: Robert L. said: @Kurt just wanted to thank you for the macro idea and show my appreciation for the wonderful script you have written,  the videos you post (those really, really help), and the time and patience you take to answer so many questions including the time you take to ad features people here have requests @Everyone else thank you so much for being a knowledgeable and helpful community  :) Seconding the props to Kurt, who has built an amazing script that I can't wait to implement in my games, and who is patient with user queries and extremely responsive to feedback about features. I learned this from his excellent EncounterHelper script, which I highly recommend! Thanks guys :) I appreciate your kind words. Look for a new version probably early tomorrow morning with some bug fixes and a new function :)
Is there a way to get an updated attribute from a character sheet? I'd like my healing potion scriptcards to display the HP healed and also the new HP total for whoever's being healed. But currently, when I call the hp attribute after running tokenmod to heal the character, it gives me the character's HP before the potion was applied. Would looking it up with the * operator help? I suppose I could create a separate variable that contained the heal amount + the character's HP and then reference that variable in direct output, but that seems somewhat clunky.
1613047182
Kurt J.
Pro
API Scripter
Jay R. said: Is there a way to get an updated attribute from a character sheet? I'd like my healing potion scriptcards to display the HP healed and also the new HP total for whoever's being healed. But currently, when I call the hp attribute after running tokenmod to heal the character, it gives me the character's HP before the potion was applied. Would looking it up with the * operator help? I suppose I could create a separate variable that contained the heal amount + the character's HP and then reference that variable in direct output, but that seems somewhat clunky. API calls are asynchronous, so the token-mod call is happening after the script has been processed. You could potentially add the two together, but it might result in reporting more HP than they actually have (if they are at 8/10 and get healed for 4 HP it would say they had 12 hp even though the token mod would cap it at 12). Sounds like I need to add a "max" function :)
1613047324
Kurt J.
Pro
API Scripter
ScriptCards v 0.0.14 now available ( GIST ) Bug Fix : Searching for a repeating section that doesn't exist would crash the sandbox. It now just fails silently. Behavior Change : Referencing a string variable that did not exist would previously leave the reference (i.e. [&NotAVariable]) in the output. It will now be removed New Setting : NoMinMaxHilight . If set to a non-default value (which is "0"), dice rolls output on --+ lines will always have a yellow background and not change based on rolling 1's, aces, etc. New Function : getselected. Creates a series of string variables using the passed name as a base for each token selected when the script is run. For example: --~seltokens|getselected Will create [&seltokensCount], [&seltokens1], [&seltokens2], etc. The Count will contain how many tokens were selected, while each of the individual numbered variables will contain the token id of the selected tokens.
1613048995

Edited 1613049047
David M.
Pro
API Scripter
@Kurt: Excited about the update! @Jay: I would probably create a HealLimit variable and take the lower of that and your HealingAmount prior to the token-mod call. --=HealLimit|@{selected|hp|max}-@{selected|hp} That is, unless Kurt adds a max/min bounding option to rolls :)
Ooh, excited about the update, Kurt! @David, thank you!! I'll definitely try that out (but also wait for that max/min bounding ;)).
1613050893
Kurt J.
Pro
API Scripter
David M. said: @Kurt: Excited about the update! @Jay: I would probably create a HealLimit variable and take the lower of that and your HealingAmount prior to the token-mod call. --=HealLimit|@{selected|hp|max}-@{selected|hp} That is, unless Kurt adds a max/min bounding option to rolls :) Funny you should mention that... :)
1613053567
Duncan R.
Pro
Sheet Author
Hi @Kurt. Just wondering if you had any more thoughts on: 1. A dedicated comment function or a change to --| so that if you put it in front of another valid command it won't execute it? Only useful for debugging but easier than cutting and pasting code in/out of a scriptcard script while developing. 2. And did you think of any other way I could fudge passing variables between scriptcard macros? I haven't tried using the load/save parameter yet, but that was going to be my next attempt. Just wondered if these were possible or not.
1613055642
David M.
Pro
API Scripter
That second one would be tricky. I'm assuming your thought is to have a master scriptcard execute and output a button linked to another scriptcard macro that would use a roll created by the master card? The only thing I can think of is some kind of read/write commands to an variable/object scoped to the scriptcard namespace (or to State, I suppose, though it seems like it wouldn't be necessary to persist between sessions). Master scriptcard writes, then subordinate scriptcard reads it. The subordinate scriptcard would need to do some checking to ensure the value existed (responsibility of the macro writer). The hypothetical read command should probably also delete (or have option to delete) the stored variable/object once it it is read to avoid potential downstream shenanigans. If optional, could allow for hitting that original button several times if needed. Some interesting (potentially useful) things could happen if the subordinate scriptcard also wrote values. Chaining sequences and whatnot. This starts to get into some pretty Meta territory, though. Might be just more of a thought experiment, depending on Kurt's roadmap/priorities and if he really wants to start opening that can of worms. Also, he's going to run out of ASCII special character prefixes eventually, haha! 
1613060933
Duncan R.
Pro
Sheet Author
David M. said: That second one would be tricky. I'm assuming your thought is to have a master scriptcard execute and output a button linked to another scriptcard macro that would use a roll created by the master card? The only thing I can think of is some kind of read/write commands to an variable/object scoped to the scriptcard namespace (or to State, I suppose, though it seems like it wouldn't be necessary to persist between sessions). Master scriptcard writes, then subordinate scriptcard reads it. The subordinate scriptcard would need to do some checking to ensure the value existed (responsibility of the macro writer). The hypothetical read command should probably also delete (or have option to delete) the stored variable/object once it it is read to avoid potential downstream shenanigans. If optional, could allow for hitting that original button several times if needed. Some interesting (potentially useful) things could happen if the subordinate scriptcard also wrote values. Chaining sequences and whatnot. This starts to get into some pretty Meta territory, though. Might be just more of a thought experiment, depending on Kurt's roadmap/priorities and if he really wants to start opening that can of worms. Also, he's going to run out of ASCII special character prefixes eventually, haha!  Yes something along those lines, where the script branched either to setup the 'environment' or branched to resolved the 'environment' setup by its previous self. Something I would do quite often if shell scripting in one way or another, but in the web world where things have already happened it's more tricky to get ones head around.
1613060973
Kurt J.
Pro
API Scripter
Duncan R. said: Hi @Kurt. Just wondering if you had any more thoughts on: 1. A dedicated comment function or a change to --| so that if you put it in front of another valid command it won't execute it? Only useful for debugging but easier than cutting and pasting code in/out of a scriptcard script while developing. 2. And did you think of any other way I could fudge passing variables between scriptcard macros? I haven't tried using the load/save parameter yet, but that was going to be my next attempt. Just wondered if these were possible or not. For #1, how about a "log" statement that would spit out a line to the API Console log if #debug was turned on and do nothing if it isn't? See below for #2 David M. said: That second one would be tricky. I'm assuming your thought is to have a master scriptcard execute and output a button linked to another scriptcard macro that would use a roll created by the master card? The only thing I can think of is some kind of read/write commands to an variable/object scoped to the scriptcard namespace (or to State, I suppose, though it seems like it wouldn't be necessary to persist between sessions). Master scriptcard writes, then subordinate scriptcard reads it. The subordinate scriptcard would need to do some checking to ensure the value existed (responsibility of the macro writer). The hypothetical read command should probably also delete (or have option to delete) the stored variable/object once it it is read to avoid potential downstream shenanigans. If optional, could allow for hitting that original button several times if needed. Some interesting (potentially useful) things could happen if the subordinate scriptcard also wrote values. Chaining sequences and whatnot. This starts to get into some pretty Meta territory, though. Might be just more of a thought experiment, depending on Kurt's roadmap/priorities and if he really wants to start opening that can of worms. Also, he's going to run out of ASCII special character prefixes eventually, haha!  Yea, --S and --L store variables to state (currently no way to delete them, but I'll work on something). That is likely the only way to pass things back and forth. I guess you could store items as attributes on characters (maybe make a dummy character to store them) and use chatsetattr to set them and the normal attribute notation to read them. And that last part (Also, he's going to run out of ASCII special character prefixes eventually, haha!) is why I started implementing things as functions with --~ :) My current plan for v0.0.15 is to add three new functions: "range", which handles min, max, and clamp (limit a value to be between a min and max), "round" which supports up, down, floor, and ceil, and "stringfuncs" which I've currently got planned for strlength, substring, and replace. Might be a couple of other string functions that would be worthwhile to implement.