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

1651804164
Andrew R.
Pro
Sheet Author
It’s a forgotten art these days, but very useful for ScriptCards programming: <a href="https://en.wikipedia.org/wiki/Structured_programming" rel="nofollow">https://en.wikipedia.org/wiki/Structured_programming</a> I learned it in 1981 and I’ve been using it since I started with ScriptCards.&nbsp;
Help Please Greetings. I'm preparing a new game (Cyberpunk Red) with ScriptCards.&nbsp; I'm new to both. !scriptcard {{ --#title|Luck Inclusion --#titlecardbackground|#5b0f00 --#oddRowBackground|#5b0f00 --#evenRowBackground|#5b0f00 --#oddRowFontColor|#ffffff --#evenRowFontColor|#ffffff --#subtitlefontsize|12px --=Luck|0d0 + @{selected|luck} --=Maxluck|0d0 + @{selected|luck|max} --~HowFarAway|distance;@{selected|token_id};@{target|token_id} --=Distance|[$HowFarAway] *2 --#leftsub|Luck: [$Luck] / [$Maxluck.Total] --#rightsub|Distance: [$Distance] meters. --:Variables| --=Base|1d10 --=Extra|1d10 --:Luck --? [$Luck] -lt 1|Attack --=Spend|?{Spend a luck point|No,0|Yes,1} --!a:@{selected|token_id}|luck:-=?{Spend a luck point} --Attack| --? [$Base] -eq 1|FumbleRoll --? [$Base] -eq 10|BonusRoll --=AttackRoll|[$Base][base] + [$Spend][luck] --:AttackRoll| --+AttackRoll|[$AttackRoll] --X| --:FumbleRoll| --=FumbleRoll|[$Base][base] - [$Extra][fumble] + [$Spend][luck] --+FumbleRoll|[$FumbleRoll] --X| --:BonusRoll| --=BonusRoll|[$Base][base] + [$Extra][bonus] + [$Spend][luck] --+BonusRoll|[$BonusRoll] --X| }} My intention is to skip the "Spend a luck point" if the characters luck total is already zero. I find myself unable to accomplish this. Does it have something to do with the --i function? Furthermore..Testing my fledgling script it appears that my [$BonusRoll]/[$FumbleRoll] do not appear. Would someone please set me on the right path.
1652181004

Edited 1652181240
Andrew R.
Pro
Sheet Author
You cannot skip a query roll, it happens before the script is run. Use the --i command instead.&nbsp; You are missing the trailing "|" on the --:Luck line. You are missing the ":" on the --Attack line. I suspect if you examine the API console log there are lots of error messages there for you to examine and correct.&nbsp;
Andrew R. said: You cannot skip a query roll, it happens before the script is run. Use the --i command instead.&nbsp; You are missing the trailing "|" on the --:Luck line. You are missing the ":" on the --Attack line. I suspect if you examine the API console log there are lots of error messages there for you to examine and correct.&nbsp; Thanks Andrew, my coding skills are a long road to travel. I am stalled at how to use the --i command and then have it translate over to a --= / --+ command. The Wiki demonstrated how to select targets and choose text. It is not meshing for me. An example would provide a valuable lesson, please.
1652243489

Edited 1652243783
Toby
Pro
I am sure this has probably been addressed somewhere, but I've been unable to locate it.&nbsp; I am trying to access repeating sections from within the repeating section (like character sheet roll buttons).&nbsp; The problem I run into is that RFind requires the value of a given field, which I cant use and RFirst will just iterate through the various repeating sections. Not really sure how to describe what I'm looking for other than to say, if the player presses the "Attack" button within the repeating section.&nbsp; I want to to run the ScriptCard contained in the wHitRoll text area and pull the information from that specific row of the repeating section.&nbsp; No complex loops or searching for values... just whatever is within that row. The text area code I am using is: &lt;textarea class="sheet-macro-text" title="@{repeating_weapon_$X_wHitRoll}" name="attr_wHitRoll"&gt;!scriptcard {{ --/| === ScriptCard Layout for Attack Rolls === |\-- --/| === Version 0.1a&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=== |\-- --/| === Date: 05/03/2022&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=== |\-- --#title|Attack Name --#titlecardbackground|#993333 --#leftsub| [*R:name] --#rightsub| [*R:rab] m [AMMO/AMMO^] --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#emoteText|[*S:t-name] attacks [*T:t-name] --/| === Roll Queries and Variables --&amp;AtkMod|?{Modifier|0} --&amp;AimType|?{Aim | No aim (+0),+0 | Half aim (+10),+10| Full aim (+20),+20} --/| I wonder if the range could be handled by calculating token distance from selected to targeted and then adding in appr. modifier based on the rng incr. of weapon. --/| Or even better, hide the Range rollQuery if its a melee weapon.... --&amp;RangeType|?{Range | Point Blank (+30),+30 | Short Range (+10),+10 | Standard range (+0),+0 | Long Range (-10),-10 | Extreme Range (-30),-30} --&amp;RoFType|?{Rate of Fire/Attack Type| Standard (+10),+10 | Semi auto (+0),+0 | Full Auto (-10),-10 | Called Shot (-20),-20 | Suppressing Fire (-20),-20} --/| == Need to creat conditional to check dropdown box if it is ranged or melee. melee = [*S:WS] [BS] ranged = [*S:WS] [WS] Should be fairly easy. I --=AtkTarget|[*S:BS] [BS] + [&amp;AimType] [Aim] + [&amp;RangeType] [Range] + [&amp;RoFType] + [Rate of Fire] + [&amp;AtkMod] [Modifier] --=AtkRoll|1d100 --&amp;BodyHit|Null --=DegSucess|[$AtkTarget] - [$AtkRoll] \ 10 --/| === Roll Details Tables --+|[c]● Roll Details ●[/c] --+[c][t border=2 width=95% align=center][tr][td][b]Skill&nbsp; &nbsp; [/b][/td][td][b]Aim&nbsp; &nbsp; &nbsp; [/b][/td][td][b]Range&nbsp; &nbsp; [/b][/td][td][b]RoF&nbsp; &nbsp; &nbsp; [/b][/td][td][b]Modifier [/b][/td][/tr][tr][td][*S:BS][/td][td][&amp;AimType][/td][td][&amp;RangeType][/td][td][&amp;RoFType][/td][td][&amp;AtkMod][/td][/tr][/t][/c]| --+|[c][t border=2 width=95% align=center][tr][td][b]Total&nbsp; [/b][/td][td][b]Target [/b][/td][/tr][tr][td][$AtkRoll]&nbsp; &nbsp;[/td][td][$AtkTarget] [/td][/tr][/t][/c] --/| ====== Check if AttackRoll is less than the test THRESHOLD --?[$AtkRoll.Total] -le [$AtkTarget.Total]|Success --?[$AtkRoll.Total] -gt [$AtkTarget.Total]|Failure --:Success| --+[c][#3FB315]HIT! ([$DegSucess.Total])[/#][/c]| --^Done| --:Failure| --+[c][#B31515]MISS! ([$DegSucess.Total])[/#][/c]| --^Done| --:Jam| --+[c]JAM![/c]| --^Done| --:Done| --?[$AtkRoll] -lt 10|[ --&amp;rollStr|0[$AtkRoll.Raw] --]|[ --&amp;rollStr|[$AtkRoll.Raw] --]| --~len|string;length;[&amp;rollStr] --%i|[$len];1;-1 --~s|string;substring;[&amp;i];1;[&amp;rollStr] --&amp;revStr|+[&amp;s] --%| --=revRoll|[&amp;revStr] --/| === Out of Range Values Included for Debugging === --?[$revRoll] -le 0|&gt;SetHitLocation;Error - Out of Range --?[$revRoll] -le 10|&gt;SetHitLocation;Head --?[$revRoll] -ge 11 -and -le 20|&gt;SetHitLocation;Right Arm --?[$revRoll] -ge 21 -and -le 30|&gt;SetHitLocation;Left Arm --?[$revRoll] -ge 31 -and -le 70|&gt;SetHitLocation;Body --?[$revRoll] -ge 71 -and -le 85|&gt;SetHitLocation;Right Leg --?[$revRoll] -ge 86|&gt;SetHitLocation;Left Leg --?[$revRoll] -ge 101|&gt;SetHitLocation;Error - Out of Range --+[c][b][#3FB315][&amp;BodyHit][/#][/b][/c]| --X| End Macro --:PROCEDURES| --:SetHitLocation| accepts hit location as parameter &nbsp; &nbsp; --&amp;BodyHit|[%1%] --&lt;| }} &lt;/textarea&gt; For the purpose of this I cannot use chat area buttons because I need the row information BEFORE it gets displayed in the chat.&nbsp; I will probably have follow up questions to this once it is resolved.&nbsp; But I just need to this down first.
@Matt - include the --#debug|1 command in your code and the API window will give you a lot of information on how your code progressed. Also, if you haven't already, review&nbsp; <a href="https://wiki.roll20.net/Script:ScriptCards#Method_1:_The_Information_Request_.28--i.29_Command" rel="nofollow">https://wiki.roll20.net/Script:ScriptCards#Method_1:_The_Information_Request_.28--i.29_Command</a> The example used in the description is (bugbearcount becomes the variable to be manipulated by your macro): --iA Random Encounter has occurred and we need more information to continue;Click to provide details|q;bugbearcount;How many bugbears|1|2|3|4|5|6|7
@Michael C. - Thank you. Honing my coding.
Referencing Compendium Material I am now in the possession of my first Roll20 game that has its own compendium. Previously in Powercards, I would link material to the SRD website: [stuff](URL). My question is: How do I reference my compendium using Scriptcards? (Cyberpunk Red, if that is important) e.g. [shotgun](shotgun in compendium)
Probably got lost in the shuffle but.&nbsp; I asked a question about a week ago and didn't get a reply. TL;DR version is, I want to use ScriptCards with repeating sections, without having to write a new ScriptCard code for EACH individual weapon.&nbsp; With --RFind working by getting ID based on the value of one of the repeating section fields, that would mean I'd have to re-do the ScriptCard code for EACH repeating field row. Is there a way to just target the repeating field based on the repeating field's row number? My original question can be found here:&nbsp; <a href="https://app.roll20.net/forum/post/9752053/script-scriptcards-my-spiritual-successor-to-powercards/?pageforid=10856507#post-10856507" rel="nofollow">https://app.roll20.net/forum/post/9752053/script-scriptcards-my-spiritual-successor-to-powercards/?pageforid=10856507#post-10856507</a> . I am sorry if my question isn't worded very well.
1652727072
Kurt J.
Pro
API Scripter
Toby said: Probably got lost in the shuffle but.&nbsp; I asked a question about a week ago and didn't get a reply. TL;DR version is, I want to use ScriptCards with repeating sections, without having to write a new ScriptCard code for EACH individual weapon.&nbsp; With --RFind working by getting ID based on the value of one of the repeating section fields, that would mean I'd have to re-do the ScriptCard code for EACH repeating field row. Is there a way to just target the repeating field based on the repeating field's row number? My original question can be found here:&nbsp; <a href="https://app.roll20.net/forum/post/9752053/script-scriptcards-my-spiritual-successor-to-powercards/?pageforid=10856507#post-10856507" rel="nofollow">https://app.roll20.net/forum/post/9752053/script-scriptcards-my-spiritual-successor-to-powercards/?pageforid=10856507#post-10856507</a> . I am sorry if my question isn't worded very well. Unfortunately I don't know anything at all about building custom character sheets and/or writing sheet workers, so I could be totally off base, but I know when in the context of a particular item, things like @{pb} work as references to the value in that context, so it might be possible to use the row data directly that way. Again, though, I haven't even looked at the character sheet development stuff.
1652728178
Kurt J.
Pro
API Scripter
ScriptCards 1.9.5 Experimental (PLEASE READ BEFORE INSTALLING) Version 1.9.5 is identical in functionality to 1.7.7a unless you utilize the ScriptCards Triggers feature described below. This is an initial implementation&nbsp;of the Triggers feature which may change before the feature becomes official in 2.0.0. Also, please keep in mind that the API is not notified of events cause by API scripts, so a token changing via token-mod will not cause a Trigger to fire. In the next experimental update to this feature, objects update via ScriptCards --! object modification command will cause Triggers to fire. I am particularly &nbsp;interested in feedback on this feature. There is a new version of ScriptCards available on the GitHub in a special "Experimental" directory . This version is sort of a pre-release for ScriptCards 2.0, and includes the first iteration of support for a new feature called ScriptCards Triggers. There are also a couple of Trigger Examples &nbsp;in their own folder along with a readme with more details about the feature. Essentially, ScriptCards Triggers is activated by creating a mule character called ScriptCards_Triggers (imaginative, I know...) and creating ability macros on that character with very specific names. ScriptCards subscribes to a selection of API events and matches an event to a name on this character to launch a Script when the event happens. Currently, this list of events is (and these are the names the abilities on ScriptCards_Triggers should have): change:campaign:playerpageid change:campaign:turnorder change:character change:attribute :* add:graphic destroy:gra phic change:graphic:* add:page destroy:page change:page Events marked with :* at the end require you to define the particular property of an object that you wish to be alerted to. Here is a GIF of a couple of simple triggers in action:
Kurt J. said: Unfortunately I don't know anything at all about building custom character sheets and/or writing sheet workers, so I could be totally off base, but I know when in the context of a particular item, things like @{pb} work as references to the value in that context, so it might be possible to use the row data directly that way. Again, though, I haven't even looked at the character sheet development stuff. That doesn't work.&nbsp; It either returns a blank space on the chat if I use a&nbsp;[*S:name] or a "NoRepeatingAttributeLoaded" if I use a&nbsp;[*R:name].&nbsp; Which honestly makes sense since with the first item, it doesn't know where to look because the specific location of a variable has not been set.&nbsp; And for the second I havent defined which repeating section I am wanting to look at though the use of an --RFind or similar statement.&nbsp; The RFind requires I ALREADY know the name of a given attribute within all of the rows... --Rfind|@{selected|character_id};Greatsword;repeating_attack;atkname Well I need to know the value within the attribute @{repeating_attack_XX_atkname.&nbsp; Problem is.&nbsp; I dont know what the value is, that is what I want to GET when I click on the roll button.&nbsp; And what I want to use is the ROWID "XX". so the example would be (half psuedo-code half actual syntax) !scriptcard {{ --/| === ScriptCard Layout for Attack Rolls === |\-- --/| === Version 0.1a&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=== |\-- --/| === Date: 05/03/2022&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=== |\-- --#title|@{selected|repeating_attack_$XX_name} --#titlecardbackground|#993333 --/| AtkType = Melee/Ranged/Thrown/Special --#leftsub|@{selected|repeating_attack_$XX_atkType} --#rightsub|@{selected|repeating_attack_$XX_range} m [@{selected|repeating_attack_$XX_ammo}/@{selected|repeating_attack_$XX_ammo_max] If I try to use the code above with a SPECIFIC ROW ID, it works..&nbsp; Yay!&nbsp; But what If I dont know the row ID ahead of time.&nbsp; Like am rolling it WITHIN a repeating section.. --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --#emoteText|[*S:t-name] attacks [*T:t-name] --/| === Roll Queries and Variables --&amp;AtkMod|?{Modifier|0} --&amp;AimType|?{Aim | No aim (+0),+0 | Half aim (+10),+10| Full aim (+20),+20} --&amp;RangeType|?{Range | Point Blank (+30),+30 | Short Range (+10),+10 | Standard range (+0),+0 | Long Range (-10),-10 | Extreme Range (-30),-30} --&amp;RoFType|?{Rate of Fire/Attack Type| Standard (+10),+10 | Semi auto (+0),+0 | Full Auto (-10),-10 | Called Shot (-20),-20 | Suppressing Fire (-20),-20} --=AtkTarget|[*S:BS] [BS] + [&amp;AimType] [Aim] + [&amp;RangeType] [Range] + [&amp;RoFType] + [Rate of Fire] + [&amp;AtkMod] [Modifier] --=AtkRoll|1d100 --&amp;BodyHit|Null --=DegSucess|[$AtkTarget] - [$AtkRoll] \ 10 --/| === Roll Details Tables --+|[c]● Roll Details ●[/c] --+[c][t border=2 width=95% align=center][tr][td][b]Skill&nbsp; &nbsp; [/b][/td][td][b]Aim&nbsp; &nbsp; &nbsp; [/b][/td][td][b]Range&nbsp; &nbsp; [/b][/td][td][b]RoF&nbsp; &nbsp; &nbsp; [/b][/td][td][b]Modifier [/b][/td][/tr][tr][td][*S:BS][/td][td][&amp;AimType][/td][td][&amp;RangeType][/td][td][&amp;RoFType][/td][td][&amp;AtkMod][/td][/tr][/t][/c]| --+|[c][t border=2 width=95% align=center][tr][td][b]Total&nbsp; [/b][/td][td][b]Target [/b][/td][/tr][tr][td][$AtkRoll]&nbsp; &nbsp;[/td][td][$AtkTarget] [/td][/tr][/t][/c] --/| ====== Check if AttackRoll is less than the test THRESHOLD --?[$AtkRoll.Total] -le [$AtkTarget.Total]|Success --?[$AtkRoll.Total] -gt [$AtkTarget.Total]|Failure --:Success| --+[c][#3FB315]HIT! ([$DegSucess.Total])[/#][/c]| --^Done| --:Failure| --+[c][#B31515]MISS! ([$DegSucess.Total])[/#][/c]| --^Done| --:Jam| --+[c]JAM![/c]| --^Done| --:Done| --?[$AtkRoll] -lt 10|[ --&amp;rollStr|0[$AtkRoll.Raw] --]|[ --&amp;rollStr|[$AtkRoll.Raw] --]| --~len|string;length;[&amp;rollStr] --%i|[$len];1;-1 --~s|string;substring;[&amp;i];1;[&amp;rollStr] --&amp;revStr|+[&amp;s] --%| --=revRoll|[&amp;revStr] --/| === Out of Range Values Included for Debugging === --?[$revRoll] -le 0|&gt;SetHitLocation;Error - Out of Range --?[$revRoll] -le 10|&gt;SetHitLocation;Head --?[$revRoll] -ge 11 -and -le 20|&gt;SetHitLocation;Right Arm --?[$revRoll] -ge 21 -and -le 30|&gt;SetHitLocation;Left Arm --?[$revRoll] -ge 31 -and -le 70|&gt;SetHitLocation;Body --?[$revRoll] -ge 71 -and -le 85|&gt;SetHitLocation;Right Leg --?[$revRoll] -ge 86|&gt;SetHitLocation;Left Leg --?[$revRoll] -ge 101|&gt;SetHitLocation;Error - Out of Range --+[c][b][#3FB315][&amp;BodyHit][/#][/b][/c]| --X| End Macro --:PROCEDURES| --:SetHitLocation| accepts hit location as parameter &nbsp; &nbsp; --&amp;BodyHit|[%1%] --&lt;| }} I hope this clarifies exactly what I am looking to do. Also, for some reason I'm no longer getting notifications that a reply has been posted.&nbsp; GRRR.&nbsp; I gotta fix that.
1652813379
timmaugh
Pro
API Scripter
I'm not sure exactly what you're looking for, Troy, but I wonder if the Fetch metascript could help. Fetch will retrieve repeating info for you *after* you click to run the scriptcard but *before* the ScriptCard code actually gets a turn at the command line of the message. You can choose the entry from the repeating section based on conditions of the row (like where the naming attribute = "Smelly Carp"), and then either return a sub-attribute from that section or the name of the attribute (in various forms). Doing this, you wouldn't need the rowID because you wouldn't be outputting the name of the sub-attribute using the rowID... you could just return the data from appropriate sub-attribute based on the same conditional set. For instance, you can return the ammo sub-attribute of the Smelly Carp attack like this: *(selected.attack.[atkname="Smelly Carp"].ammo) How you choose the repeating element is up to you, then. You could use a roll query with the names of your repeating attacks, and put that in the Fetch construction: *(selected.attack.[atkname="?{Which attack?|Smelly Carp|Sarcastic Goo}"].ammo) Then, elsewhere, you can use that same query with the other sub-attributes to get them: *(selected.attack.[atkname="?{Which attack?}"].range) The Fetch documentation is here ... scroll down to the section on Repeating Items. If this seems like it might work for you but you have questions, you can start a new thread or reach out directly.
1652813518

Edited 1652813982
David M.
Pro
API Scripter
Toby, I think we might be a little unsure of what your goal &amp; intended workflow is. You have a bunch of repeating attacks on your sheet. Are you trying to make a single generic scriptcard that can handle the roll modifiers and hit location of&nbsp; any &nbsp;of these attacks (so basically you just want to pull the damage roll and ammo info from the appropriate repeating attack)? If not, what info do you need from the repeating attack? How do you intend to tell the scriptcard what attack you want to use? Is this going to be an ability macro tied to a character sheet or a collections macro? Or are you trying to do something wild like integrate a scriptcard macro directly into the character sheet? EDIT - You may want to check out Kurt's 5e Character Action scriptcard example. It creates a chat menu that (among other things) can list PC attacks and creates a clickable " reentrant " button that continues processing that repeating attack in the&nbsp; EXEC_PC_ATTACK &nbsp;code block. I imagine you could trim this scriptcard down a bunch (eliminating all the NPC and spell stuff), and modify the EXEC_PC_ATTACK block to include all of your attack mods and hit location logic. EDIT 2 &nbsp;- Or try Tim's Fetch construct ;)
@David M. David M. said: Toby, I think we might be a little unsure of what your goal &amp; intended workflow is. I am having that problem aren't I.&nbsp; And I can tell that frustration is mounting on all sides.&nbsp; Or at least I'm getting frustrated by my inability explain what I want. You have a bunch of repeating attacks on your sheet. Are you trying to make a single generic scriptcard that can handle the roll modifiers and hit location of&nbsp; any &nbsp;of these attacks (so basically you just want to pull the damage roll and ammo info from the appropriate repeating attack)? If not, what info do you need from the repeating attack? Correct.&nbsp; I want it rolled from within a repeating section (or button dragged/similar shortcut).&nbsp; And I want the repeating section to roll using the scriptcards output.&nbsp; You have it exactly.&nbsp; I mean if you don't have this ability it would make running attack macros with power cards... fairly... hard to use. Is this going to be an ability macro tied to a character sheet or a collections macro? Or are you trying to do something wild like integrate a scriptcard macro directly into the character sheet? Integrated into the character sheet.&nbsp; If it wasn't every player would have to know how to use ScriptCards, or I'd have to set it up for them every time they wanted to make an attack with a new weapon.&nbsp; Also, I have no idea what you mean by a "Collections Macro." EDIT&nbsp; - You may want to check out Kurt's&nbsp; 5e Character Action &nbsp;scriptcard example. It creates a chat menu that (among other things) can list PC attacks and creates a clickable " reentrant " button that continues processing that repeating attack in the&nbsp; EXEC_PC_ATTACK &nbsp;code block. I imagine you could trim this scriptcard down a bunch (eliminating all the NPC and spell stuff), and modify the EXEC_PC_ATTACK block to include all of your attack mods and hit location logic. I dont see how 5e code is going to help me.&nbsp; It is fundimentally different from the DH system I am working with.&nbsp; I have glanced at it, and there are a few places where they appear to use repeating section values..&nbsp; But I am not really sure how or what is being done with it.&nbsp; I am not sure what is meant by "Reentrant" are they trying to enter information twice? As for trimming it, I wouldnt even know where to begin to edit the code, because its well beyond my skill level.&nbsp; Its near enough using !ScriptCards as an entire language.&nbsp; A stand-in for sheet workers code. EDIT 2 &nbsp;- Or try Tim's Fetch construct ;) I can see where posting buttons to chat is useful for some things, perhaps even a shortcut for me as a GM to deal with npcs by "creating them" on the fly.&nbsp; But I have a hard enough time convincing my players to roll from the character sheet.&nbsp; Let alone asking them to roll once and then click a button in the chat based on what they want to do.&nbsp; That unfortunately wouldn't be something I could use for this. In addition to this, I need to ask.&nbsp; Why is it so hard to access repeating sections?&nbsp; I just want to have a ScriptCards function based on the values enter into a given row of a repeating section..&nbsp; It doesn't seem to me like that should be such a difficult thing.&nbsp; Granted working with repeating sections within SheetWorkers always appeared to me like a pain in the NECK... perhaps its the same with sheet workers. If I have to I'll abandon repeating sections altogether and simply hard-code like 10 or so weapons and use that..&nbsp; But that is a bit Archaic, and seems counter-intuitive. I just want to remove the need for all the table look ups for part of body struck, and the effects of a critical based on how much damage is dealt and what part of the body is struck.... (Dark Heresy 1e).&nbsp; I didn't realize how much of a bloody nightmare that would be. Sheesh.
For a visual representation of what I am trying to do: Ignore the Buttons in inside the repeating section.&nbsp; That was something I was attempting to get working with checkbox logic, but they dont work yet since I cant even get the output working. And an Output in chat of:
1652818566
David M.
Pro
API Scripter
Ok yeah sorry, I have no experience with that sheet, how the "macro text" box in that sheet relates to anything, and definitely not with sheetworkers at all. I was hoping you were asking about a vanilla scriptcard macro. Integrating things directly into a sheet is definitely not in my wheelhouse. You might have better luck in the Character Sheets Forum?
1652819261

Edited 1652819368
Toby
Pro
The macro text box is just the way of executing the script.....&nbsp; It would be functionally the same as putting it into the chat..&nbsp; Although, it would be a lot harder to access repeating sections.... I will ask in the character sheet forums, however- I am fairly certain they will refer me right back here.. as this isnt a character sheet question.&nbsp; It is a ScriptCards coding question.
1652819671
timmaugh
Pro
API Scripter
Sounds like you are trying to use ScriptCards as a roll template stand-in, Toby... but you are already in the character sheet when you're doing it. In that case, you might as well just go for a full roll template and give your repeating sections a button to trigger that output. Sheets know how to reference the sub-attributes of a repeating section (there's specific syntax for it)... but help for that kind of a thing would best be found over on the Character Sheets forum. (Oh, and the Fetch construct would give you a new button to click -- it works right in the original ScriptCards command line. It would, however, maybe require a query, and now that I see what you are trying to do, that might not work.)
timmaugh said: Sounds like you are trying to use ScriptCards as a roll template stand-in, Toby... but you are already in the character sheet when you're doing it. In that case, you might as well just go for a full roll template and give your repeating sections a button to trigger that output. Sheets know how to reference the sub-attributes of a repeating section (there's specific syntax for it)... but help for that kind of a thing would best be found over on the Character Sheets forum. In a way, I am kinda looking for this to replace Roll Templates.&nbsp; Because Roll templates dont have the functionality that ScriptCards do.
1652823411

Edited 1652824199
David M.
Pro
API Scripter
EDIT - nm, obviously custom sheet. Which character sheet is this? Custom sheet? I tried a game with the Dark Heresy 1e sheet and couldn't expose a Macro Text field EDIT 2 - While scriptcard-specific info is probably a longshot, the character sheet forum might be able to give you the generic info about how to reference the repeating attack row information in your macro text field.
It is a custom variant of the Dark Heresy 1e Custom sheet.&nbsp; It uses a new repeating section that combines the melee and ranged attacks.&nbsp; The repeating section code is very closely related to the one used in the community pathfinder sheet, though it has its roots in the even older 3.5 sheet. Ultimately I feel what I need wont be found inside of the character sheet forum.&nbsp; Because what I need is the ability to specifically reference attributes unique to the rows of a repeating section USING ScriptCards.&nbsp; --RFind identifies and finds the rows by iterating through the value of chosen field: --Rfind|@{selected|character_id};Greatsword;repeating_attack;atkname All I am looking for is a way to specifically reference a repeating field row.&nbsp; To select the row I want to draw attribute names from.&nbsp; Like: --RSetCurrent| And then it will specifically set the [*R:atkname] to be found exclusively from repeating section that is currently active.&nbsp; Or --RSet|0...999 Which would set the [*R:atkname] to be found exclusively from the repeating section specifically referenced.&nbsp; I understand that neither of those is actual syntax.&nbsp; But it is an example of what I am attempting to accomplish. The fact that I cant do this now--would imply that ScriptCards simply cannot be used at all within repeating sections as it is currently coded.&nbsp; That referencing anything within them is IMPOSSIBLE without first knowing the name of the weapon that one wants to reference.&nbsp; Is that the case?&nbsp; I mean, I dont want to have to press an action button and throw out ALL the attacks associated with that character (sheet) and then click the button in the chat to roll attack and damage. In any event.&nbsp; I will try in tthe Character Sheet forums tomorrow.&nbsp; I need a break from this because.. well my pain meds are wearing off AND I am getting frustrated (not anyones' fault.. just... frustrated). If that does not work, then I will redo the character sheet to not use repeating sections at all for weapons.&nbsp; And instead have like 10 melee attacks and 10 ranged attacks hard coded..&nbsp; I know that sort of sheet coding is very 2012... But it is the only solution I can think of, since I dont have the $1500-2500 US to pay someone to hard code what I want into the character sheet using Workers.&nbsp; (Been there did that with another character sheet, and the game I was doing it for fell apart before I even could use the character sheet..) Yeah, I am kinda OCD.&nbsp; I very much appreciate all the help, and apologize if it seemed I was getting snippy.&nbsp; I just like things a certain way.
Hey everybody, i'm actually trying to make a whisper|self macro in which a lot of buttons appear. Each button can call another macro in Roll20. But nothing is happening when i click on one... Can someone try to figure out what's the problem ? !scriptcard {{ --#whisper|self --#titleCardBackground|#6E6E6E --#oddRowBackground|#B0B0B0 --#evenRowBackground|#D4D4D4 --#sourceToken|@{selected|token_id} --#emoteText|Table de Jets --#targetToken|@{selected|token_id} --#emoteBackground|No --#title|Table de Jets --#titleFontSize|40px --#bodyFontSize|24px --#bodyFontFace|Contrail One --+|[c]Caractéristiques[/c] --+|[c][button]Force::!‌&amp;‌#‌1‌3‌;‌#Force[/button] [button]Constitution::!‌&amp;‌#‌1‌3‌;‌#Constitution[/button][/c] --+|[c][button]Dextérité::!‌&amp;‌#‌1‌3‌;‌#Dexterite[/button] [button]Perception::!‌&amp;‌#‌1‌3‌;‌#Perception[/button][/c] --+|[c][button]Charisme::!‌&amp;‌#‌1‌3‌;‌#Charisme[/button] [button]Sagesse::!‌&amp;‌#‌1‌3‌;‌#Sagesse[/button][/c] --+|[c][button]Volonté::!‌&amp;‌#‌1‌3‌;‌#Volonte[/button] [button]Intelligence::!‌&amp;‌#‌1‌3‌;‌#Intelligence[/button][/c] --+|[c]Compétences[/c] --+|[c][button]Acrobaties::!‌&amp;‌#‌1‌3‌;‌#‌Acrobaties[/button] [button]Athlétisme::!&amp;#13;#Athletisme[/button][/c] --+|[c][button]Intimidation::!‌&amp;‌#‌1‌3‌;‌#Intimidation[/button] [button]Bluff::!‌&amp;‌#‌1‌3‌;‌#Bluff[/button][/c] --+|[c][button]Diplomacie::!‌&amp;‌#‌1‌3‌;‌#Diplomacie[/button] [button]Culture::!‌&amp;‌#‌1‌3‌;‌#Culture[/button][/c] --+|[c][button]Informatique::!‌&amp;‌#‌1‌3‌;‌#Informatique[/button] [button]Capacités techniques::!‌&amp;‌#‌1‌3‌;‌#Capatech[/button][/c] --+|[c][button]Biologie::!‌&amp;‌#‌1‌3‌;‌#Biologie[/button] [button]Sciences Physiques::!‌&amp;‌#‌1‌3‌;‌#Sciencephy[/button][/c] --+|[c][button]Survie::!‌&amp;‌#‌1‌3‌;‌#Survie[/button] [button]Mysticisme::!‌&amp;‌#‌1‌3‌;‌#Mysticisme[/button][/c] --+|[c][button]Pilotage::!‌&amp;‌#‌1‌3‌;‌#Pilotage[/button] [button]Escamotage::!‌&amp;‌#‌1‌3‌;‌#Escamotage[/button][/c] --+|[c][button]Discrétion::!‌&amp;‌#‌1‌3‌;‌#Discretion[/button] [button]Déguisement::!‌&amp;‌#‌1‌3‌;‌#Deguisement[/button][/c] }} If i understood well, if my macro name is "Strength", i need to write [button]Strength::!‌&amp;‌#‌1‌3‌;‌#Strength[/button][/c] to get a button called "Strength" launching the "Strength" macro on click, right ? Thanks in advance
1652969145
Kraynic
Pro
Sheet Author
Toby said: Ultimately I feel what I need wont be found inside of the character sheet forum.&nbsp; Because what I need is the ability to specifically reference attributes unique to the rows of a repeating section USING ScriptCards.&nbsp; --RFind identifies and finds the rows by iterating through the value of chosen field: --Rfind|@{selected|character_id};Greatsword;repeating_attack;atkname Disclaimer:&nbsp; I have never used PowerCards or ScriptCards, so I may be misreading what you are trying to do. Assuming each entry/line in your repeating section has a button that is triggering the output for that attack/line, you don't reference the repeating section at all.&nbsp; A roll button in a repeating section will read the attributes from that line only, so if you have an attribute within a repeating section that is labeled as name="attr_atkname", then the macro will only be looking for @{atkname} to pull that value instead of the whole @{repeatingsectionname_row_atkname}.&nbsp; Basically, when you click a roll button within a repeating section, it is as though only that row exists as far as attribute calls in that section go. That is a character sheet mechanic, and is shown in the wiki: <a href="https://wiki.roll20.net/Building_Character_Sheets#Repeating_Sections" rel="nofollow">https://wiki.roll20.net/Building_Character_Sheets#Repeating_Sections</a> You might try stripping out all of your repeating section references from your attribute calls and see if that moves you forward.
1653006815

Edited 1653006868
I'm also getting very odd behavior now scriptcards "latest" code used, both as a mule ability and as direct paste into chat: !scriptcard {{ --#whisper|self --#title|Title &nbsp;--+|[button]carry::!&amp;‌#‌1‌3‌;‌#CarryTokensMenu [/button]&nbsp; }} produces links that look like: - I used "copy link address" <a href="https://app.roll20.net/editor/!&amp;%E2%80%8C#%E2%80%8C1%E2%80%8C3%E2%80%8C;%E2%80%8C#CarryTokensMenu" rel="nofollow">https://app.roll20.net/editor/!&amp;%E2%80%8C#%E2%80%8C1%E2%80%8C3%E2%80%8C;%E2%80%8C#CarryTokensMenu</a> That's a lot of &amp;zwnj; unicode characters in the link, which do not work in the body of the link. A-Rtichaud said: Hey everybody, i'm actually trying to make a whisper|self macro in which a lot of buttons appear. Each button can call another macro in Roll20. ... If i understood well, if my macro name is "Strength", i need to write [button]Strength::!‌&amp;‌#‌1‌3‌;‌#Strength[/button][/c] to get a button called "Strength" launching the "Strength" macro on click, right ? Thanks in advance
@A-Rtichaud - not sure why you are using the unicode.&nbsp; I use:&nbsp;[button]Healing Word::~Macros1stLevel|HealWord[/button] which has worked fine for quite some time.
Your example calls an ability on a Macro Mule, which works still. Calling a macro directly is now not working. See&nbsp; example in scriptcards wiki page &nbsp;for something that doesn't seem to work. -- jcii Michael C. said: @A-Rtichaud - not sure why you are using the unicode.&nbsp; I use:&nbsp;[button]Healing Word::~Macros1stLevel|HealWord[/button] which has worked fine for quite some time.
1653037331
Kurt J.
Pro
API Scripter
Fluffy5789 said: Your example calls an ability on a Macro Mule, which works still. Calling a macro directly is now not working. See&nbsp; example in scriptcards wiki page &nbsp;for something that doesn't seem to work. -- jcii Michael C. said: @A-Rtichaud - not sure why you are using the unicode.&nbsp; I use:&nbsp;[button]Healing Word::~Macros1stLevel|HealWord[/button] which has worked fine for quite some time. I will do some testing and see if I can reproduce the issue and look for a resolution.
Kraynic said: Disclaimer:&nbsp; I have never used PowerCards or ScriptCards, so I may be misreading what you are trying to do. Assuming each entry/line in your repeating section has a button that is triggering the output for that attack/line, you don't reference the repeating section at all.&nbsp; A roll button in a repeating section will read the attributes from that line only, so if you have an attribute within a repeating section that is labeled as name="attr_atkname", then the macro will only be looking for @{atkname} to pull that value instead of the whole @{repeatingsectionname_row_atkname}.&nbsp; Basically, when you click a roll button within a repeating section, it is as though only that row exists as far as attribute calls in that section go. That is a character sheet mechanic, and is shown in the wiki: <a href="https://wiki.roll20.net/Building_Character_Sheets#Repeating_Sections" rel="nofollow">https://wiki.roll20.net/Building_Character_Sheets#Repeating_Sections</a> You might try stripping out all of your repeating section references from your attribute calls and see if that moves you forward. Sorry for not responding right away, for some reason r20 isnt notifying me of new messages to this thread.&nbsp; Regardless, Yeh, this is one of the first things that I tried to get things working.&nbsp; Regrettably it doesn't work.&nbsp; I think the simplifying the of the attribute name for roll commands is part of roll 20's roll system.&nbsp; And strips out the full name reassigning it to something shorter, like an alias.&nbsp; Problem is, ScriptCards entirely bypasses roll20's roll engine and uses its own which doesn't have the same.... flexibility. I am moving my question to the character sheet forums as was suggested by several people here.
Scriptcards is ingenious and I'm really enjoying it. Just a little issue and question.&nbsp; I want to dynamically populate a dropdown list for an --i statement, so: q;LevelsKnown;What level?|{dynamically created pipe-separated list of options here} I've managed to create an array of the options in a loop, and then I can stringify them like this: &nbsp; --~str|array;stringify;LevelsKnown which outputs: 1;2;3 However, I if I try to replace the semicolons with a pipe character like this, and output the result: --~str|string;replace;;;|;[&amp;str] --+[&amp;str]| It doesn't do any replacement, and remains 1;2;3. I suspect it has something to do with the comma and pipe characters as the search/replace text? Not sure.&nbsp; Anyway, even if I do achieve what I want, and get a string containing 1|2|3, does anyone even know if can I even use the string variable containing that in a q; statement? Thanks for any ideas.&nbsp;
1653089279
Kurt J.
Pro
API Scripter
Matt D said: Scriptcards is ingenious and I'm really enjoying it. Just a little issue and question.&nbsp; I want to dynamically populate a dropdown list for an --i statement, so: q;LevelsKnown;What level?|{dynamically created pipe-separated list of options here} I've managed to create an array of the options in a loop, and then I can stringify them like this: &nbsp; --~str|array;stringify;LevelsKnown which outputs: 1;2;3 However, I if I try to replace the semicolons with a pipe character like this, and output the result: --~str|string;replace;;;|;[&amp;str] --+[&amp;str]| It doesn't do any replacement, and remains 1;2;3. I suspect it has something to do with the comma and pipe characters as the search/replace text? Not sure.&nbsp; Anyway, even if I do achieve what I want, and get a string containing 1|2|3, does anyone even know if can I even use the string variable containing that in a q; statement? Thanks for any ideas.&nbsp; Yes, since ";" is the default parameter delimiter, it is confusing what is a parameter separator with the character you want to replace. This can be worked around by using setting the #parameterdelimiter value. For eample: !script {{ &nbsp; --&amp;MyString|1;2;3 &nbsp; --+[&amp;MyString]| &nbsp; --#parameterdelimiter|\ &nbsp; --~str|string\replaceall\;\|\[&amp;MyString] &nbsp; --#parameterdelimiter|; &nbsp; --+[&amp;str]| }} I usually recommend changing it back to ";" after you have completed a command that needs it to be changed for consistency. In this case, I'm changing the parameter separator to a backslash (\) and using that in the string replaceall function statement so I can use the semicolon as the character to replace. On a related note, the parameter delimiter doesn't need to be a single character - If there isn't a simple single character you can use, you can set the parameter delimiter to a multi-character string: --#parameterdelimiter|-$- --~str|string-$-replaceall-$-;-$-|-$-[&amp;MyString] That would use "-$-" as the separator between parameters.
Amazing! Thanks, Kurt!
1653435861

Edited 1653436050
Kurt J.
Pro
API Scripter
Fluffy5789 said: I'm also getting very odd behavior now scriptcards "latest" code used, both as a mule ability and as direct paste into chat: !scriptcard {{ --#whisper|self --#title|Title &nbsp;--+|[button]carry::!&amp;‌#‌1‌3‌;‌#CarryTokensMenu [/button]&nbsp; }} produces links that look like: - I used "copy link address" <a href="https://app.roll20.net/editor/!&amp;%E2%80%8C#%E2%80%8C1%E2%80%8C3%E2%80%8C;%E2%80%8C#CarryTokensMenu" rel="nofollow">https://app.roll20.net/editor/!&amp;%E2%80%8C#%E2%80%8C1%E2%80%8C3%E2%80%8C;%E2%80%8C#CarryTokensMenu</a> That's a lot of &amp;zwnj; unicode characters in the link, which do not work in the body of the link. A-Rtichaud said: Hey everybody, i'm actually trying to make a whisper|self macro in which a lot of buttons appear. Each button can call another macro in Roll20. ... If i understood well, if my macro name is "Strength", i need to write [button]Strength::!‌&amp;‌#‌1‌3‌;‌#Strength[/button][/c] to get a button called "Strength" launching the "Strength" macro on click, right ? Thanks in advance &nbsp; It looks like you may have copied the line straight from the wiki, which would normally work, but the wiki needs the non-printing characters in the string to keep it from actually just showing the unicode character). If you manually type out the !&amp;#13;# it should function as expected. I updated the wiki with a statement to that effect.
Indeed ! It works now ! Thanks Kurt ;)
How would i create a scriptcard that would list all global modifiers on a players sheet from the selected token, regardless of its active flag? I want to do this because I am wanting create another macro that can selectively activate a modifier without having to open the character 5e ogl&nbsp; sheet.
1653644497
Kurt J.
Pro
API Scripter
John D. said: How would i create a scriptcard that would list all global modifiers on a players sheet from the selected token, regardless of its active flag? I want to do this because I am wanting create another macro that can selectively activate a modifier without having to open the character 5e ogl&nbsp; sheet. This would need to be done in stages for each modifier type, but I just did a quick test modifying a copy of the functions in the 5E Character Action Menu script that pulls out all of the modifiers (I just changed -eq "1" to -ne "NoRepeatingAttributeLoaded" to get them all instead of just the active ones). Of course, this just returns a string of text entries but that could be modified easily enough. I'm thinking this idea might be cool to incorporate into the action menu or into a companion script for it.
I'm thinking this idea might be cool to incorporate into the action menu or into a companion script for it. Kurt, That is actually exactly what I wanted to try to.&nbsp; I am by no means a great scripter but I wa ted to try to modify the 5e Action Menu to display buttons to activate/deactivate the GAM &amp; GDM independently, like the ones for advantage.&nbsp; In our group I have a rogue that is constantly having to turn on/off sneak attack and a fighter that uses dueling.&nbsp; Both complain about having to go to the sheet, especially when they forget, and i ether have to remember or retcon the roll.&nbsp; Bless isn't that big a deal because I have made everyone make that GAM_$0 and it get turned on/off programmatically with a script that applies the statusmarker.
1653738505
Kurt J.
Pro
API Scripter
@John D. I've updated the 5E Character Action Menu to now include this feature: The Action Menu now includes support for toggling Global attack and damage modifiers on or off right from the action menu. If &amp;showGlobalModifierButtons is set to 1 in the settings area (as with most/all new features, it is off by default), the action menu will display a summary of the character's defined Global Attack and Global Damage modifiers as buttons at the top of the menu. Active modifiers will have green buttons, while inactive modifiers will have red buttons. Clicking one of the buttons will toggle that modifier and redisplay the menu.&nbsp; NOTE: There is a weirdness/bug in Roll20 that can prevent setting attributes via the API that have never been initialized on the character sheet. This means that these buttons won't be able to toggle on a modifier that has never been toggled on from the character sheet. Manually toggling a modifier on and off once should fix this permanently. There were also a couple of small font/style changes to make things (especially for characters with lots of abilities) look a bit nicer.
1653786860

Edited 1653786986
Kurt J. said: @John D. I've updated the 5E Character Action Menu to now include this feature: The Action Menu now includes support for toggling Global attack and damage modifiers on or off right from the action menu. If &amp;showGlobalModifierButtons is set to 1 in the settings area (as with most/all new features, it is off by default), the action menu will display a summary of the character's defined Global Attack and Global Damage modifiers as buttons at the top of the menu. Active modifiers will have green buttons, while inactive modifiers will have red buttons. Clicking one of the buttons will toggle that modifier and redisplay the menu.&nbsp; NOTE: There is a weirdness/bug in Roll20 that can prevent setting attributes via the API that have never been initialized on the character sheet. This means that these buttons won't be able to toggle on a modifier that has never been toggled on from the character sheet. Manually toggling a modifier on and off once should fix this permanently. There were also a couple of small font/style changes to make things (especially for characters with lots of abilities) look a bit nicer. Character Action Maker is pretty cool, but I am having one problem with it. When I'm using it with the heavy crossbow for a character, it's not calculating damage. I've added a screenshot below.
1653816810
Kurt J.
Pro
API Scripter
@GM Goss - what does the Damage section for the Heavy Crossbow on the character sheet look like?
Kurt J. said: @GM Goss - what does the Damage section for the Heavy Crossbow on the character sheet look like? I fixed it. It turned out to be Roll20 and not the 5E Action Menu. Once I toggled the box "Has an Attack" off and then on again it worked. Now everything's working perfectly.
1654067185

Edited 1654067256
Hello everyone ! I tried something today : tried to use a string variable in a @{selected|[&amp;ExampleString]} form to access the attribute contained in [&amp;ExampleString], but it's not working. Is it possible to use this ? Am i doing something wrong ? Got this error message : "No attribute was found for @{selected|[&amp;ExampleString]}" Maybe the way roll20 and scriptcards are coded arn't compatible for this kind of thing ? I was able to overcome this issue by making several conditionals. But this way, the script is very long (but working). Thanks !
1654079590
Andrew R.
Pro
Sheet Author
A-Rtichaud said: Hello everyone ! I tried something today : tried to use a string variable in a @{selected|[&amp;ExampleString]} form to access the attribute contained in [&amp;ExampleString], but it's not working. Is it possible to use this ? Am i doing something wrong ? Got this error message : "No attribute was found for @{selected|[&amp;ExampleString]}" Maybe the way roll20 and scriptcards are coded arn't compatible for this kind of thing? I think that @{selected|} is evaluated before Scriptcards get the code, so you can't use ScriptCard variables there.&nbsp;&nbsp;
Andrew R. said: A-Rtichaud said: Hello everyone ! I tried something today : tried to use a string variable in a @{selected|[&amp;ExampleString]} form to access the attribute contained in [&amp;ExampleString], but it's not working. Is it possible to use this ? Am i doing something wrong ? Got this error message : "No attribute was found for @{selected|[&amp;ExampleString]}" Maybe the way roll20 and scriptcards are coded arn't compatible for this kind of thing? I think that @{selected|} is evaluated before Scriptcards get the code, so you can't use ScriptCard variables there.&nbsp;&nbsp; This is correct. The most straightforward way to get what you're looking for is: --#sourcetoken|@{selected|token_id} --&amp;ExampleString|whatever this is supposed to be --+Attribute Name|[*S:[&amp;ExampleString]]
1654195536

Edited 1654195643
I'm making my own system and had to switch from PowerCards to ScriptCards to accommodate new features. I'm currently rewriting the whole thing and have run into a few issues so far. First, the math is one to 1, not one to one. It's not the same as QuantumRoll and I've found some wacky differences. The following code basically detects if @{target|block_counter} is 0 or greater than 0. If 0, subtract @{target|dodge} from the attack roll. If greater than 0, subtract @{target|block} from the attack roll. [[ [$atk] 1d100 + @{accuracy} - @{target|dodge}*(0**@{target|block_counter}) - @{target|block}*(@{target|block_counter}d1kh1) ]] --=Attack|1d100 + [*S:accuracy] - ( [*T:dodge] * ( 0 {SQUARE} [*T:block_counter] ) ) - ( [*T:block] * ( [*T:block_counter]d1kh1 ) ) The inline outputs correctly, but the ScriptCards result will always be 0: 1d0 is worse and outputs the following: (for those curious, 0d0 outputs similar to the 0d1, not 1d0) I know the work around is just adding more conditionals, but that's a lot of code to replace some math in a variable and it would be nice if the ScriptCards math worked the same as Roll20's math. Second, the wiki doesn't have as much documentation on Libraries as I hoped and I find myself a little confused. Libraries are essentially the replacement for PowerCard Templates, right? Replacements seem to be baked into the core mechanics of ScriptCards, but Templates are just as essential and I'm not sure if Libraries can be used as Templates for things like attack macros or if they can only contain branches. Is that even a bad thing for them to only contain branches? Are branches strong enough to replace entire macros? I learned everything I know about PowerCards from its wiki and from YouTube, but ScriptCards doesn't have as much readily available documentation on either that I've been able to find. I think a video similar to this one for ScriptCards Libraries would be very appreciated by the community and it could be easily converted into wiki documentation, like the magic missile video was.
1654293989
Kurt J.
Pro
API Scripter
Dominic H. said: &lt;snip for brevity&gt; I know the work around is just adding more conditionals, but that's a lot of code to replace some math in a variable and it would be nice if the ScriptCards math worked the same as Roll20's math. Second, the wiki doesn't have as much documentation on Libraries as I hoped and I find myself a little confused. Libraries are essentially the replacement for PowerCard Templates, right? Replacements seem to be baked into the core mechanics of ScriptCards, but Templates are just as essential and I'm not sure if Libraries can be used as Templates for things like attack macros or if they can only contain branches. Is that even a bad thing for them to only contain branches? Are branches strong enough to replace entire macros? I learned everything I know about PowerCards from its wiki and from YouTube, but ScriptCards doesn't have as much readily available documentation on either that I've been able to find. I think a video similar to this one for ScriptCards Libraries would be very appreciated by the community and it could be easily converted into wiki documentation, like the magic missile video was. ScriptCards uses its own roll parser, which strictly works left to right. There is no order of operations, etc. I understand that this makes some things a bit more complicated but the whole point of not using the built-in roll engine was to be able to use variables in rolls - not possible in PowerCards because all of the rolls are set before the card ever gets processed. Libraries are fairly straightfoward, and should not really be considered the equivalent of templates from PowerCards. Templates were my attempt to allow add some flexibility in PowerCards because it didn't support real script processing. A ScriptCards library is simply a block of ScriptCards commands that you place in a handout named after the format "ScriptCards Library libraryname". If you include +++libraryname+++ inside any ScriptCard, the API will search for a handout with a matching name and add all of the code from the library onto the end of the ScriptCard just as if it had been typed there in the first place. So if a library handout called "ScriptCards Library HelloWorld" has the following code in it: --:HELLO_WORLD| --+Hello|World! --&lt;| then this: !script {{ &nbsp; +++HelloWorld+++ &nbsp; --&gt;HELLO_WORLD| &nbsp; --X| }} is exactly the same as this when the script runs: !script {{ &nbsp; --&gt;HELLO_WORLD| &nbsp; --X| &nbsp; --:HELLO_WORLD| &nbsp; --+Hello|World! &nbsp; --&lt;| }} There is nothing special about the library code, and anything running from the library has full access to the variables in the "normal" part of the Script and vice versa (so creating/setting a variable in a called library function will make that variable available in the regular script). Personally, I don't really make use of libraries - I prefer to just put the code I need for any given script into the script itself - but your situation above could make use of the following (in or out of a library): --:CALCULATE_DEFENSE|Target Token ID;VariableToSet --&amp;[%2%]|[*[%1%]:dodge] --?[*[%1%]:block_counter] -gt 0|&amp;[%2%];[*[%1%]:block] --&lt;| Which could be utilized to create a defense variable, so the code you have above would become something like: --&gt;CALCULATE_DEFENSE|[*T:t-id];defense --=Attack|1d100 + [*S:accuracy] - [&amp;defense] While this is a bit more code, I think it is also much more readable and obvious as to what it does. If, for your system, you define things like CALCULATE_DEFENSE in a library that you include in you scripts, it would then be available everywhere without redefining it every time.
1654315569

Edited 1654316584
Kurt J. said: ScriptCards uses its own roll parser, which strictly works left to right. There is no order of operations, etc. I understand that this makes some things a bit more complicated but the whole point of not using the built-in roll engine was to be able to use variables in rolls - not possible in PowerCards because all of the rolls are set before the card ever gets processed. I know this, but in Roll20, 1d0, 0d1, and 0d0 are all treated as 0, but in ScriptCards any math that includes those dice rolls ruins the whole equation. Any roll variable containing 0dX will be set to the value of 0 and any roll variable containing Xd0 will be set to "NaN". Luckily because ScriptCards isn't as dumb as PowerCards, I haven't been forced to use those dice rolls yet, but I'm sure a case exists where they would be useful. The advice on Libraries is very useful, and it turns out Libraries are exactly what I need. Thanks! This has been a very powerful API so far. I wish there was a way for Information Requests (--i) to be sent to players other than the one sending the script. How it is now, the Roll Query in my macro that determines whether the target will attempt to block the attack is sent to the player controlling the attacker, not the player controlling the target. I also wish that there was one fewer step in the Information Request process, maybe an option for the button to not be required and the target/roll query to come up immediately. I'm not sure if either of those things are possible in Roll20, but if they are I would benefit from it. Other than that, I'm doing things I didn't know were possible in Roll20. Seriously great API.
1654342062
David M.
Pro
API Scripter
I think the intent of the information request is to allow for a certain amount of processing/logic before &nbsp;the request/query. You could structure your macro to have all queries come up immediately, but they would get parsed before that info is handed off to your scriptcard so there could be no pre-processing. The "extra step" is required when you don't know precisely what you want to ask when you initiate the macro.
Hey Kurt,&nbsp; I've noticed that the 5e Initiative Roller that you wrote has stopped working. I'm not sure if the Turn Tracker was updated or what, but I noticed that it will make the roll but it won't post it to the Turn Tracker.&nbsp;
I am having problems with a macro that checks to see if a Dnd 5e character has a spell prepared before casting.&nbsp; Anytime the spell is one word, all is well.&nbsp; Once there is a "white space" in the spell name, the macro fails. &nbsp; --:CheckSpellPrepared| &nbsp; &nbsp; &nbsp;--%loop|1;9 &nbsp; &nbsp; &nbsp; &nbsp; --?[S:lvl[&amp;loop]_slots_total] -eq 0|EndMacro &nbsp; &nbsp; &nbsp; &nbsp; --rfirst|[S:character_id];repeating_spell-[&amp;loop] &nbsp; &nbsp; &nbsp; &nbsp; --:DisplayLoop| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--?"[R:spellname]" -eq NoRepeatingAttributeLoaded|% &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--?"[R:spellname]" -inc "[%1%]" -and [R:spellprepared] -ne 1|&gt;NotPrepared;[%1%] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--rnext| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;--^DisplayLoop| &nbsp; &nbsp; &nbsp;--%| &nbsp; --&lt;| &nbsp; --:NotPrepared| &nbsp; &nbsp; &nbsp;--+|[S:character_name] Does Not Have The [%1%] Spell Prepared Is there a fix?