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

!scriptcard {{ --#title|Doors --#titlecardbackground|#606c9b --#debug|1 --/| Based on User selected door size, toughness, HP, and determine DC to open. --/Determine Door Size & Initial Mods| --&DoorSize|?{What Size Door?|Small|Regular|Large|Huge/Giant} --C[&DoorSize]|Small:=ToughnessMod;[$DC.Raw]|Regular:=ToughnessMod;[$DC.Raw]|Large:=ToughnessMod;[$DC.Raw]+5|Huge/Giant:=ToughnessMod;[$DC.Raw]+10 --C[&DoorSize]|Small:=DC;[$DC.Raw]|Regular:=DC;[$DC.Raw]|Large:=DC;[$DC.Raw]+10|Huge/Giant:=DC;[$DC.Raw]+15 --:DoorToughnessBase| --=ToughRoll|1d20 --?[$ToughRoll] -le 3|&DoorToughnessBase;Weak/Fragile --?[$ToughRoll] -ge 4|&DoorToughnessBase;Regular/Undamaged --?[$ToughRoll] -ge 13|&DoorToughnessBase;Strong/Robust --?[$ToughRoll] -ge 17|&DoorToughnessBase;Armoured/Toughened --C[&DoorToughnessBase]|Weak/Fragile:=ToughnessBase;[$DC.Raw]+10|Regular/Undamaged:=ToughnessBase;[$DC.Raw]+15|Strong/Robust:=ToughnessBase;[$DC.Raw]+20|Armoured/Toughened:=ToughnessBase;[$DC.Raw]+25 --:DoorMaterial| --=MatRoll|1d20 --?[$MatRoll] -le 2|&DM;Bone/Ivory --?[$MatRoll] -ge 3|&DM;Wood --?[$MatRoll] -ge 12|&DM;Stone --?[$MatRoll] -ge 15|&DM;Iron --?[$MatRoll] -eq 19|^Exotic --?[$MatRoll] -eq 20|&DM;Deadly --^EndOfMaterials| --:Exotic| --=ExoticRoll|1d6 --?[$ExoticRoll] -eq 1|&DM;Gold --?[$ExoticRoll] -eq 2|&DM;Silver --?[$ExoticRoll] -eq 3|&DM;Platinum --?[$ExoticRoll] -eq 4|&DM;Mithral --?[$ExoticRoll] -eq 5|&DM;Adamantine --?[$ExoticRoll] -eq 6|&DM;Crystal --C[&DM]|Gold:=Toughness;[$DC.Raw]+5|Silver:=Toughness;[$DC.Raw]|Platinum:=Toughness;[$DC.Raw]+5|Mithral:=Toughness;[$DC.Raw]+7|Adamantine:=Toughness;[$DC.Raw]+10|Crystal:=Toughness;[$DC.Raw]-5 --C[&DM]|Gold:=DC;[$DC.Raw]+10|Silver:=DC;[$DC.Raw]+10|Platinum:=DC;[$DC.Raw]+10 --:EndOfMaterials| --:DoorState| --=MatRoll|1d20 --?[$MatRoll] -le 2|&DS;Jammed Door --?[$MatRoll] -ge 3|&DS;Regular Door --?[$MatRoll] -eq 14|&DS;Barred --?[$MatRoll] -eq 15|^Locked --?[$MatRoll] -eq 16|&DS;Barred and Locked --?[$MatRoll] -eq 17|&DS;Trapped --?[$MatRoll] -eq 18|&DS;Barred and Trapped --?[$MatRoll] -eq 19|&DS;Trapped and Locked --?[$MatRoll] -eq 20|&DS;Special --C[&DS]|Jammed Door:=DC;[$Toughness.Total] --C[&DS]|Barred:=ToughnessMod;[$DC.Raw]+3 --:Locked| --&DS|Locked --=MatRoll|1d20 --?[$MatRoll] -le 10|<Sliding bolt with iron padlock (Toughness 15) --?[$MatRoll] -ge 11|<Rim lock (Toughness 20) --?[$MatRoll] -ge 13|<Mortice lock (Toughness 25) --?[$MatRoll] -ge 15|<Sliding bolt on opposite side (same toughness as door, +10 to Spot DC) --?[$MatRoll] -eq 17|<Rim lock on opposite side (same toughness as door, +5 to Spot DC) --?[$MatRoll] -ge 18|<Arcane Lock (+10 to the Toughness of Door, can be dispelled with DC15, If Arcane Lock is rolled again then re-roll unless the door has multiple locks. In which case, apply Arcane Lock to the door again.) --?[$MatRoll] -eq 20|<Multiple locks (extra locks are always sliding bolts with iron padlocks, re-roll on the table to determine the first lock once again. If multiple locks are rolled again, then add another sliding bolt with iron padlock and roll again). --^EndOfLocks| --:SpotLockDC| --=MatRoll|1d20 --?[$MatRoll] -le 10|&SL;Lock is obvious --?[$MatRoll] -ge 11|&SL;Very Easy --?[$MatRoll] -ge 15|&SL;Easy --?[$MatRoll] -eq 17|&SL;Moderate --?[$MatRoll] -eq 18|&SL;Hard --?[$MatRoll] -eq 19|&SL;Very Hard --?[$MatRoll] -eq 20|&SL;Nearly Impossible --C[&SL]|Lock is obvious:=SpotLockDC;[$DC.Raw]|Very Easy:=SpotLockDC;[$DC.Raw]+5|Easy:=SpotLockDC;[$DC.Raw]+10|Moderate:=SpotLockDC;[$DC.Raw]+15|Hard:=SpotLockDC;[$DC.Raw]+20|Very Hard:=SpotLockDC;[$DC.Raw]+25|Nearly Impossible:=SpotLockDC;[$DC.Raw]+30 --^EndOfLocks| --:OpenLockDC| --=MatRoll|1d20 --?[$MatRoll] -eq 1|&OL;Very Easy --?[$MatRoll] -ge 2|&OL;Easy --?[$MatRoll] -ge 4|&OL;Moderate --?[$MatRoll] -ge 11|&OL;Hard --?[$MatRoll] -ge 17|&OL;Very Hard --?[$MatRoll] -ge 19|&OL;Nearly Impossible --C[&OL]|Very Easy:=OpenLockDC;[$DC.Raw]+5|Easy:=OpenLockDC;[$DC.Raw]+10|Moderate:=SpotLockDC;[$DC.Raw]+15|Hard:=SpotLockDC;[$DC.Raw]+20|Very Hard:=SpotLockDC;[$DC.Raw]+25|Nearly Impossible:=SpotLockDC;[$DC.Raw]+30 --:EndOfLocks| --:HitPoints| --&DieType|[&DM] --C[&DieType]|Crystal:=DieType;[$DC.Raw]+4|Bone/Ivory:=DieType;[DC.Raw]+6|Wood:=DieType;[DC.Raw]+6|Stone:=DieType;[DC.Raw]+8|Gold:=DieType;[DC.Raw]+10|Silver:=DieType;[DC.Raw]+10|Platinum:=DieType;[DC.Raw]+10|Iron:=DieType;[DC.Raw]+12|Mithral:=DieType;[DC.Raw]+20|Adamantine:=DieType;[DC.Raw]+30 --C[&DoorSize]|Small:=DiceCount;[$DiceCount]+3|Regular:=DC;[$DiceCount]+4|Large:=DC;[$DiceCount]+5|Huge/Giant:=DC;[$DiceCount]+6 --C[&DoorToughnessBase]|Weak/Fragile:=StrengthMod;[$DC.Raw]+.25|Regular/Undamaged:=StrengthMod;[$DC.Raw]+1|Strong/Robust:=StrengthMod;[$DC.Raw]+1.5|Armoured/Toughened:=StrengthMod;[$DC.Raw]+2 --:DieType|[DieType.Total] --$DiceCount|[DiceCount.Total] --$StrengthMod|[StrengthMod.Total] --=HP|[$DiceCount.Total]*[$DieType]*[$StrengthMod.Total] --/| Output data --+DoorSize|[&DoorSize] --+DoorMaterial|[&DM] --+DoorCondition|[&DoorToughnessBase] --+DC|[$DC.Total] STR check to open --+ToughnessMod|[$ToughnessMod.Total] --+ToughnessBase|[$ToughnessBase.Total] --+Toughness|[$ToughnessBase.Total]+[$ToughnessMod.Total] --+HP|[$HP.Total] --+DoorState|[&DS] --+LockType|[&LT] --+SpotLock|[&SL] --+SpotLockDC|[$SpotLockDC.Total] --+OpenLock|[&OL] --+OpenLockDC|[$OpenLockDC.Total] --:EndMacro| }}
Update: Added more.... However HP and the bottom of the card not populating.....
@DM Scotty - I see your quandary with HP.  You are attempting to use variables to determine the number, type and then modify the HP element by a fraction.  Frankly, I am not sure that you can use a variable to set the dice type.  That's a question for Kurt.  On brief examination of your other issue, you have goto statements  --^EndOfLocks|  at the end of Locked and Spotlock subroutines that bypass Spotlock and OpenLock subroutines and need to be removed.
1647350202
David M.
Pro
API Scripter
Still a few things funky. 1) As early as line 8 you are referencing the roll variable "DC", but it has not been assigned a value yet (or anywhere in the macro that I can tell).  --C[&DoorSize]|Small:=ToughnessMod; [$DC.Raw] |Regular:=ToughnessMod;[$DC.Raw]|Large:=ToughnessMod;[$DC.Raw]+5|Huge/Giant:=ToughnessMod;[$DC.Raw]+10 2) These lines before your hp aren't doing anything. In order to reference a roll variable, the syntax is [$varName]. You are missing the leading dollar sign. Also, I'm not sure if the first line below is supposed to be a label or what the purpose of the [DieType.Total] is to the right of it? In lines 2 & 3 below, there is no such statement type of "--$" AFAIK. Seems like maybe you were intending to print the value of these roll variables? if so, you would use --+ instead. Also, these roll variable references are also missing the dollar sign. --:DieType|[DieType.Total] --$DiceCount|[DiceCount.Total] --$StrengthMod|[StrengthMod.Total] 3) You seem to have a DieType string variable as well as a DieType roll variable. This is confusing. In line 2 below, you clone the string variable DM and assign to string variable DieType. You could just use DM for your case statement. There are more references to the DC roll variable here, so same comments apply as in point #1 above. --:HitPoints| --&DieType|[&DM] --C[&DieType]|Crystal:=DieType;[$DC.Raw]+4|Bone/Ivory:=DieType;[DC.Raw]+6|Wood:=DieType;[DC.Raw]+6|Stone:=DieType;[DC.Raw]+8|Gold:=DieType;[DC.Raw]+10|Silver:=DieType;[DC.Raw]+10|Platinum:=DieType;[DC.Raw]+10|Iron:=DieType;[DC.Raw]+12|Mithral:=DieType;[DC.Raw]+20|Adamantine:=DieType;[DC.Raw]+30
@David, Michael, Will (Knights of Coding) I have made several adjustments and cleanup based on all your feedback and suggestions... And appreciate all the support!!! So, below is the new code.....
!scriptcard {{ --#title|Doors --#titlecardbackground|#606c9b --#debug|1 --/| Based on User selected door size, toughness, HP, and determine DC to open. --/Determine Door Size & Initial Mods| --&DoorSize|?{What Size Door?|Small|Regular|Large|Huge/Giant} --C[&DoorSize]|Large:=ToughnessMod;[%1%]+5|Huge/Giant:=ToughnessMod;[%1%]+10 --C[&DoorSize]|Large:=DoorDC;[%1%]+10|Huge/Giant:=DoorDC;[%1%]+15 --:DoorToughnessBase| --=ToughRoll|1d20 --?[$ToughRoll] -le 3|&DoorToughnessBase;Weak/Fragile --?[$ToughRoll] -ge 4|&DoorToughnessBase;Regular/Undamaged --?[$ToughRoll] -ge 13|&DoorToughnessBase;Strong/Robust --?[$ToughRoll] -ge 17|&DoorToughnessBase;Armoured/Toughened --C[&DoorToughnessBase]|Weak/Fragile:=ToughnessBase;[%1%]+10|Regular/Undamaged:=ToughnessBase;[%1%]+15|Strong/Robust:=ToughnessBase;[%1%]+20|Armoured/Toughened:=ToughnessBase;[%1%]+25 --:DoorMaterial| --=MatRoll|1d20 --?[$MatRoll] -le 2|&DM;Bone/Ivory --?[$MatRoll] -ge 3|&DM;Wood --?[$MatRoll] -ge 12|&DM;Stone --?[$MatRoll] -ge 15|&DM;Iron --?[$MatRoll] -eq 19|^Exotic --?[$MatRoll] -eq 20|&DM;Deadly --^EndOfMaterials| --:Exotic| --=ExoticRoll|1d6 --?[$ExoticRoll] -eq 1|&DM;Gold --?[$ExoticRoll] -eq 2|&DM;Silver --?[$ExoticRoll] -eq 3|&DM;Platinum --?[$ExoticRoll] -eq 4|&DM;Mithral --?[$ExoticRoll] -eq 5|&DM;Adamantine --?[$ExoticRoll] -eq 6|&DM;Crystal --C[&DM]|Gold:=Toughness;[%1%]+5|Silver:=Toughness;[%1%]+5|Platinum:=Toughness;[%1%]+5|Mithral:=Toughness;[%1%]+7|Adamantine:=Toughness;[%1%]+10|Crystal:=Toughness;[%1%]-5 --C[&DM]|Gold:=DoorDC;[%1%]+10|Silver:=DoorDC;[%1%]+10|Platinum:=DoorDC;[%1%]+10 --:EndOfMaterials| --:DoorState| --=MatRoll|1d20 --?[$MatRoll] -le 2|&DS;Jammed Door --?[$MatRoll] -ge 3|&DS;Regular Door --?[$MatRoll] -eq 14|&DS;Barred --?[$MatRoll] -eq 15|^Locked --?[$MatRoll] -eq 16|&DS;Barred and Locked --?[$MatRoll] -eq 17|&DS;Trapped --?[$MatRoll] -eq 18|&DS;Barred and Trapped --?[$MatRoll] -eq 19|&DS;Trapped and Locked --?[$MatRoll] -eq 20|&DS;Special --C[&DS]|Jammed Door:=DoorDC;[$Toughness.Total] --C[&DS]|Barred:=ToughnessMod;[%1%]+3 --:Locked| --&DS|Locked --=MatRoll|1d20 --?[$MatRoll] -le 10|&LC;Sliding bolt with iron padlock --?[$MatRoll] -ge 11|&LC;Rim lock --?[$MatRoll] -ge 13|&LC;Mortice lock --?[$MatRoll] -ge 15|&LC;Sliding bolt on opposite side --?[$MatRoll] -eq 17|&LC;Rim lock on opposite side --?[$MatRoll] -ge 18|&LC;Arcane Lock (can be dispelled with DC15) --?[$MatRoll] -eq 20|&LC;Multiple locks (extra locks are always sliding bolts with iron padlocks, re-roll on the table to determine the first lock once again. If multiple locks are rolled again, then add another sliding bolt with iron padlock and roll again). --C[&LC]|Sliding bolt with iron padlock:=LockToughness;[%1%]+15|Rim lock:=LockToughness;[%1%]+20|Mortice lock:=LockToughness;[%1%]+25 --C[&LC]|Sliding bolt on opposite side:=LockToughness;[$Toughness.Total]|Rim lock on opposite side:=LockToughness;[$Toughness.Total] --C[&LC]|Sliding bolt on opposite side:=SpotLockDC;[%1%]+10|Rim lock on opposite side:=SpotLockDC;[%1%]+5 --C[&LC]|Arcane Lock:=ToughnessMod;[%1%]+10 --:EndOfLocks| --:SpotLockDC| --=MatRoll|1d20 --?[$MatRoll] -le 10|&SL;Lock is obvious --?[$MatRoll] -ge 11|&SL;Very Easy --?[$MatRoll] -ge 15|&SL;Easy --?[$MatRoll] -eq 17|&SL;Moderate --?[$MatRoll] -eq 18|&SL;Hard --?[$MatRoll] -eq 19|&SL;Very Hard --?[$MatRoll] -eq 20|&SL;Nearly Impossible --C[&SL]|Lock is obvious:=SpotLockDC;[%1%]+0|Very Easy:=SpotLockDC;[%1%]+5|Easy:=SpotLockDC;[%1%]+10|Moderate:=SpotLockDC;[%1%]+15|Hard:=SpotLockDC;[%1%]+20|Very Hard:=SpotLockDC;[%1%]+25|Nearly Impossible:SpotLockDC;=SpotLock;[%1%]+30 --:EndOfLocks| --:OpenLockDC| --=MatRoll|1d20 --?[$MatRoll] -eq 1|&OL;Very Easy --?[$MatRoll] -ge 2|&OL;Easy --?[$MatRoll] -ge 4|&OL;Moderate --?[$MatRoll] -ge 11|&OL;Hard --?[$MatRoll] -ge 17|&OL;Very Hard --?[$MatRoll] -ge 19|&OL;Nearly Impossible --C[&OL]|Very Easy:=OpenLockDC;[%1%]+5|Easy:=OpenLockDC;[%1%]+10|Moderate:=OpenLockDC;[%1%]+15|Hard:=OpenLockDC;[%1%]+20|Very Hard:=OpenLockDC;[%1%]+25|Nearly Impossible:=OpenLockDC;[%1%]+30 --:EndOfLocks| --:HitPoints| --&DieType|[&DM] --C[&DieType]|Crystal:=DieType;[$DC.Raw]+4|Bone/Ivory:=DieType;[DC.Raw]+6|Wood:=DieType;[DC.Raw]+6|Stone:=DieType;[DC.Raw]+8|Gold:=DieType;[DC.Raw]+10|Silver:=DieType;[DC.Raw]+10|Platinum:=DieType;[DC.Raw]+10|Iron:=DieType;[DC.Raw]+12|Mithral:=DieType;[DC.Raw]+20|Adamantine:=DieType;[DC.Raw]+30 --C[&DoorSize]|Small:=DiceCount;[$DiceCount]+3|Regular:=DC;[$DiceCount]+4|Large:=DC;[$DiceCount]+5|Huge/Giant:=DC;[$DiceCount]+6 --C[&DoorToughnessBase]|Weak/Fragile:=StrengthMod;[$DC.Raw]+.25|Regular/Undamaged:=StrengthMod;[$DC.Raw]+1|Strong/Robust:=StrengthMod;[$DC.Raw]+1.5|Armoured/Toughened:=StrengthMod;[$DC.Raw]+2 --:DieType|[DieType.Total] --$DiceCount|[DiceCount.Total] --$StrengthMod|[StrengthMod.Total] --=HP|[$DiceCount.Total]*[$DieType]*[$StrengthMod.Total] --/| Output data --+DoorSize|[&DoorSize] --+DoorMaterial|[&DM] --+DoorCondition|[&DoorToughnessBase] --+DoorDC|[$DoorDC.Total] STR check to open --+ToughnessMod|[$ToughnessMod.Total] --+ToughnessBase|[$ToughnessBase.Total] --&TotalToughness|[$ToughnessBase.Total]+[$ToughnessMod.Total] --+Toughness=|[&TotalToughness] --+HP|[$HP.Total] --+DoorState|[&DS] --+LockClass|[&LC] --+LockToughness|[$LockToughness.Total] --+SpotLock|[&SL] --+SpotLockDC|[$SpotLockDC.Total] --+OpenLock|[&OL] --+OpenLockDC|[$OpenLockDC.Total] --:EndMacro| }}
So, I have cleaned up and the replacement of [DC.Raw] to [1%] .... Changed LockType to LockClass & added LockToughness Added LockClass Conditionals corrected --^EndOfLocks| - Im still looking for a solution to correct the HP section: - Would it be easier if I assign the dice type to each material? If so would that be in a --C Line or a --? ... and assign the # of rolls for each door size? just a thought? - Looking for a solution  ToughnessMod & ToughnessBase to add correctly with Combined Total output. - I also noticed it is always populating a LOCKED DOOR..... not sure why..... Any suggestions?? - How to have it reroll when "Multiple Locks" is selected in LockClass section of script. Also, any additional feedback or suggestions that are identified are greatly appreciated!!!! Thanks again..
My next project:&nbsp; Import NPC For my next large project, I want to create a quick way to create an NPC in Roll20.&nbsp; Here are my initial thoughts: 1. Use the amazing NPC Generator website:&nbsp; <a href="https://miniworlds.online/generators/generateNPC.html" rel="nofollow">https://miniworlds.online/generators/generateNPC.html</a> &nbsp;to create the Markdown text of an NPC. 2. Copy/Paste markdown text into a ScriptCards queried variable ([&amp;NPC]) via a text prompt/user query.&nbsp;&nbsp; 3. Parse the heck out of it, extracting all the pertinent NPC Character Fields (Name, Race/Class, Stats, HP, Languages, Skills,&nbsp; Appearance, Personality, Abilities, Attacks, Trinkets, ....) 4. Populate a new NPC Character sheet with this data using either native ScriptCards or Chatsetattr.&nbsp;&nbsp; I've got a feeling this is a week-long 25+ hour endeavor.&nbsp; Any thoughts from the community before I jump in.&nbsp; I plan to post my code on the Sharing forum.&nbsp;&nbsp; -Will
1647470469
Kurt J.
Pro
API Scripter
Will M. said: My next project:&nbsp; Import NPC For my next large project, I want to create a quick way to create an NPC in Roll20.&nbsp; Here are my initial thoughts: 1. Use the amazing NPC Generator website:&nbsp; <a href="https://miniworlds.online/generators/generateNPC.html" rel="nofollow">https://miniworlds.online/generators/generateNPC.html</a> &nbsp;to create the Markdown text of an NPC. 2. Copy/Paste markdown text into a ScriptCards queried variable ([&amp;NPC]) via a text prompt/user query.&nbsp;&nbsp; 3. Parse the heck out of it, extracting all the pertinent NPC Character Fields (Name, Race/Class, Stats, HP, Languages, Skills,&nbsp; Appearance, Personality, Abilities, Attacks, Trinkets, ....) 4. Populate a new NPC Character sheet with this data using either native ScriptCards or Chatsetattr.&nbsp;&nbsp; I've got a feeling this is a week-long 25+ hour endeavor.&nbsp; Any thoughts from the community before I jump in.&nbsp; I plan to post my code on the Sharing forum.&nbsp;&nbsp; -Will That sounds very cool :) I didn't know about that site. I was playing around to see if the markdown would run into any trouble, and indeed because it uses HTML replacements for some characters (like ') which contain semicolons it can break the --i command. I've uploaded version 1.6.8 Experimental of ScriptCards to the GitHub to address this. The --i command and subsequent resumes now utilize the value of the parameterdelimiter settings, so this actually works when I paste in the markdown !script {{&nbsp; &nbsp; --#parameterdelimiter|$ &nbsp; --IScriptCards needs additional information to continue;Provide Markdown for NPC to Import|q;Markdown;Markdown? &nbsp; --+Markdown|[&amp;Markdown] &nbsp; --~|array$fromstring$Lines$&gt;$[&amp;Markdown] &nbsp; --#parameterdelimiter|; &nbsp; --~count|array;getlength;Lines &nbsp; --%Loop|0;[&amp;count] &nbsp; &nbsp; --+Row [&amp;Loop]|[@Lines([&amp;Loop])] &nbsp; --%| }} Do you have a way to create the character object? If not, I could extend the --! syntax to allow for object creation and pass back a character ID...
1647472275

Edited 1647472354
Kurt - you are on top of this. I'm going to check out version 1.6.8 tomorrow (running a game shortly) to see if this helps my issue. The cool thing about the site is it gives you the actual Markdown text.&nbsp; The bad thing is it uses |:---:|:---:| type syntax to place things like character attributes (Str, Dex, ...) into a table format.&nbsp; SC chokes on&nbsp; --:| and curtails the text when it comes across that syntax.&nbsp;&nbsp; I did get the first half of the NPC parsed out before running across the reserved text/syntax issue.&nbsp;&nbsp; On creating a character object , I didn't have an easy way of doing this through code and was just going to create a blank one manually, then name it "New NPC" so that it could be referenced from the script.&nbsp; But if you could add that functionality, it would be handy.&nbsp; I wasn't sure if there would be a synchronous issue, between the creation of the sheet object and populating it's attribute fields.&nbsp;&nbsp; FYI - I don't use the --i command to get input from the user and instead just issue a simple query command ( --&amp;NPC|"?{NPC Markdown Text?|}" ).&nbsp; I rely heavily on your string functions; before, after and trim.&nbsp;&nbsp; Below is my half-written script.&nbsp;&nbsp; !script {{ --/|Script Name : Import NPC --/|Version : 0.1 --/|Requires SC : Scripcards Version 1.6.6 --/|Author : Will M. --/|Description : Takes a the text from a Markdown version of an NPC created by the <a href="https://miniworlds.online/generators/generateNPC.html" rel="nofollow">https://miniworlds.online/generators/generateNPC.html</a> site --/| and populates an NPC in Roll20 --:TOP| --#reentrant|Import NPC --#title|Import NPC --#whisper|self --#debug|1 --/|Special characters and key fields used to parse NPC Markdown --&amp;NL|&gt; --&amp;STAR|* --&amp;COMMA|, --&amp;LEFT_PAREN|( --&amp;RIGHT_PAREN|) --&amp;H2|## --&amp;H3|### --&amp;ATT|:- --&amp;CHA|CHA --/|Ask user for Markdown text representing NPC --&amp;NPC|"?{NPC Markdown Text?|}" --/|Debug Code --+NPC|[&amp;NPC] --&gt;GET_NAME| --+Name|[&amp;Name] --&gt;GET_RACE_SEX_CLASS| --+Race|[&amp;Race] --+Sex|[&amp;Sex] --+Class|[&amp;Class] --&gt;GET_AGE_LEVEL| --+AGE|[&amp;AGE] --+LEVEL|[&amp;LEVEL] --&gt;GET_AC| --+AC|[&amp;AC] --&gt;GET_HP| --+HP|[&amp;HP] --&gt;GET_MOVEMENT| --+WALK|[&amp;WALK] --+FLY|[&amp;FLY] --+SWIM|[&amp;SWIM] --/|Fails at this point because of the Markdown table syntax use of reserved characters --&gt;GET_ATTRIBUTES| --+Attributes|[&amp;Temp] --&gt;GET_DESCRIPTION| --&gt;GET_PP| --&gt;GET_LANGUAGES| --&gt;GET_ABILITIES| --&gt;GET_TRINKETS| --&gt;GET_GOSSIP| --&gt;WRITE_TO_NPC| --X| --:GET_NAME| Text string after first H2 Header symbol --~z1|string;after;[&amp;H2];[&amp;NPC] --~z2|string;before;[&amp;NL];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;Name|[&amp;z3] --&lt;| --:GET_RACE_SEX_CLASS| --~z1|string;after;[&amp;H2];[&amp;NPC] --~z2|string;after;[&amp;NL];[&amp;z1] --~z3|string;after;[&amp;STAR];[&amp;z2] --~z4|string;before;[&amp;COMMA];[&amp;z3] --~z5|string;before;[&amp;LEFT_PAREN];[&amp;z4] --~z6|string;trim;[&amp;z5] --&amp;Race|[&amp;z6] --~z4|string;after;[&amp;LEFT_PAREN];[&amp;z3] --~z5|string;before;[&amp;RIGHT_PAREN];[&amp;z4] --~z6|string;trim;[&amp;z5] --&amp;Sex|[&amp;z6] --~z4|string;after;[&amp;COMMA];[&amp;z3] --~z5|string;before;[&amp;STAR];[&amp;z4] --~z6|string;trim;[&amp;z5] --&amp;Class|[&amp;z6] --&lt;| --:GET_AGE_LEVEL| --~z1|string;after;**Age**;[&amp;NPC] --~z2|string;before;[&amp;LEFT_PAREN];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;AGE|[&amp;z3] --~z1|string;after;*Level:*;[&amp;NPC] --~z2|string;before;[&amp;RIGHT_PAREN];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;LEVEL|[&amp;z3] --&lt;| --:GET_AC| --~z1|string;after;**Armor Class**;[&amp;NPC] --~z2|string;before;[&amp;NL];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;AC|[&amp;z3] --&lt;| --:GET_HP| --~z1|string;after;**Hit Points**;[&amp;NPC] --~z2|string;before;[&amp;LEFT_PAREN];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;HP|[&amp;z3] --&lt;| --:GET_MOVEMENT| --~z1|string;after;**Walk**;[&amp;NPC] --~z2|string;before;[&amp;COMMA];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;WALK|[&amp;z3] --~z1|string;after;**Fly**;[&amp;NPC] --~z2|string;before;[&amp;COMMA];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;FLY|[&amp;z3] --~z1|string;after;**Swim**;[&amp;NPC] --~z2|string;before;[&amp;NL];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;SWIM|[&amp;z3] --&lt;| --:GET_ATTRIBUTES| --~z1|string;after;[&amp;CHA];[&amp;NPC] --+Debug0|[&amp;z1] --~z1|string;after;[&amp;NL];[&amp;z1] --/~z1|string;after;[&amp;NL];[&amp;z1] --+Debug1|[&amp;z1] --~z2|string;after;[&amp;NL];[&amp;z1] --+Debug2|[&amp;z2] --~z3|string;before;[&amp;NL];[&amp;z2] --+Debug3|[&amp;z3] --~z4|string;trim;[&amp;z3] --+Debug4|[&amp;z4] --&amp;Temp|[&amp;z4] --&lt;| }}
1647475959
Kurt J.
Pro
API Scripter
Will M. said: Kurt - you are on top of this. I'm going to check out version 1.6.8 tomorrow (running a game shortly) to see if this helps my issue. The cool thing about the site is it gives you the actual Markdown text.&nbsp; The bad thing is it uses |:---:|:---:| type syntax to place things like character attributes (Str, Dex, ...) into a table format.&nbsp; SC chokes on&nbsp; --:| and curtails the text when it comes across that syntax.&nbsp;&nbsp; I did get the first half of the NPC parsed out before running across the reserved text/syntax issue.&nbsp;&nbsp; On creating a character object , I didn't have an easy way of doing this through code and was just going to create a blank one manually, then name it "New NPC" so that it could be referenced from the script.&nbsp; But if you could add that functionality, it would be handy.&nbsp; I wasn't sure if there would be a synchronous issue, between the creation of the sheet object and populating it's attribute fields.&nbsp;&nbsp; FYI - I don't use the --i command to get input from the user and instead just issue a simple query command ( --&amp;NPC|"?{NPC Markdown Text?|}" ).&nbsp; I rely heavily on your string functions; before, after and trim.&nbsp;&nbsp; Below is my half-written script.&nbsp;&nbsp; !script {{ --/|Script Name : Import NPC --/|Version : 0.1 --/|Requires SC : Scripcards Version 1.6.6 --/|Author : Will M. --/|Description : Takes a the text from a Markdown version of an NPC created by the <a href="https://miniworlds.online/generators/generateNPC.html" rel="nofollow">https://miniworlds.online/generators/generateNPC.html</a> site --/| and populates an NPC in Roll20 --:TOP| --#reentrant|Import NPC --#title|Import NPC --#whisper|self --#debug|1 --/|Special characters and key fields used to parse NPC Markdown --&amp;NL|&gt; --&amp;STAR|* --&amp;COMMA|, --&amp;LEFT_PAREN|( --&amp;RIGHT_PAREN|) --&amp;H2|## --&amp;H3|### --&amp;ATT|:- --&amp;CHA|CHA --/|Ask user for Markdown text representing NPC --&amp;NPC|"?{NPC Markdown Text?|}" --/|Debug Code --+NPC|[&amp;NPC] --&gt;GET_NAME| --+Name|[&amp;Name] --&gt;GET_RACE_SEX_CLASS| --+Race|[&amp;Race] --+Sex|[&amp;Sex] --+Class|[&amp;Class] --&gt;GET_AGE_LEVEL| --+AGE|[&amp;AGE] --+LEVEL|[&amp;LEVEL] --&gt;GET_AC| --+AC|[&amp;AC] --&gt;GET_HP| --+HP|[&amp;HP] --&gt;GET_MOVEMENT| --+WALK|[&amp;WALK] --+FLY|[&amp;FLY] --+SWIM|[&amp;SWIM] --/|Fails at this point because of the Markdown table syntax use of reserved characters --&gt;GET_ATTRIBUTES| --+Attributes|[&amp;Temp] --&gt;GET_DESCRIPTION| --&gt;GET_PP| --&gt;GET_LANGUAGES| --&gt;GET_ABILITIES| --&gt;GET_TRINKETS| --&gt;GET_GOSSIP| --&gt;WRITE_TO_NPC| --X| --:GET_NAME| Text string after first H2 Header symbol --~z1|string;after;[&amp;H2];[&amp;NPC] --~z2|string;before;[&amp;NL];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;Name|[&amp;z3] --&lt;| --:GET_RACE_SEX_CLASS| --~z1|string;after;[&amp;H2];[&amp;NPC] --~z2|string;after;[&amp;NL];[&amp;z1] --~z3|string;after;[&amp;STAR];[&amp;z2] --~z4|string;before;[&amp;COMMA];[&amp;z3] --~z5|string;before;[&amp;LEFT_PAREN];[&amp;z4] --~z6|string;trim;[&amp;z5] --&amp;Race|[&amp;z6] --~z4|string;after;[&amp;LEFT_PAREN];[&amp;z3] --~z5|string;before;[&amp;RIGHT_PAREN];[&amp;z4] --~z6|string;trim;[&amp;z5] --&amp;Sex|[&amp;z6] --~z4|string;after;[&amp;COMMA];[&amp;z3] --~z5|string;before;[&amp;STAR];[&amp;z4] --~z6|string;trim;[&amp;z5] --&amp;Class|[&amp;z6] --&lt;| --:GET_AGE_LEVEL| --~z1|string;after;**Age**;[&amp;NPC] --~z2|string;before;[&amp;LEFT_PAREN];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;AGE|[&amp;z3] --~z1|string;after;*Level:*;[&amp;NPC] --~z2|string;before;[&amp;RIGHT_PAREN];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;LEVEL|[&amp;z3] --&lt;| --:GET_AC| --~z1|string;after;**Armor Class**;[&amp;NPC] --~z2|string;before;[&amp;NL];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;AC|[&amp;z3] --&lt;| --:GET_HP| --~z1|string;after;**Hit Points**;[&amp;NPC] --~z2|string;before;[&amp;LEFT_PAREN];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;HP|[&amp;z3] --&lt;| --:GET_MOVEMENT| --~z1|string;after;**Walk**;[&amp;NPC] --~z2|string;before;[&amp;COMMA];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;WALK|[&amp;z3] --~z1|string;after;**Fly**;[&amp;NPC] --~z2|string;before;[&amp;COMMA];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;FLY|[&amp;z3] --~z1|string;after;**Swim**;[&amp;NPC] --~z2|string;before;[&amp;NL];[&amp;z1] --~z3|string;trim;[&amp;z2] --&amp;SWIM|[&amp;z3] --&lt;| --:GET_ATTRIBUTES| --~z1|string;after;[&amp;CHA];[&amp;NPC] --+Debug0|[&amp;z1] --~z1|string;after;[&amp;NL];[&amp;z1] --/~z1|string;after;[&amp;NL];[&amp;z1] --+Debug1|[&amp;z1] --~z2|string;after;[&amp;NL];[&amp;z1] --+Debug2|[&amp;z2] --~z3|string;before;[&amp;NL];[&amp;z2] --+Debug3|[&amp;z3] --~z4|string;trim;[&amp;z3] --+Debug4|[&amp;z4] --&amp;Temp|[&amp;z4] --&lt;| }} Using --i might get around the problem with --:| since the return from --i doesn't get parsed as script lines, so it won't get split up into issues. I generated a few dozen characters on the site, and that always ends up on the same line, so it should be easy to skip :) I'll look at adding the character object as part of --!. There shouldn't be a sync issue because it isn't shelling out to another API to do it, and it doesn't look like createObj is a callback function. Version 1.6.9 will be up shortly :)
1647477122
Kurt J.
Pro
API Scripter
ScriptCards 1.6.9 Experimental A new version has been pushed to the GitHub Repo. This version expands the --! object manipulation syntax to add a "o" command to create objects. Currently, the only type of object that can be created is a character, but I'll expand that. The syntax is --!oc-ReturnVariableName|CharacterName ("o" for object creation, "c" for character", a dash, followed by the name of a string variable that will return the object ID of the created character for you to use later. For example: !script {{ &nbsp; --!oc-MyCharID|Gimli &nbsp; --+CharID|[&amp;MyCharID] }} Creates a character named Gimli and displays the Character ID. You can then use --!c to set character object properties or --!a to set/create attributes.
1647529669

Edited 1647532524
@Kurt - You were correct, using "--i" functionality to query for the Markdown allowed me to put the entire Markdown string into a variable and I was able to successfully parse it.&nbsp; I'm now well on my way to building this markdown parser/importer.&nbsp;&nbsp; With this and your new "--o" function, I could easily write a script that imports NPCs from a well-formatted JSON type string that's stored off in Excel or some other text file format.&nbsp; This would allow me to have an offline repository of all my NPCs and then import them in as I need them.&nbsp;&nbsp; I can't wait to give this a try.&nbsp;&nbsp;
!scriptcard {{ --#title|Dungeon Doors --#titlecardbackground|#606c9b --#leftsub|DM --#rightsub|Scotty --&gt;GetImage|[%1%] --/|CARD --+|[&amp;Image] --+|[img]<a href="https://imgsrv.roll20.net/?src=https%3A//pbs.twimg.com/media/DTjo2alXkAAO1_7%3Fformat%3Djpg%26name%3D900x900[/img]" rel="nofollow">https://imgsrv.roll20.net/?src=https%3A//pbs.twimg.com/media/DTjo2alXkAAO1_7%3Fformat%3Djpg%26name%3D900x900[/img]</a> --+|[c][b][%2%][/b][/c] --&lt;| --#debug|1 --/| Based on User selected door size, toughness, HP, and determine DC to open. --/Determine Door Size &amp; Initial Mods| --&amp;DoorSize|?{What Size Door?|Small|Regular|Large|Huge/Giant} --C[&amp;DoorSize]|Small:=ToughnessMod;[%1%]+0|Regular:=ToughnessMod;[%1%]+0|Large:=ToughnessMod;[%1%]+5|Huge/Giant:=ToughnessMod;[%1%]+10 --C[&amp;DoorSize]|Small:=DoorDC;[%1%]+0|Regular:=DoorDC;[%1%]+0|Large:=DoorDC;[%1%]+10|Huge/Giant:=DoorDC;[%1%]+15 --:DoorMeasurement| --DoorSize|[&amp;DoorSize] --=DoorSize|[%1%] --?"[&amp;DoorSize]" -eq "Small"|&amp;M;2-5ft. --?"[&amp;DoorSize]" -eq "Regular"|&amp;M;5-10ft. --?"[&amp;DoorSize]" -eq "Large"|&amp;M;10-20ft. --?"[&amp;DoorSize]" -eq "Huge/Giant"|&amp;M;20+ft. --:DoorToughnessBase| --=ToughRoll|1d20 --?[$ToughRoll] -le 3|&amp;DoorToughnessBase;Weak/Fragile --?[$ToughRoll] -ge 4|&amp;DoorToughnessBase;Regular/Undamaged --?[$ToughRoll] -ge 13|&amp;DoorToughnessBase;Strong/Robust --?[$ToughRoll] -ge 17|&amp;DoorToughnessBase;Armoured/Toughened --C[&amp;DoorToughnessBase]|Weak/Fragile:=ToughnessBase;[%1%]+10|Regular/Undamaged:=ToughnessBase;[%1%]+15|Strong/Robust:=ToughnessBase;[%1%]+20|Armoured/Toughened:=ToughnessBase;[%1%]+25 --:DoorMaterial| --=MatRoll|1d20 --?[$MatRoll] -le 2|&amp;DM;Bone/Ivory --?[$MatRoll] -ge 3|&amp;DM;Wood --?[$MatRoll] -ge 12|&amp;DM;Stone --?[$MatRoll] -ge 15|&amp;DM;Iron --?[$MatRoll] -eq 19|^Exotic --?[$MatRoll] -eq 20|&amp;DM;Deadly --^EndOfMaterials| --:Exotic| --=ExoticRoll|1d6 --?[$ExoticRoll] -eq 1|&amp;DM;Gold --?[$ExoticRoll] -eq 2|&amp;DM;Silver --?[$ExoticRoll] -eq 3|&amp;DM;Platinum --?[$ExoticRoll] -eq 4|&amp;DM;Mithral --?[$ExoticRoll] -eq 5|&amp;DM;Adamantine --?[$ExoticRoll] -eq 6|&amp;DM;Crystal --C[&amp;DM]|Gold:=Toughness;[%1%]+5|Silver:=Toughness;[%1%]+5|Platinum:=Toughness;[%1%]+5|Mithral:=Toughness;[%1%]+7|Adamantine:=Toughness;[%1%]+10|Crystal:=Toughness;[%1%]-5 --C[&amp;DM]|Gold:=DoorDC;[%1%]+10|Silver:=DoorDC;[%1%]+10|Platinum:=DoorDC;[%1%]+10 --:EndOfMaterials| --:DoorState| --=MatRoll|1d20 --?[$MatRoll] -le 2|&amp;DS;Jammed Door --?[$MatRoll] -ge 3|&amp;DS;Regular Door --?[$MatRoll] -eq 14|&amp;DS;Barred --?[$MatRoll] -eq 15|^Locked --?[$MatRoll] -eq 16|&amp;DS;Barred and Locked --?[$MatRoll] -eq 17|&amp;DS;Trapped --?[$MatRoll] -eq 18|&amp;DS;Barred and Trapped --?[$MatRoll] -eq 19|&amp;DS;Trapped and Locked --?[$MatRoll] -eq 20|&amp;DS;Special --C[&amp;DS]|Jammed Door:=DoorDC;[$Toughness.Total] --C[&amp;DS]|Barred:=ToughnessMod;[%1%]+3 --:Locks| --=MatRoll|1d20 --?[$MatRoll] -le 10|&amp;LC;Sliding bolt with iron padlock --?[$MatRoll] -ge 11|&amp;LC;Rim lock --?[$MatRoll] -ge 13|&amp;LC;Mortice lock --?[$MatRoll] -ge 15|&amp;LC;Sliding bolt on opposite side --?[$MatRoll] -eq 17|&amp;LC;Rim lock on opposite side --?[$MatRoll] -ge 18|&amp;LC;Arcane Lock (can be dispelled with DC15) --?[$MatRoll] -eq 20|&amp;LC;Multiple locks (extra locks are always sliding bolts with iron padlocks, re-roll on the table to determine the first lock once again. If multiple locks are rolled again, then add another sliding bolt with iron padlock and roll again). --C[&amp;LC]|Sliding bolt with iron padlock:=LockToughness;[%1%]+15|Rim lock:=LockToughness;[%1%]+20|Mortice lock:=LockToughness;[%1%]+25 --C[&amp;LC]|Sliding bolt on opposite side:=LockToughness;[$DoorToughness.Total]|Rim lock on opposite side:=LockToughness;[$DoorToughness.Total] --C[&amp;LC]|Sliding bolt on opposite side:=SpotLockDC;[%1%]+10|Rim lock on opposite side:=SpotLockDC;[%1%]+5 --C[&amp;LC]|Arcane Lock:=ToughnessMod;[%1%]+10 --C[&amp;LC]|Sliding bolt with iron padlock:=&amp;DS;Locked|Rim lock:=&amp;DS;Locked|Mortice lock:=&amp;DS;Locked|Sliding bolt on opposite side:=&amp;DS;Locked|Rim lock on opposite side:=&amp;DS;Locked|Arcane Lock:=&amp;DS;Magically Locked --:EndOfLocks| --:SpotLockDC| --=MatRoll|1d20 --?[$MatRoll] -le 10|&amp;SL;Lock is obvious --?[$MatRoll] -ge 11|&amp;SL;Very Easy --?[$MatRoll] -ge 15|&amp;SL;Easy --?[$MatRoll] -eq 17|&amp;SL;Moderate --?[$MatRoll] -eq 18|&amp;SL;Hard --?[$MatRoll] -eq 19|&amp;SL;Very Hard --?[$MatRoll] -eq 20|&amp;SL;Nearly Impossible --C[&amp;SL]|Lock is obvious:=SpotLockDC;[%1%]+0|Very Easy:=SpotLockDC;[%1%]+5|Easy:=SpotLockDC;[%1%]+10|Moderate:=SpotLockDC;[%1%]+15|Hard:=SpotLockDC;[%1%]+20|Very Hard:=SpotLockDC;[%1%]+25|Nearly Impossible:SpotLockDC;=SpotLock;[%1%]+30 --:EndOfLocks| --:OpenLockDC| --=MatRoll|1d20 --?[$MatRoll] -eq 1|&amp;OL;Very Easy --?[$MatRoll] -ge 2|&amp;OL;Easy --?[$MatRoll] -ge 4|&amp;OL;Moderate --?[$MatRoll] -ge 11|&amp;OL;Hard --?[$MatRoll] -ge 17|&amp;OL;Very Hard --?[$MatRoll] -ge 19|&amp;OL;Nearly Impossible --C[&amp;OL]|Very Easy:=OpenLockDC;[%1%]+5|Easy:=OpenLockDC;[%1%]+10|Moderate:=OpenLockDC;[%1%]+15|Hard:=OpenLockDC;[%1%]+20|Very Hard:=OpenLockDC;[%1%]+25|Nearly Impossible:=OpenLockDC;[%1%]+30 --:EndOfLocks| --:DiceCount| --DiceCount|[&amp;DoorSize] --=DiceCount|[$ROLLDC] --?"[&amp;DoorSize]" -eq "Small"|&amp;DC;3 --?"[&amp;DoorSize]" -eq "Regular"|&amp;DC;4 --?"[&amp;DoorSize]" -eq "Large"|&amp;DC;5 --?"[&amp;DoorSize]" -eq "Huge/Giant"|&amp;DC;6 --:EndOfDiceCount| --:DiceType| --:DieType|[&amp;DM] --=DiceType|[$ROLLDT] --?"[&amp;DM]" -eq "Crystal"|&amp;DT;1d4 --?"[&amp;DM]" -eq "Bone/Ivory"|&amp;DT;1d6 --?"[&amp;DM]" -eq "Wood"|&amp;DT;1d6 --?"[&amp;DM]" -eq "Stone"|&amp;DT;1d8 --?"[&amp;DM]" -eq "Gold"|&amp;DT;1d10 --?"[&amp;DM]" -eq "Silver"|&amp;DT;1d10 --?"[&amp;DM]" -eq "Platinum"|&amp;DT;1d10 --?"[&amp;DM]" -eq "Iron"|&amp;DT;1d12 --?"[&amp;DM]" -eq "Mithral"|&amp;DT;1d20 --?"[&amp;DM]" -eq "Adamantine"|&amp;DT;1d30 --:EndOfDiceType| --:HitPoints| --HP| --C[&amp;DoorToughnessBase]|Weak/Fragile:=StrengthMod;[%1%]+.5|Regular/Undamaged:=StrengthMod;[%1%]+1|Strong/Robust:=StrengthMod;[%1%]+1.5|Armoured/Toughened:=StrengthMod;[%1%]+2 --=HPRoll|[&amp;DC]*[&amp;DT] --=HPRollTotal|[$HPRoll.Total] --=HP|[$HPRoll]*[$StrengthMod.Total] --/| Output data --+DoorSize|[&amp;DoorSize] --+Measurement|[&amp;M] --+DoorMaterial|[&amp;DM] --+DoorCondition|[&amp;DoorToughnessBase] --+DoorDC|[$DoorDC.Total] STR check to open --+ToughnessMod|[$ToughnessMod.Total] --+ToughnessBase|[$ToughnessBase.Total] --=DoorToughness|[$ToughnessBase.Total]+[$ToughnessMod.Total] --+DoorToughness|[$DoorToughness.Total] --+HP|[$HP.Total] --+DoorState|[&amp;DS] --+LockClass|[&amp;LC] --+LockToughness|[$LockToughness.Total] --+SpotLock|[&amp;SL] --+SpotLockDC|[$SpotLockDC.Total] --+OpenLock|[&amp;OL] --+OpenLockDC|[$OpenLockDC.Total] --:EndMacro| }}
Everything is working well now that I was able to figure out the code for the HP...... Working on Special &amp; Deadly Doors &amp; of course the traps.....
@DM Scotty - Good deal, nothing like learning to code with all new syntax. @Kurt - I'm using your new 1.6.9 code and the new Object creation logic works well.&nbsp; I've abandoned my attempt to copy the Markdown NPC from that site (still struggling with special characters).&nbsp; Instead, I'm developing a generic NPC Import routine so that I can keep my collection of NPCs stored in a tool like Excel and paste them in using SC with your new logic.&nbsp; The only problem I've run into so far is adding repeating items for things like Traits and Actions.&nbsp; I'm able to create simple traits and actions, with your new functionality to create attributes.&nbsp; However, when I pull up the actual sheet, I can see the new trait, but can't edit or delete it.&nbsp; Must be something behind the scenes that needs to be set but I've not been able to figure it out.&nbsp;&nbsp; --!a:[&amp;MyCharID]|!repeating_npctrait_$[$TCount.Raw]_name:[%1%] Instead I went back to the Chatsetattr and it works --@setattr|_charid [&amp;MyCharID] _repeating_npctrait_-CREATE_name|[%1%] _repeating_npctrait_-CREATE_description|[%2%]
1647733340

Edited 1647733388
Kurt J.
Pro
API Scripter
Will M. said: @DM Scotty - Good deal, nothing like learning to code with all new syntax. @Kurt - I'm using your new 1.6.9 code and the new Object creation logic works well.&nbsp; I've abandoned my attempt to copy the Markdown NPC from that site (still struggling with special characters).&nbsp; Instead, I'm developing a generic NPC Import routine so that I can keep my collection of NPCs stored in a tool like Excel and paste them in using SC with your new logic.&nbsp; The only problem I've run into so far is adding repeating items for things like Traits and Actions.&nbsp; I'm able to create simple traits and actions, with your new functionality to create attributes.&nbsp; However, when I pull up the actual sheet, I can see the new trait, but can't edit or delete it.&nbsp; Must be something behind the scenes that needs to be set but I've not been able to figure it out.&nbsp;&nbsp; --!a:[&amp;MyCharID]|!repeating_npctrait_$[$TCount.Raw]_name:[%1%] Instead I went back to the Chatsetattr and it works --@setattr|_charid [&amp;MyCharID] _repeating_npctrait_-CREATE_name|[%1%] _repeating_npctrait_-CREATE_description|[%2%] I might take up the challenge of parsing the characters created via that generator :) I think I can get around the special characters issues. I'll have to look at how to reliably create repeating attribute items. Probably end up adding a --!r subcommand to do it.
1647734922

Edited 1647735232
I'm making good progress on the script.&nbsp; Character sheet acts kind of weird after adding traits, but I was able to create a populate an NPC sheet with actions, traits, reactions, bonus actions and legendary actions.&nbsp; I'm working on an XLS repository right now that builds a text string that is easily parsed by scriptcards.&nbsp;&nbsp;
1648003019

Edited 1648074127
Well, it's been a long, strange journey reading the 44-pages of this to get a basic handle on ScriptCards.&nbsp; By now it's been said dozens of times, but it bears repeating: tremendous kudos to Kurt for this wonderful tool. First, an observation - the Exit command (--X|) is not documented in the wiki, save for in the video.&nbsp; Secondly a query: i'm having an issue getting character id's to function in the *[ID-] mode.&nbsp; As I want my players to be able to use their macros that access their characters even if they're on a map without a token, I don't want to require a selected token, so I'm trying to hard-code the individual character into each macro.&nbsp; Since I want them to be as portable as possible, I would like to store the ID in a variable or even as the sourceToken, but there aren't a lot of examples here (haven't done the dive into the Working and Sharing thread yet, so mostly I'm using Kurt's old group health macro and a few examples I've found here to go by), and I'm not seeming to have any luck pulling up any traits using that ID.&nbsp; I'm hoping I'm just missing something, but I can't see what it is.&nbsp; As you can see, I've tried a number of variants.&nbsp; Using ScriptCards 1.6.4, only API installed, the character ID is called in the code (and I cut and pasted it), so it's valid, and health is a valid attribute in the character sheet (custom game and custom sheet, but health is simply entered, not calculated, and health is not the only attribute I have tried to retrieve and gotten a null response for).&nbsp; Players-can-ids is set to true, so that's not it either. Code: !scriptcard {{ --#title|Test --#sourceToken|-M4Sxm4pI-UCYHe6s --&amp;char|-M4Sxm4pI-UCYHe6s --+test|@{Xancarlo|character_id} --+test|@{Xancarlo|health} --=SHeal|[*S:health] --+test|[*S:health] --+test|[$SHeal] --+test|[*-M4Sxm4pI-UCYHe6s:health] --=IDHeal|[*-M4Sxm4pI-UCYHe6s:health] --+test|[$IDHeal] --+test|[*[&amp;char]:health] }} Output:
1648307366
Kurt J.
Pro
API Scripter
unverified said: Well, it's been a long, strange journey reading the 44-pages of this to get a basic handle on ScriptCards.&nbsp; By now it's been said dozens of times, but it bears repeating: tremendous kudos to Kurt for this wonderful tool. First, an observation - the Exit command (--X|) is not documented in the wiki, save for in the video.&nbsp; Secondly a query: i'm having an issue getting character id's to function in the *[ID-] mode.&nbsp; As I want my players to be able to use their macros that access their characters even if they're on a map without a token, I don't want to require a selected token, so I'm trying to hard-code the individual character into each macro.&nbsp; Since I want them to be as portable as possible, I would like to store the ID in a variable or even as the sourceToken, but there aren't a lot of examples here (haven't done the dive into the Working and Sharing thread yet, so mostly I'm using Kurt's old group health macro and a few examples I've found here to go by), and I'm not seeming to have any luck pulling up any traits using that ID.&nbsp; I'm hoping I'm just missing something, but I can't see what it is.&nbsp; As you can see, I've tried a number of variants.&nbsp; Using ScriptCards 1.6.4, only API installed, the character ID is called in the code (and I cut and pasted it), so it's valid, and health is a valid attribute in the character sheet (custom game and custom sheet, but health is simply entered, not calculated, and health is not the only attribute I have tried to retrieve and gotten a null response for).&nbsp; Players-can-ids is set to true, so that's not it either. Code: !scriptcard {{ --#title|Test --#sourceToken|-M4Sxm4pI-UCYHe6s --&amp;char|-M4Sxm4pI-UCYHe6s --+test|@{Xancarlo|character_id} --+test|@{Xancarlo|health} --=SHeal|[*S:health] --+test|[*S:health] --+test|[$SHeal] --+test|[*-M4Sxm4pI-UCYHe6s:health] --=IDHeal|[*-M4Sxm4pI-UCYHe6s:health] --+test|[$IDHeal] --+test|[*[&amp;char]:health] }} Output: @unverified : I'd be interested to see the HTML of the character sheet for the attributes. I don't really know much about custom sheet development, though. Using the 5E sheet I wasn't able to duplicate this issue :(
1648307575
Kurt J.
Pro
API Scripter
ScriptCards v 1.7.0 has been pushed to the GitHub Repo Allowed VS Code to format the script. Cleans up so bad spacing and indents, etc. New : Expanded the suffixes that can be used with dice rolls. There are a total of six new roll modifiers: .RollCount (The number of dice rolled), .KeptCount (The number of dice that were kept with the roll), .DroppedCound (The number of dice that were dropped from the roll). There are corresponding suffixes to retrieve the rolls themselves: .RolledDice(index), .KeptDice(index), and .DroppedDice(index). The index is a 1-based value for the die number in the list. Here is a quick example: !script {{ &nbsp; --=Roll|10d12kh8 &nbsp; --+Roll|[$Roll] &nbsp; --+RollCount|[$Roll.RollCount] &nbsp; --%die|1;[$Roll.RollCount] &nbsp; &nbsp; --+Roll [&amp;die]|[$Roll.RolledDice([&amp;die])] &nbsp; --%| &nbsp; --+KeptCount|[$Roll.KeptCount] &nbsp; --%die|1;[$Roll.KeptCount] &nbsp; &nbsp; --+Kept [&amp;die]|[$Roll.KeptDice([&amp;die])] &nbsp; --%| &nbsp; --+DroppedCount|[$Roll.DroppedCount] &nbsp; --%die|1;[$Roll.DroppedCount] &nbsp; &nbsp; --+Dropped [&amp;die]|[$Roll.DroppedDice([&amp;die])] &nbsp; --%| }} This rolls 10d12, keeping the top 8 and then displays information about the rolls themselves. If a roll variable contains multiple components (ie, 2d20kl1+1d4) all of the dice values will be included in the lists (so the RolledDice would contain 3 entries (2 for the d20 and 1 for the d4). The KeptDice would contains 2 entries (one for the d20 and one for the d4) and the DroppedDice would contain 1 entry (one for the d20). If a roll does not include a kh or kl clause, all of the dice will be in both the RolledDice and the KeptDice, while the DroppedDice will be empty
1648316939

Edited 1648388077
@Kurt: Thank you for the response.&nbsp; I was really hoping there was a syntax error I was missing.&nbsp; I noted at one point you mentioned that there were problems with the 4E-D&amp;D sheet caused by the presence of the floor() command in an attribute, and was worried it was something similar (don't use floor(), but I do use ceil() to calculate modifiers - use what is effectively the OSR attribute mods as a base, so they're based on a bell curve, not a flat progression), but was hoping since none of the attributes being called involved the calculated attributes that that wasn't the issue.&nbsp; Any suggestions on what to avoid specifically in the html of a character sheet to avoid issues?&nbsp; Might help cut down on my trial-and-error testing as I redesign the character sheet to make it compatible. EDIT: On further testing (after creating a Test Bed game and playing with truncated character sheets), then checking another character on the original game, the problem is character-specific.&nbsp; I'm guessing it's not properly parsing the hyphen in the character ID?&nbsp; STRANGER DEVELOPMENTS: Problem still character-specific, having no problem using the character id's of any other characters - including other characters with a hyphen in their character id!!!&nbsp; Have used different macros to pull the id, and cut and paste it into new test macros.&nbsp; ScriptCards, the API, and/or Roll20 apparently just doesn't like that one character id.&nbsp; I have no idea why - the only thing I can think of is - despite the fact that it is (afaik) explicitly not supposed to happen - is that the full id had a whitespace character at the end somehow due to some internal hiccup or something. FINAL UPDATE: Copied the character, new version with the new id works perfectly.&nbsp; Came across another bad id - one that kept the following line of the ScriptCards script from running!&nbsp; (-MwYgzNCxNS-7-tv2Gr, at least for the visible characters; I'm really starting to suspect that some of these character ids have hinky characters at the end that aren't displaying).&nbsp; Ran the same test macro on a copy and it worked fine again.
I'm Trying to get the output of this to produce: a total for the amount &amp; item and to show up in altogether.... example output would be the following: 2 iron cooking pot, 1 Giant Size Comb, 4 small bags of salt.... etc. any suggestions? !scriptcard {{ &nbsp; --#title|Giant's Bag &nbsp; --#titlecardbackground|#606c9b &nbsp; --#leftsub|What's in &nbsp; --#rightsub|the Giant's Bag &nbsp; --&gt;GetImage|[%1%] &nbsp; --/|CARD &nbsp; --+|[&amp;Image] &nbsp; --+|[img]<a href="https://static2.srcdn.com/wordpress/wp-content/uploads/2020/10/Dungeons-And-Dragons-Stone-Giant.jpg[/img]" rel="nofollow">https://static2.srcdn.com/wordpress/wp-content/uploads/2020/10/Dungeons-And-Dragons-Stone-Giant.jpg[/img]</a> &nbsp; &nbsp; --&lt;| &nbsp; --#debug|1 &nbsp; &nbsp; --+|[b]You find the following items in the Giant's Bag..[/b] &nbsp; &nbsp; &nbsp; &nbsp; --%LoopCounter|1;7 &nbsp; &nbsp;&nbsp; --=R1|1d4 &nbsp;&nbsp; --=R2|1d6 &nbsp;&nbsp; --=R3|1d8 &nbsp;&nbsp; --=R4|1d10 &nbsp; &nbsp;&nbsp;&nbsp; --=MatRoll|1d12 &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 1|&amp;A;[$R1] Handaxe blade (used as a hand chopper) &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 2|&amp;A;[$R1] Dented metal helm (used as a bowl) &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 3|&amp;A;[$R1]Giant-sized shabby cloak (wool or hide) &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 4|&amp;A;[$R1]Giant-sized bone comb &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 5|&amp;A;[$R1]Iron cooking pot &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 6|&amp;A;[$R1]Giant-sized drinking horn &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 7|&amp;A;[$R1]Giant-sized skinning knife &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 8|&amp;A;[$R1]Haunch of meat &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 9|&amp;A;[$R1]Mangy fur pelt &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 10|&amp;A;[$R1]Small bag of salt &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 11|&amp;A;[$R1]Giant-sized pair of old sandals &nbsp;&nbsp;&nbsp; --?[$MatRoll] -eq 12|&amp;A;[$R1]Giant-sized waterskin (full) &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; --&gt;Total| &nbsp; &nbsp;&nbsp;&nbsp; --%| &nbsp;&nbsp;&nbsp; --X| &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; --:Total| &nbsp;&nbsp;&nbsp; --=Bag|[&amp;A] &nbsp; &nbsp;&nbsp;&nbsp; --&gt;Result| &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; --:Result| &nbsp; &nbsp;&nbsp;&nbsp; --+|[$Bag.Total] &nbsp; --&lt;| &nbsp; &nbsp; }}
@Kurt: If you're interested in my experiences with the bad ids when hard-coding them (using the direct id label into the sourceToken, ultimately, so I only need the one change for the macro to work for the character even without having to select the token), the final prognosis is that I had 3 characters with bad ids out of the 43 (well, 46 if you include the working copies made to replace the three bad ones) characters I tested.&nbsp; That seems sufficiently common to be repeatable if this is an issue you're that concerned with (I can't imagine my usage is unique, but I recognize it is an outlier concern and it may be simpler to note in the wiki that bad ids exist, and that copying the character to get a new id is a viable workaround).&nbsp; Two of the bad ids prevented the following line from displaying when encountered (but not the original) with the following id-gathering macro: !scriptcard {{ --#title|Test --+test|@{Zamora|character_id} --+id|-Mxeoc1-Ki1RSd4S7JOl }} The two bad ids that caused the line skip (or terminated the script early; I didn't test further) output the test line, but not the following id line.&nbsp; All of the bad ids otherwise generated null values when used as sourceToken. (I actually updated the macro with each character; I kept the test macro - with the correct id once retrieved - as a reference for cut and past operations later, which is why the follow-up line is a hard-coded repeat of the id)
I'm Trying to get the output of this to produce: a total for the amount &amp; item and to show up in altogether.... example output would be the following: 2 iron cooking pot, 1 Giant Size Comb, 4 small bags of salt.... etc. any suggestions?
!scriptcard {{ --#title|Giant's Bag --#titlecardbackground|#606c9b --#leftsub|What's in --#rightsub|the Giant's Bag --&gt;GetImage|[%1%] --/|CARD --+|[&amp;Image] --+|[img]<a href="https://static2.srcdn.com/wordpress/wp-content/uploads/2020/10/Dungeons-And-Dragons-Stone-Giant.jpg[/img]" rel="nofollow">https://static2.srcdn.com/wordpress/wp-content/uploads/2020/10/Dungeons-And-Dragons-Stone-Giant.jpg[/img]</a> --&lt;| --#debug|1 --+|[b]You find the following items in the Giant's Bag..[/b] --%LoopCounter|1;7 --=R1|1d4 --=R2|1d6 --=R3|1d8 --=R4|1d10 --=MatRoll|1d12 --?[$MatRoll] -eq 1|&amp;A;[$R1] Handaxe blade (used as a hand chopper) --?[$MatRoll] -eq 2|&amp;A;[$R1] Dented metal helm (used as a bowl) --?[$MatRoll] -eq 3|&amp;A;[$R1]Giant-sized shabby cloak (wool or hide) --?[$MatRoll] -eq 4|&amp;A;[$R1]Giant-sized bone comb --?[$MatRoll] -eq 5|&amp;A;[$R1]Iron cooking pot --?[$MatRoll] -eq 6|&amp;A;[$R1]Giant-sized drinking horn --?[$MatRoll] -eq 7|&amp;A;[$R1]Giant-sized skinning knife --?[$MatRoll] -eq 8|&amp;A;[$R1]Haunch of meat --?[$MatRoll] -eq 9|&amp;A;[$R1]Mangy fur pelt --?[$MatRoll] -eq 10|&amp;A;[$R1]Small bag of salt --?[$MatRoll] -eq 11|&amp;A;[$R1]Giant-sized pair of old sandals --?[$MatRoll] -eq 12|&amp;A;[$R1]Giant-sized waterskin (full) --&gt;Result| --%| --X| --:Result| --+|[&amp;A] --&lt;| }}
Here is the current card... I'm trying to get it to group &amp; tally all the rolls together.....&nbsp; Total # of the item with the item rolled (then a Comma,) total # of the item with the next item, (and so on) Currently it is showing each result on separate lines and showing duplicates without totaling.... How would I get it to do the output I want it to do?
1648407198

Edited 1648409228
Found some anomalous behavior with the {ROUND} command.&nbsp; I'm running the following test code: !scriptcard {{ --=test|7 + -6 / 10000 {ROUND 4} --=test2|4 / 100 {ROUND 2} + [$test] --+test|[R][$test][/R] --+test2|[R][$test2][/R] }} And I'm getting this as a result: Strange.&nbsp; Never mind.&nbsp; Missing the colon.
1648415262
David M.
Pro
API Scripter
DM Scotty, this should get you started. Created an enumerated list of unique item types and matching counts. Increments qty based on the index rolled. Builds comma-separated list for display. !scriptcard {{ --#debug|1 --#title|Giant's Bag --#titlecardbackground|#606c9b --#leftsub|What's in --#rightsub|the Giant's Bag --DISPLAY IMAGE| --+|[&amp;Image] --+|[img]<a href="https://static2.srcdn.com/wordpress/wp-content/uploads/2020/10/Dungeons-And-Dragons-Stone-Giant.jpg[/img]" rel="nofollow">https://static2.srcdn.com/wordpress/wp-content/uploads/2020/10/Dungeons-And-Dragons-Stone-Giant.jpg[/img]</a> --:ENUMERATE ITEM DESCRIPTIONS| --&amp;item1|Handaxe blade (used as a hand chopper) --&amp;item2|Dented metal helm (used as a bowl) --&amp;item3|Giant-sized shabby cloak (wool or hide) --&amp;item4|Giant-sized bone comb --&amp;item5|Iron cooking pot --&amp;item6|Giant-sized drinking horn --&amp;item7|Giant-sized skinning knife --&amp;item8|Haunch of meat --&amp;item9|Mangy fur pelt --&amp;item10|Small bag of salt --&amp;item11|Giant-sized pair of old sandals --&amp;item12|Giant-sized waterskin (full) --=numUniqueTypes|12 --:INITIALIZE ITEM COUNTS| --%LoopCounter|1;[$numUniqueTypes.Raw] --=count[&amp;LoopCounter]|0 --%| --:LOOP THROUGH numRolls TO START ADDING ITEMS --=numRolls|12 --%LoopCounter|1;[$numRolls.Raw] --=R1|1d4 --=R2|1d6 --=R3|1d8 --=R4|1d10 --=MatRoll|1d12 --:NOTE - ONLY USING R1 HERE, BUT YOU COULD ADD CONDITIONALS FOR DIFFERENT ROLLS, CALLING SAME FUNCTION --&gt;AddItems|[$MatRoll.Raw];[$R1.Raw] --%| --:BUILD COMMA-SEPARATED LIST| --&amp;displayString| --%LoopCounter|1;[$numUniqueTypes.Raw] --?[$count[&amp;LoopCounter]] -gt 0|[ --&amp;displayString|+ [&amp;item[&amp;LoopCounter]] x[$count[&amp;LoopCounter].Raw], --]| --%| --:CLEANUP TRAILING COMMA IN THE LIST STRING --~stringLength|string;length;[&amp;displayString] --=numCharsToKeep|[$stringLength] - 1 --~displayString|string;substring;1;[$numCharsToKeep];[&amp;displayString] --:DISPLAY RESULTS| --+|[b]You find the following items in the Giant's Bag..[/b] --+|[&amp;displayString] --X| End Macro --:FUNCTIONS| --:AddItems| accepts the item index and qty. Increments the count of index [%1%] by qty [%2%] --=count[%1%]|[$count[%1%]] + [%2%] --&lt;| }}
@Scotty: right now your loop is printing the output as it is generated, which means you can't apply that kind of formatting.&nbsp; What I would suggest is making a couple of 12-item arrays (or, if you want to get sophisticated, a variable-size array that gets its size from a data list), one to hold the total count of each possible item, and one to hold the string for that item's name.&nbsp; Once you finish the generation loop (which populates the numbers from the array, but I suggest initializing each to 0 before hand) - for which you need to add to the existing item total - you then jump to the display loop. The display loop runs for 12 iterations (or the size of your table), and creates a long string containing each total variable, the character string (which has a comma appended); it makes a check for a 0-item total count and jumps ahead to the next item when encountering zeros.&nbsp; Once you've completed the loop, use a the string manipulation commands to remove the last character (a comma) and append a period instead.&nbsp; Only then do you actually output your data.
1648423661

Edited 1648423724
Kurt J.
Pro
API Scripter
ScriptCards 1.7.1 has been pushed to the GitHub Repo New : ScriptCards now supports its own inline rolling syntax. This is done in the same way that a variable is referenced with a new identifier. Anywhere you could display the contents of a variable you can now include an inline roll: Example: &nbsp; --+Goblins|[=1d6] goblins leap from the bushes to attack! You can also store the result of the roll in a roll variable by prefixing the roll with a variable name followed by a colon: &nbsp; --+Goblins|[=GoblinCount:1d6] goblins leap from the bushes to attack! Some notes: The ".Raw" equivalent of the result will be returned inline as the replacement for the [=...] construct. Currently, inline roll variables support a subset of the full ScriptCards roll syntax. The important points are: At the moment, only addition (+) and subtraction (-) of roll components are supported, so [=1d20 + 5] will be fine, but [=1d20 * 5] will just return the string inside the [ ]. Brackets are not supported inside the roll string, but parenthesis are, so [=1d20 + 5 (STR)] is ok, but [=1d20 + 5 [STR]] will fail. All of the various dice formats are supported for inline rolls (keep highest, keep lowest, wild dice, etc.)&nbsp; As with other ScriptCards commands, this is not &nbsp;processed by the chat server, so every time the statement gets evaluated the roll will be repeated.
1648423821
Kurt J.
Pro
API Scripter
DM Scotty said: Here is the current card... I'm trying to get it to group &amp; tally all the rolls together.....&nbsp; Total # of the item with the item rolled (then a Comma,) total # of the item with the next item, (and so on) Currently it is showing each result on separate lines and showing duplicates without totaling.... How would I get it to do the output I want it to do? Just a quick note (you may already know this) but if you use leftsub or rightsub without the other value being set, the subtitle will be centered under the title without the separator.
@David, thanks for your assistance!!! @Unverified.......... I'm still learning, so I don't completely understand without seeing an example... Pardon my lack of coding experience... So, I have another question with images..... Is there a better way to store more than one image and then call for a specific image to show on the card.. I've tried with the code below but it is not working... !scriptcard {{ --#debug|1 --#title|?{Name of Shop?|} --#titlecardbackground|#606c9b --#leftsub|?{Type of Shop?|Adventure|Arcane|Blacksmith|General|Jeweler &amp; Stonecutter|Leatherworker|Magic|Merchant|Potion|Stable &amp; Farm|Temple &amp; Faith|Woodworker &amp; Bowyer} --#rightsub|Shop --#bodyFontSize|12px --IMAGE SELECTION| --:Image Selection| --Selection|[#leftsub] --=Selection|[%1%] --?"[#leftsub]" -eq "Adventure"|&amp;WS; --?"[#leftsub]" -eq "Arcane"|&amp;WS; --?"[#leftsub]" -eq "Blacksmith"|&amp;WS;<a href="https://i.pinimg.com/originals/8f/e4/72/8fe47283864b4bbeba9c21b20964f38b.jpg" rel="nofollow">https://i.pinimg.com/originals/8f/e4/72/8fe47283864b4bbeba9c21b20964f38b.jpg</a> --?"[#leftsub]" -eq "General"|&amp;WS; --?"[#leftsub]" -eq "Jeweler &amp; Stonecutter"|&amp;WS; --?"[#leftsub]" -eq "Leatherworker"|&amp;WS; --?"[#leftsub]" -eq "Merchant"|&amp;WS; --?"[#leftsub]" -eq "Potion"|&amp;WS;<a href="https://www.wargamer.com/wp-content/uploads/2021/06/dnd-rogue-poisoners-workshop.jpg" rel="nofollow">https://www.wargamer.com/wp-content/uploads/2021/06/dnd-rogue-poisoners-workshop.jpg</a> --?"[#leftsub]" -eq "Stable &amp; Farm"|&amp;WS; --?"[#leftsub]" -eq "Temple &amp; Faith"|&amp;WS; --?"[#leftsub]" -eq "Woodworker &amp; Bowyer"|&amp;WS; --:EndImage| --DISPLAY IMAGE| --+|[&amp;Image] --+|[img][&amp;WS][/img]
1648435494

Edited 1648435643
@Kurt..... thanks for the left/right sub tip!! &amp; a big thanks for Inline Rolls!!! This is huge for what I'm working on!!
1648467305

Edited 1648467322
David M.
Pro
API Scripter
DM Scotty, you can't use [#leftsub] as a variable that way. Try this. Assigned a string variable shopType below which is used to set leftsub and used for conditionals. I'm assuming you will be filling this out with more images as well? Otherwise all the other conditionals are not needed. Also, you were missing colons before your line labels (so --:TEXT instead of just --TEXT). Actually, there is dedicated comment syntax of --/TEXT, but I always seem to forget about it because it's newer and I learned it the other way ;) !scriptcard {{ --#debug|1 --#title|?{Name of Shop?|} --#titlecardbackground|#606c9b --#rightsub|Shop --#bodyFontSize|12px --&amp;shopType|?{Type of Shop?|Adventure|Arcane|Blacksmith|General|Jeweler &amp; Stonecutter|Leatherworker|Magic|Merchant|Potion|Stable &amp; Farm|Temple &amp; Faith|Woodworker &amp; Bowyer} --#leftsub|[&amp;shopType] --:IMAGE SELECTION| --:Image Selection| --?"[&amp;shopType]" -eq "Adventure"|&amp;WS; --?"[&amp;shopType]" -eq "Arcane"|&amp;WS; --?"[&amp;shopType]" -eq "Blacksmith"|&amp;WS;<a href="https://i.pinimg.com/originals/8f/e4/72/8fe47283864b4bbeba9c21b20964f38b.jpg" rel="nofollow">https://i.pinimg.com/originals/8f/e4/72/8fe47283864b4bbeba9c21b20964f38b.jpg</a> --?"[&amp;shopType]" -eq "General"|&amp;WS; --?"[&amp;shopType]" -eq "Jeweler &amp; Stonecutter"|&amp;WS; --?"[&amp;shopType]" -eq "Leatherworker"|&amp;WS; --?"[&amp;shopType]" -eq "Merchant"|&amp;WS; --?"[&amp;shopType]" -eq "Potion"|&amp;WS;<a href="https://www.wargamer.com/wp-content/uploads/2021/06/dnd-rogue-poisoners-workshop.jpg" rel="nofollow">https://www.wargamer.com/wp-content/uploads/2021/06/dnd-rogue-poisoners-workshop.jpg</a> --?"[&amp;shopType]" -eq "Stable &amp; Farm"|&amp;WS; --?"[&amp;shopType]" -eq "Temple &amp; Faith"|&amp;WS; --?"[&amp;shopType]" -eq "Woodworker &amp; Bowyer"|&amp;WS; --:EndImage| --:DISPLAY IMAGE| --+|[img][&amp;WS][/img] }} Finally, I'm not sure what these two lines were for, so I removed them. I'm guessing they were left in from some previous testing. --Selection|[#leftsub] --=Selection|[%1%]
1648487188
Kurt J.
Pro
API Scripter
David M. said: DM Scotty, you can't use [#leftsub] as a variable that way. Try this. Assigned a string variable shopType below which is used to set leftsub and used for conditionals. I'm assuming you will be filling this out with more images as well? Otherwise all the other conditionals are not needed. Also, you were missing colons before your line labels (so --:TEXT instead of just --TEXT). Actually, there is dedicated comment syntax of --/TEXT, but I always seem to forget about it because it's newer and I learned it the other way ;) !scriptcard {{ --#debug|1 --#title|?{Name of Shop?|} --#titlecardbackground|#606c9b --#rightsub|Shop --#bodyFontSize|12px --&amp;shopType|?{Type of Shop?|Adventure|Arcane|Blacksmith|General|Jeweler &amp; Stonecutter|Leatherworker|Magic|Merchant|Potion|Stable &amp; Farm|Temple &amp; Faith|Woodworker &amp; Bowyer} --#leftsub|[&amp;shopType] --:IMAGE SELECTION| --:Image Selection| --?"[&amp;shopType]" -eq "Adventure"|&amp;WS; --?"[&amp;shopType]" -eq "Arcane"|&amp;WS; --?"[&amp;shopType]" -eq "Blacksmith"|&amp;WS;<a href="https://i.pinimg.com/originals/8f/e4/72/8fe47283864b4bbeba9c21b20964f38b.jpg" rel="nofollow">https://i.pinimg.com/originals/8f/e4/72/8fe47283864b4bbeba9c21b20964f38b.jpg</a> --?"[&amp;shopType]" -eq "General"|&amp;WS; --?"[&amp;shopType]" -eq "Jeweler &amp; Stonecutter"|&amp;WS; --?"[&amp;shopType]" -eq "Leatherworker"|&amp;WS; --?"[&amp;shopType]" -eq "Merchant"|&amp;WS; --?"[&amp;shopType]" -eq "Potion"|&amp;WS;<a href="https://www.wargamer.com/wp-content/uploads/2021/06/dnd-rogue-poisoners-workshop.jpg" rel="nofollow">https://www.wargamer.com/wp-content/uploads/2021/06/dnd-rogue-poisoners-workshop.jpg</a> --?"[&amp;shopType]" -eq "Stable &amp; Farm"|&amp;WS; --?"[&amp;shopType]" -eq "Temple &amp; Faith"|&amp;WS; --?"[&amp;shopType]" -eq "Woodworker &amp; Bowyer"|&amp;WS; --:EndImage| --:DISPLAY IMAGE| --+|[img][&amp;WS][/img] }} Finally, I'm not sure what these two lines were for, so I removed them. I'm guessing they were left in from some previous testing. --Selection|[#leftsub] --=Selection|[%1%] Correct. The ability to reference settings with [#settingname] was briefly in the code, but I had to remove it, as it was interfering with the colorization formatting ([#rrggbb], etc.) It will probably return in the near future when I settle on an appropriate prefix for the variable access :) I'm running out of easy symbols though :)
Discovered an anomaly while writing a Thrown Weapons script; apparently, having a "T" or "t" as the initial character in a bracketed dice roll notation prevents the notation from displaying in the roll results...&nbsp; (and also, it seems apostrophes break the whole roll...) !scriptcard {{ --=dice|1d20 + 3 [control] + 4 [Test] + 1 [control 2] + 3 [t doesnt work either] --+Roll|[$dice] }} output: The garbage at the top is the result of leaving the apostrophe in doesn't (was using 'e' as my control for those); the apostrophes causing the results to go wonky is not limited to the entries that begin with 'T' or 't.'
1648511299

Edited 1648511425
@David &amp; Kurt, thanks for the help!! It makes sense now that I see how it is supposed to be done..... Thanks again!!
1648512660

Edited 1648513102
Kurt J.
Pro
API Scripter
**ScriptCards 1.7.2** has been pushed to the GitHub Repo Thanks to @unverified for finding this one :) - Bug Fix: Flavor text in rolls (ie, [BLESS]) was not visible in a hover-over if the text started with [T or [t because the inline formatter was thinking it should be creating a table tag in its place. This has been fixed. Currently, flavor text of [p], [br], or [hr] will still be invisible like this, but those will be corrected in the next update. (I ninja-updated 1.7.2 to include the fix for all types of flavor text)
I had a twitchy thought.&nbsp; While you can't pass a parameter to a macro directly, there's nothing that says you can't have a "parameter mule" store parameters in attributes as long as the receiving macro knows to look for them.&nbsp; While this is somewhat limited (either each player needs their own mule, or at least set of macros, to keep them from "stealing" each others' parameters if they fire their macros off simultaneously), it could still be of use for GM tools without having to use reentrant data.&nbsp; It's not likely anything I will play with in the immediate future, but I figured sharing the idea might spark some mad insights.
1648759146

Edited 1648759393
In this code I end up getting X+1 button prompts where X is the number of items in the repeating attribute.&nbsp; &nbsp;What am I missing? I am only getting the --+Debug line once so I know something else in an other part of the code isn't sending me back to this sub twice. --:Commlink| --+Debug|Commlink --Rfirst|@{selected|character_id};repeating_commlinks --&amp;Commlinks| --:ChooseCommlinkLoop| --+Debug|[*R:commlink-name] --?"[*R:commlink-name]" -eq NoRepeatingAttributeLoaded|DoneChooseCommlink --&amp;Commlinks|[&amp;Commlinks]|[*R:commlink-name] --Rnext| --&gt;ChooseCommlinkLoop| --:DoneChooseCommlink| --/Commlinks|[&amp;Commlinks] --IChooseDevice;Enter|q;device;Which Device are you using?[&amp;Commlinks] --Rfind|[*S:character_id];[&amp;device];repeating_commlinks;commlink-name --=Data|[*R:commlink-data] --=Firewall|[*R:commlink-firewall] --&lt;|
1648767128

Edited 1648848426
More data on the bad character ids; i found another, so I ran a debug code on it and the one that I kept from before.&nbsp; This one wasn't a surprise; it only returned a six character id (!); after looking at the debug, I suspect it might be excess hyphens at the end or double-hyphens in the middle of the id that are causing the issue, which I suspect there's nothing to be done for it, but here's images of the code and the debug for each of the two characters with bad ids. First Example (which I suspect might have a double hyphen in the middle of the real id): Since it's throwing a "Line 6 is missing a | character" and line six is "}}" i think a double hyphen in the id is the likeliest culprit in this case; either way, the id is obviously truncated by *something*. Second Example (which I suspect ends in a hyphen): Since the debug is showing "Tag:-+test2," i suspect a hyphen at the end of the id is the culprit in this one; turning the actual --+ into ---+ and invalidating the next line. I did verify that the test code is otherwise working as expected (and debug is happy with it) on a valid character id.&nbsp; I don't suspect there's any way to avoid the double-hyphen id pitfall (I think a similar instance cropped up early in the chat record for a bad token id, once, iirc), but not sure if a single terminal hyphen id might be something that could be addressed - assuming I'm right about what's causing the bad ids. EDIT: Ran a second test on the second one where I added more text on the test1 line (a simple " test") and I can confirm for a fact that the id ends in a hyphen, and that *is* what is causing the issue with the missing line.&nbsp;
1648860265

Edited 1648860388
Kurt J.
Pro
API Scripter
unverified said: More data on the bad character ids; i found another, so I ran a debug code on it and the one that I kept from before.&nbsp; This one wasn't a surprise; it only returned a six character id (!); after looking at the debug, I suspect it might be excess hyphens at the end or double-hyphens in the middle of the id that are causing the issue, which I suspect there's nothing to be done for it, but here's images of the code and the debug for each of the two characters with bad ids. First Example (which I suspect might have a double hyphen in the middle of the real id): Since it's throwing a "Line 6 is missing a | character" and line six is "}}" i think a double hyphen in the id is the likeliest culprit in this case; either way, the id is obviously truncated by *something*. Second Example (which I suspect ends in a hyphen): Since the debug is showing "Tag:-+test2," i suspect a hyphen at the end of the id is the culprit in this one; turning the actual --+ into ---+ and invalidating the next line. I did verify that the test code is otherwise working as expected (and debug is happy with it) on a valid character id.&nbsp; I don't suspect there's any way to avoid the double-hyphen id pitfall (I think a similar instance cropped up early in the chat record for a bad token id, once, iirc), but not sure if a single terminal hyphen id might be something that could be addressed - assuming I'm right about what's causing the bad ids. EDIT: Ran a second test on the second one where I added more text on the test1 line (a simple " test") and I can confirm for a fact that the id ends in a hyphen, and that *is* what is causing the issue with the missing line.&nbsp; I was finally able to duplicate the second scenario - where an ID ends with a dash (-). I wasn't able to get it to happen before because I always indent the lines between !script{{ and }}. When the text gets processed, all linebreaks are removed from it, so: --+Test1|SomethingThatEndsWith- --+Test2|SomethingElse becomes: --+Test1|SomethingThatEndsWith---+Test2|SomethingElse and the first two dashes in the triple dash are treated as a new line marker. That can be worked around immediately without changes by putting at least one space before the -- characters on each line. The code-based fix for that should be a fairly straightforward... I just need to test it with a lot of stuff to make sure it doesn't break anything else. IDs unfortunate enough to contain two dashes in a row are going to be harder :)
@Kurt: amusingly, for all of my real scripts I do indent, I just didn't for the id grab and the tests based off of it, 'cause they were just a couple of lines thrown together.&nbsp; Definitely adding the indents in the id grabs now, at least for the new ones.
I am having a little issue with the code below and can't seem to figure out how to fix the issue... Currently I can choose the # of times to roll, however it doesn't always give me the number of items per the amount selected... It seems to just remove it.... I'm guessing it's removing duplicates instead of rerolling or replacing the duplicates... In which, i'm not sure how to have it reroll or replace duplicates... If I select 20 items to be in the wagon.... and all different... I want it to show 20 different items in the string... See Below for the current code: !scriptcard {{ --#debug|1 --#title|What's In? --#titlecardbackground|#606c9b --#leftsub|The Wagon --&amp;numRolls|?{How Many Items?|} --:ENUMERATE ITEM DESCRIPTIONS| --&amp;item1|Square silver coin with a serpent design --&amp;item2|Hempen Rope (100’) --&amp;item3|Map to a dungeon --&amp;item4|Silver pieces --&amp;item5|Crate of longswords --&amp;item6|Prisoner --&amp;item7|Chain (12’) --&amp;item8|Wolf pelts --&amp;item9|Dead Goblin --&amp;item10|Crate of short swords --&amp;item11|Bear pelts --&amp;item12|Crate of cookware --&amp;item13|Wolf in a cage --&amp;item14|Jugs of rum --&amp;item15|Beaver pelts --&amp;item16|Leather (1’ x 5’) --&amp;item17|Gloves --&amp;item18|Barrels --&amp;item19|Wax sealed letter --&amp;item20|Crate of daggers --&amp;item21|Canvas (3’ x 6’) --&amp;item22|Dead dwarf --&amp;item23|Bottles of oil --&amp;item24|Dead halfling --&amp;item25|Workman's hat --&amp;item26|Gold pieces --&amp;item27|Burlap bags --&amp;item28|Books --&amp;item29|Leather armor --&amp;item30|Wolf pelts --&amp;item31|Detailed map of a nearby town --&amp;item32|Gold piece from a legendary Kingdom --&amp;item33|Bottles of whiskey --&amp;item34|Sacks of seeds --&amp;item35|Crates of Vellum --&amp;item36|Jars of fruit --&amp;item37|Tanned goat hides --&amp;item38|Crate of vases --&amp;item39|Arrowhead with an “S” on it --&amp;item40|Basket of eagle feathers --&amp;item41|Dead elf --&amp;item42|Plate armor --&amp;item43|Weasel pelts --&amp;item44|Mink pelts --&amp;item45|Straw bales --&amp;item46|Metal chest --&amp;item47|Small feather made of gold --&amp;item48|Hidden child --&amp;item49|Dead falcon --&amp;item50|Hempen Rope (50’) --&amp;item51|Bundles of Wool --&amp;item52|Barrels --&amp;item53|Books --&amp;item54|Copper pieces --&amp;item55|Sacks of wheat --&amp;item56|Great sword --&amp;item57|Deed to a farm --&amp;item58|Vegetables --&amp;item59|Tanned cow hides --&amp;item60|Hidden note --&amp;item61|Hay bale --&amp;item62|Broken porcelain dishes --&amp;item63|Rabbit pelts --&amp;item64|Dead body --&amp;item65|Plate armor --&amp;item66|Wagon Wheel --&amp;item67|Crate of lanterns --&amp;item68|Sacks of flour --&amp;item69|Leather (2’ x 4’) --&amp;item70|Elf in a cage --&amp;item71|Deed to a mine claim --&amp;item72|Pieces of Fruit --&amp;item73|Burned body --&amp;item74|Sacks of sugar --&amp;item75|Boards of Lumber --&amp;item76|Crate of formal clothing --&amp;item77|Dagger made of some black material --&amp;item78|Bottles of wine --&amp;item79|Wolf pelts --&amp;item80|Human in a cage --&amp;item81|Crate of common clothing --&amp;item82|Land claim --&amp;item83|Dead orc --&amp;item84|Locked wooden chest --&amp;item85|Boards of Lumber --&amp;item86|Firewood --&amp;item87|Mountain lion in a cage --&amp;item88|Sacks of grain --&amp;item89|Crate of tin cups --&amp;item90|Coyote pelts --&amp;item91|Crates of parchment --&amp;item92|Pots and pans --&amp;item93|Piece torn from a formal women's dress --&amp;item94|Dead goat --&amp;item95|Chainmail --&amp;item96|Beaver pelts --&amp;item97|Partially burned foreign flag --&amp;item98|Basket of hawk feathers --&amp;item99|Stack of letters bound with crimson ribbon --&amp;item100|Canvas (4’ x 4’) --&amp;item101|Empty sacks --&amp;item102|Flint and Tinder --&amp;item103|Shovels, Miners Picks, Hammers --&amp;item104|Mound of Hay --&amp;item105|Wagon Wheels --&amp;item106|Animal Dung --&amp;item107|Pile of dirt --&amp;item108|A wooden casket --&amp;item109|Hunting traps --&amp;item110|(10 ft.) Chains --&amp;item111|Waterskins --&amp;item112|Torches --&amp;item113|Rakes, Shovels, Pitchforks, Hoes --&amp;item114|A small bag of Tobacco --&amp;item115|Iron box --&amp;item116|Jars of pickled eggs --&amp;item117|Dead Deer --&amp;item118|Blankets --&amp;item119|Wooden Boxes of Nails --&amp;item120|Fox Pelts --&amp;item121|Large Rocks --=numUniqueTypes|121 --:INITIALIZE ITEM COUNTS| --%LoopCounter|1;[$numUniqueTypes.Raw] --=count[&amp;LoopCounter]|0 --%| --:LOOP THROUGH numRolls TO START ADDING ITEMS --%LoopCounter|1;[&amp;numRolls] --=R1|1d4 --=MatRoll|1d12 --:NOTE - ONLY USING R1 HERE, BUT YOU COULD ADD CONDITIONALS FOR DIFFERENT ROLLS, CALLING SAME FUNCTION --&gt;AddItems|[$MatRoll.Raw] --%| --:BUILD COMMA-SEPARATED LIST| --&amp;displayString| --%LoopCounter|1;[$numUniqueTypes.Raw] --?[$count[&amp;LoopCounter]] -gt 0|[ --&amp;displayString|+ [&amp;item[&amp;LoopCounter]], --]| --%| --:CLEANUP TRAILING COMMA IN THE LIST STRING --~stringLength|string;length;[&amp;displayString] --=numCharsToKeep|[$stringLength] - 1 --~displayString|string;substring;1;[$numCharsToKeep];[&amp;displayString] --:DISPLAY RESULTS| --+|[b]You find the following items in the Giant's Bag..[/b] --+|[&amp;displayString] --X| End Macro --:FUNCTIONS| --:AddItems| accepts the item index --=count[%1%]|[%1%] --&lt;| }}
1649073909
Kurt J.
Pro
API Scripter
@DM Scotty - Here are two different options depending on what you want to do. (I left out the beginning, so this just replaces a few lines in the code after the item list is generated: --:INITIALIZE ITEM COUNTS| --%LoopCounter|1;[$numUniqueTypes.Raw] --=count[&amp;LoopCounter]|0 --%| --/|LOOP THROUGH numRolls TO START ADDING ITEMS --%LoopCounter|1;[&amp;numRolls] --=R1|1d4 --=MatRoll|1d[$numUniqueTypes.Raw] --&gt;AddItems|[$MatRoll.Raw];[$R1.Raw] --%| --:BUILD COMMA-SEPARATED LIST| --&amp;displayString| --%LoopCounter|1;[$numUniqueTypes.Raw] --?[$count[&amp;LoopCounter]] -gt 0|[ --&amp;displayString|+ [$count[&amp;LoopCounter].Raw] [&amp;item[&amp;LoopCounter]], --]| --%| --/|CLEANUP TRAILING COMMA IN THE LIST STRING --~stringLength|string;length;[&amp;displayString] --=numCharsToKeep|[$stringLength] - 1 --~displayString|string;substring;1;[$numCharsToKeep];[&amp;displayString] --:DISPLAY RESULTS| --+|[b]You find the following items in the Giant's Bag..[/b] --+|[&amp;displayString] --X| End Macro --:FUNCTIONS| --:AddItems| accepts the item index and the count to add --=count[%1%]|+[%2%] --&lt;| Initialize Item Counts: No changes here Loop Through numRolls: Changed MatRoll from 1d12 to 1d[$numUniqueTypes.Raw] so it will roll 1d121 for items. Before, any number entered larger than 12 would guarantee that you would have "missing" items in the roll because only the first 12 could be added. I also interpreted the 1d4 as the number of items added each time and updated the call to AddItems to include that. Also changed the label for the section to a comment and added a | to avoid errors logged to the API console. Build Comma Separated List: Added [$count[&amp;LoopCounter].Raw] before the item description to display the count. Note that because 1d4 is rolled for each item added, items that only came up once can have up to 4 counts. Cleaning up: Changed the label to a commend and added a | to avoid errors logged to api console. Display Results: No changes here AddItems: Add the quantity passed in as the second parameter to the count for an item type. Note that this approach doesn't guarantee that rolling on the table 20 times will produce 20 different results. The next approach generates unique rolls by rerolling the MatRoll any time the result already contains a number greater than 0: --:INITIALIZE ITEM COUNTS| --%LoopCounter|1;[$numUniqueTypes.Raw] --=count[&amp;LoopCounter]|0 --%| --/|LOOP THROUGH numRolls TO START ADDING ITEMS --%LoopCounter|1;[&amp;numRolls] --=R1|1d4 --:RepeatRoll| --=MatRoll|1d[$numUniqueTypes.Raw] --?[$count[$MatRoll].Raw] -gt 0|RepeatRoll --&gt;AddItems|[$MatRoll.Raw] --%| --:BUILD COMMA-SEPARATED LIST| --&amp;displayString| --%LoopCounter|1;[$numUniqueTypes.Raw] --?[$count[&amp;LoopCounter]] -gt 0|[ --&amp;displayString|+ [&amp;item[&amp;LoopCounter]], --]| --%| --/|CLEANUP TRAILING COMMA IN THE LIST STRING --~stringLength|string;length;[&amp;displayString] --=numCharsToKeep|[$stringLength] - 1 --~displayString|string;substring;1;[$numCharsToKeep];[&amp;displayString] --:DISPLAY RESULTS| --+|[b]You find the following items in the Giant's Bag..[/b] --+|[&amp;displayString] --X| End Macro --:FUNCTIONS| --:AddItems| accepts the item index and the count to add --=count[%1%]|1 --&lt;| This removes the random number of items from the system and just sets the count to 1 if the item came up. It also removes the count being displayed in front of the item names. Note that putting a numRolls value larger than 121 in this case will trigger ScriptCards execution limit (since it will result in an infinite loop) and your script will stop processing to prevent the sandbox from crashing. With #debug turned off, this runs instantly for me, even generating a list of 100 items. You could also combine the two approaches by only modifying the "LOOP THROUGH" section to contain the --:RepeatRoll| label and the check that branches to it. That would give you the random item counts (1-4 of each item).
1649074518
David M.
Pro
API Scripter
Glad I have notifications turned on for this thread, as I was about to start messing with it when Kurt responded! Sounds like the RepeatRoll part he added in option 2 is critical to your no duplicates requirement. Note that for your original Giant's Bag macro, the goal was to combine the counts of duplicate rolls, so the AddItems function accepted two parameters (the index of the item and the new qty), which Kurt added back in for option 1. If you want a random qty of each item with no duplicates, you may want to implement a hybrid of the two options Kurt presented.&nbsp; &nbsp; &nbsp;