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

This looks super cool! I have a few (dumb newbie) questions. For ScriptCards that reference spells, the spell slot is updated on the character sheet, right? If we're not using AlterBars, I assume we can handle damage using Tokenmod? Would it be possible to have a conditional tied to a hit or miss but not actually apply the damage until a button is clicked? Let's say Carla the Fighter attacks Bob the Orc with a longsword. Bob's AC is 15. Carla's result is an 18. It looks like Carla will hit, but Bob has a reaction that gives him +4 to AC against a melee attack that would otherwise hit. In this situation, I don't want the attack to automatically hit. Instead, I'd like to have a green checkmark (hit button to apply damage) or a red x (miss button for no damage), so that the player herself can click hit or miss after I assess. Another inverse case would be someone (me or a player) forgetting that the attacker has advantage on the roll, thereby turning a potential miss into a hit. Would this be possible using ScriptCards?
1612447509
Kurt J.
Pro
API Scripter
Jay R. said: This looks super cool! I have a few (dumb newbie) questions. For ScriptCards that reference spells, the spell slot is updated on the character sheet, right? If we're not using AlterBars, I assume we can handle damage using Tokenmod? Would it be possible to have a conditional tied to a hit or miss but not actually apply the damage until a button is clicked? Let's say Carla the Fighter attacks Bob the Orc with a longsword. Bob's AC is 15. Carla's result is an 18. It looks like Carla will hit, but Bob has a reaction that gives him +4 to AC against a melee attack that would otherwise hit. In this situation, I don't want the attack to automatically hit. Instead, I'd like to have a green checkmark (hit button to apply damage) or a red x (miss button for no damage), so that the player herself can click hit or miss after I assess. Another inverse case would be someone (me or a player) forgetting that the attacker has advantage on the roll, thereby turning a potential miss into a hit. Would this be possible using ScriptCards? ScriptCards does not make any changes to characters/tokens/etc directly. it would be necessary to call other APIs via the --@ command to do so. Token-mod should work fine, as well as chatsetattr. Because ScriptCards acts like a scripting language, you can control all aspects of what the script does - nothing is automatic. Currently you can create buttons that run other commands, but right now button command text can't contain the -- sequence. I'm planning on an update to allow button commands that start with "!" (an API call) to use the same replacement logic for underscores that happen in --@ commands. That should happen in the next release.
Kurt J. said: ScriptCards does not make any changes to characters/tokens/etc directly. it would be necessary to call other APIs via the --@ command to do so. Token-mod should work fine, as well as chatsetattr. Because ScriptCards acts like a scripting language, you can control all aspects of what the script does - nothing is automatic. Currently you can create buttons that run other commands, but right now button command text can't contain the -- sequence. I'm planning on an update to allow button commands that start with "!" (an API call) to use the same replacement logic for underscores that happen in --@ commands. That should happen in the next release. OK, that's good to know. Thanks. I am trying to modify the sample longsword attack scriptcard to use Tokenmod to apply damage, instead of AlterBars, but it's not working. What am I doing wrong here?   --@token-mod|_ids|@{target|token_id} _set|bar1_value-[$Damage] Edit: BTW, copying the sample eh list command into the longsword script produced the following message and nothing else: (From EncounterHelper): Player Jay R. (GM) tried to use the !eh list command.
1612463492
timmaugh
Pro
API Scripter
Kurt J. said: GiGs said: Alternatively, just let me know what i need to change in MEGS to work with scriptcards. I think the only thing that would need to change is in this function: const getSender = msg => { const character = findObjs({ type: 'character', name: msg.who })[0], player = getObj('player', msg.playerid); if (character) return 'character|'+character.id; else return 'player|'+player.id; }; When using sendChat, the SpeakingAs parameter fills in msg.who, but msg.playerid will always be "API" (I haven't found a way to change that). ScriptCards (and powercards) just pass along whatever they got for msg.who so if I'm reading things right, the only time the crash indicated above would happen is when the GM (who's msg.who value doesn't equal a character name) runs something that calls !megs via the API. In that case the character lookup will fail by name (for example, my msg.who is "Kurt J (GM)" which isn't a valid character name) and the script will try looking up a player by ID, which will also result in undefined since playerid will be API, which isn't a valid player. Alternatively, you could implement SelectManager for any script that might expect to be called by another API. I just updated SelectManager to also store the  msg.who  and  msg.playerid  properties, so now it tracks all of the items that are typically changed when a message goes through an API call. If you have your script declared as dependent on SelectManager, you could use it directly: msg.who = SelectManager.GetWho(); Otherwise, if you left it optional (until SelectManager gets into the one-click): let getWho = () => {}; on('ready', () => { if(undefined !== typeof SelectManager) getWho = () => SelectManager.GetWho (); }); // ... // after making sure this script should catch the message msg.who = getWho(); I'm headed over to update the script thread with the new access, then I'll submit it to the one-click. Should hopefully make it in next week.
1612464989
GiGs
Pro
Sheet Author
API Scripter
Great idea. MEGS predates Select Manager quite a bit, so it would never have occurred to me when writing it, but I think I'll update it with the optional method. Since my script isn't on the one-click, it's best not to assume a dependency is present.
Jay R. said: OK, that's good to know. Thanks. I am trying to modify the sample longsword attack scriptcard to use Tokenmod to apply damage, instead of AlterBars, but it's not working. What am I doing wrong here?   --@token-mod|_ids|@{target|token_id} _set|bar1_value-[$Damage] Edit: BTW, copying the sample eh list command into the longsword script produced the following message and nothing else: (From EncounterHelper): Player Jay R. (GM) tried to use the !eh list command. I think this has more to do with your syntax for token-mod. Your line should read: --@token-mod|_ids @{target|token_id} _set bar1_value|-[$Damage]
1612472786

Edited 1612472820
Kurt J.
Pro
API Scripter
Minor Update : 0.0.10a I've updated the GIST with a minor update which changes the following: If a button action contains an API call, the line line will be run through the _ to -- replacement process that happens on --@ lines, allowing you to make buttons with [button]Caption::Action[/button] that call API scripts that use -- as a parameter indicator. A new setting: dontcheckbuttonforapi . This defaults to 0. If set to anything else, the button replacement described in the previous bullet won't take place. Removed some console log spam that was inadvertently left in the code. Tweak to the --V visual effects statement. If the effect type is blank or "none", no effect will be displayed. Prior to this the spawnFX would still be called, producing a blast-fire effect (the default effect). I'll be putting together a "Deep Dive" YouTube video this weekend expanding on the Magic Missile sample script to include visual effects, modifying attributes with chatsetattr, tokenmod, and alterbar, playing sounds, tracking spell slots, and laying out procedures with parameters. After I've completed the video I'll put the result in the Wiki.
1612473906

Edited 1612474583
David M.
Pro
API Scripter
There's a lot of chatter going on, so wanted to follow up on previous questions/comments and add a related one: David M. said: 1) I noticed that it does not seem to handle table names that include a dash (like the default "new-table" name). Haven't tried other special characters. NBD if we just have to remember to name appropriately. 2) Is there support for multiple table images on a single line? If so, I haven't figured out the syntax. Example would be for concisely displaying custom dice graphics without spamming the chat with very "tall" cards for games with large dice pools. 3) Currently the  tableEntryText always treats the entry as, well, text. Would it be difficult or cause any unforseen problems to do a parseInt or similar on the table entry text and either return it as a normal roll or otherwise expose potential numeric values (e.g. " tableEntryVal", or perhaps populate the .Total, etc.) ?  Example applications include custom dice (above) or maybe summing GP values of treasure tables, etc. EDIT - There is a partial workaround for item #3. Appears you can just assign the table text to a new roll with something like the following (assuming the table entry is completely numeric):  --=TableVal|[$TableRoll.tableEntryText]
1612475221

Edited 1612477011
Kurt J.
Pro
API Scripter
David M. said: There's a lot of chatter going on, so wanted to follow up on previous questions/comments and add a related one: David M. said: 1) I noticed that it does not seem to handle table names that include a dash (like the default "new-table" name). Haven't tried other special characters. NBD if we just have to remember to name appropriately. 2) Is there support for multiple table images on a single line? If so, I haven't figured out the syntax. Example would be for concisely displaying custom dice graphics without spamming the chat with very "tall" cards for games with large dice pools. 3) Currently the  tableEntryText always treats the entry as, well, text. Would it be difficult or cause any unforseen problems to do a parseInt or similar on the table entry text and either return it as a normal roll or otherwise expose potential numeric values (e.g. " tableEntryVal", or perhaps populate the .Total, etc.) ?  Example applications include custom dice (above) or maybe summing GP values of treasure tables, etc. EDIT - There is a partial workaround for item #3. Appears you can just assign the table text to a new roll with something like the following (assuming the table entry is completely numeric):  --=TableVal|[$TableRoll.tableEntryText] I don't know of anything that should keep table names with a dash in them from working, but it is probably a mistake in my regex (imagine that!) :) I'll have a look. I haven't tried placing multiple images on a line, but I'll play around with it. I can certainly add a tableEntryValue that is a parse of the text property. It would end up being 0 in cases where the text isn't a number, but should be easy enough to do.
1612478928
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
This looks awesome, just a question... would be possible to integrate stuff from a compendium in some way? Let say I have a magic scrip cart, creating a layout that uses the information of a compendium entry instead of doing it manually?
1612479666
Kurt J.
Pro
API Scripter
Version 0.0.10b is on the GIST Minor update to address three issues identified by David M: Rollable Tables can now contain a dash in the name . This breaking was a side effect of trying to be friendly for roll text by replacing "-" with " - " prior to parsing the roll, resulting in the table not being found because of the additional spaces. Rollable Tables return a .tableEntryValue . This is the result of converting the tableEntryText to a number with parseInt. If the text is not numeric, the result will be 0. Multiple [img]...[/img] sequences on a single --+ statement are now supported . Had to play some games with regex, but this is now working.
1612480018

Edited 1612480352
Kurt J.
Pro
API Scripter
Marco M. said: This looks awesome, just a question... would be possible to integrate stuff from a compendium in some way? Let say I have a magic scrip cart, creating a layout that uses the information of a compendium entry instead of doing it manually? Hmmm... I see there IS a way to access compendium entries via JSON... I didn't know that until just now. :) But I don't know that there is any way for a Roll20 API script to retrieve the JSON from the compendium. I'll play around and see what I can figure out, but being able to do so is unlikely. Just checked, and as I suspected the API sandbox does not allow the retrieval of external HTML/pages (I would be totally amazed if it did... that would pose lots of potential problems), so at the moment there isn't a way for this to be done.
Colin C. said: Jay R. said: OK, that's good to know. Thanks. I am trying to modify the sample longsword attack scriptcard to use Tokenmod to apply damage, instead of AlterBars, but it's not working. What am I doing wrong here?   --@token-mod|_ids|@{target|token_id} _set|bar1_value-[$Damage] Edit: BTW, copying the sample eh list command into the longsword script produced the following message and nothing else: (From EncounterHelper): Player Jay R. (GM) tried to use the !eh list command. I think this has more to do with your syntax for token-mod. Your line should read: --@token-mod|_ids @{target|token_id} _set bar1_value|-[$Damage] Just tried your suggestion, and tried a bunch of different combinations (earlier), and nothing has successfully taken damage off the targeted token's bar.  Edit: No token-mod command has worked. I was able, as a test, to get roll20AM to bring up the basic config menu from the scriptcard, but nothing else has worked. Tokenmod and group-init don't work. EncounterHelper just gives me the same error: (From EncounterHelper): Player Jay R. (GM) tried to use the !eh list command. Edit 2: Turning the "player can ID" option on in Tokenmod worked!
1612486726

Edited 1612489311
David M.
Pro
API Scripter
Ahhh, v0.0.10b for the win! Thanks for all the help, Kurt! Took a few minutes to figure out the syntax for appending URLs to a string variable in a loop (had to prepend alignment and img size tags, then build URL strings, then append closing tag). Here's what I came up with for the Alien TTRPG. You roll a number of base dice, and a number of "stress" dice. Both count 6's as a success, while the stress dice can also add a failure for each roll of 1. Add successes & failures to determine overall result of the check.  Here's a couple of example checks, using rollable table graphics for the cool Alien dice and string building variables to put the dice on a single line. Here's the Scriptcard macro for those that are interested in how I put it together. I left several comments in the code to help decipher all the new syntax. !scriptcard {{ --#title|AlienTTRPG Rolls --#leftsub|Num Dice ?{Num Dice?|1} --#rightsub|Num Stress Dice ?{Num Stress Dice?|0} --:Initialize Roll Vars| --=NumDice|?{Num Dice?} --=NumStressDice|?{Num Stress Dice?} --=NumSuccess|0 --=NumFail|0 --:String Building Vars| Will store table graphics. Pre-pend opening format tag --&DieOutput|+[r] --&StressOutput|+[r] --:Base Dice Block| --+[#990000]BASE ROLLS[/#]| --=DieCount|0 --:BaseDiceLoop| --=DieCount|[$DieCount] + 1 -->RollBase| --?[$DieCount] -lt [$NumDice]|BaseDiceLoop --:Output Main Dice| but first append closing format tag --&DieOutput|+[/r] --+|[&DieOutput] --:Stress Dice Block| --+[#990000]STRESS ROLLS[/#]| --?[$NumStressDice] -eq 0|>NA --?[$NumStressDice] -eq 0|EvaluationBlock --=DieCount|0 --:StressLoop| -->RollStress| --=DieCount|[$DieCount] + 1 --?[$DieCount] -lt [$NumStressDice]|StressLoop --:Output Stress Dice| but first append closing format tag --&StressOutput|+[/r] --+|[&StressOutput] --:EvaluationBlock| --+[#990000]EVALUATION[/#]| --:Output Success and Failure counts| --+|[r][b]Successes=[$NumSuccess][/b][/r] --+|[r][b]Failures=[$NumFail][/b][/r] --:Compare rolls| --=Diff|[$NumSuccess] - [$NumFail] --+|[r][b]Difference[$Diff][/b][/r] --+[#990000]RESULT[/#]| --:Output Overall Success or Failure| --?[$Diff] -gt 0|OverallSuccess --?[$Diff] -le 0|OverallFailure --X| End macro --:FUNCTIONS| --:NA| --+|[b][r]N/A[/r][/b] --<| --:RollBase| --=ThisRoll|[T#AlienD6] --?[$ThisRoll.tableEntryValue] -eq 6|>AddSuccess --&DieOutput|+[img width=32][$ThisRoll.tableEntryImgURL][/img] --<| --:RollStress| --=ThisRoll|[T#AlienStressD6] --?[$ThisRoll.tableEntryValue] -eq 6|>AddSuccess --?[$ThisRoll.tableEntryValue] -eq 1|>AddFail --&StressOutput|+[img width=32][$ThisRoll.tableEntryImgURL][/img] --<| --:AddSuccess| --=NumSuccess|[$NumSuccess] + 1 --<| --:AddFail| --=NumFail|[$NumFail] + 1 --<| --:OverallSuccess| --+[c][#009900]~~~SUCCESS~~~[/#][/c]| --X| --<| --:OverallFailure| --+[c][#ff0000]~~~FAILURE~~~[/#][/c]| --X| }}
1612489341

Edited 1612489386
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
Awesome!! Is there a way to 1. change the color of a button? 2. do a round up instead of down? !scriptcard {{ --#sourceToken|@{target|token_id} --#emoteText|@{target|token_name} starts eating the body --#titleCardBackground|#000000 --#buttonCardBackground|#000000 --#titleCardFontColor|#FFFFFF --#titleFontFace|Arial --#evenRowBackground|#FFFFFF --#oddRowBackground|#F2F3F4 --=RitualTarget|99-@{target|sanity_points} --=RollR|1d100 --=SLossLearn|1d20 --=SLossCast|1d10 --=WPLossCast|20 --=WPLossCast1|[$WPLossCast] / 2 --=SLossCast1|[$SLossCast] / 2) --#title|Ageless Banquet --#leftsub|*Elaborate Ritual* --+[#990000]Study time:[/#]| weeks; [$SLossLearn] SAN; +1 *Unnatural* --+[#990000]Activation:[/#]| days --#leftsub|([$RitualTarget]%) --+[#990000]Ritual:[/#]| Supposedly discovered by an ancient, infamous Congo tribe, this days-long sacrificial ritual invokes Shub-Niggurath in a litany of other, more traditional spirits. A human sacrificial victim is slain, dismembered, cooked, and eaten. The ritual costs **20 WP** from the sacrifice and the operator, and costs the operator **1D10 SAN** in addition to **SAN** lost from the violence of the sacrifice. \\ Consuming a human body costs a further **1/1D6 SAN** for **violence**. The operator does not age for one year following the ritual. Other versions are rumored to stem from other cultural traditions and to involve drinking blood, but not eating flesh. --+[#990000]Result:[/#]| [$RollR] --?[$RollR] -le [$RitualTarget]|>Success1|>Failure1 --X| --:Success1| --?[$RollR] -eq 1 -or ?[$RollR] -eq 11 -or ?[$RollR] -eq 22 -or ?[$RollR] -eq 33 -or ?[$RollR] -eq 44 -or ?[$RollR] -eq 55 -or ?[$RollR] -eq 66 -or ?[$RollR] -eq 77 -or ?[$RollR] -eq 88 -or ?[$RollR] -eq 99|>Critical|>Success --X| --:Success| --+[#990000]Success:[/#]|: the ritual worked as described, you lose [$WPLossCast]WP and [$SLossCast]. -->Fin| --<| --:Critical| --+[#990000]Critical:[/#]|: the ritual worked **better** than intended, you lose [$WPLossCast]WP and [$SLossCast]. -->Fin| --<| --:Failure1| --?[$RollR] -eq 1 -or ?[$RollR] -eq 11 -or ?[$RollR] -eq 22 -or ?[$RollR] -eq 33 -or ?[$RollR] -eq 44 -or ?[$RollR] -eq 55 -or ?[$RollR] -eq 66 -or ?[$RollR] -eq 77 -or ?[$RollR] -eq 88 -or ?[$RollR] -eq 99|>Fumble|>Failure --X| --:Failure| --+[#990000]Failure:[/#]|:the ritual didn't work, you lose [$WPLossCast1]WP and [$SLossCast1] or you can force the ritual to work by spending [$WPLossCast]/2 WP and [$SLossCast]/2 and 1POW. -->Fin| --<| --:Fumble| --+[#990000]Fumble:[/#]|the ritual didn't work, you lose [$WPLossCast1]/2 WP and [$SLossCast1]/2 or you can force the ritual to work by spending [$WPLossCast]WP and [$SLossCast] and 1POW. -->Fin| --<| --:Fin| --+[#990000]Additional loss:[/#]|: For eating the body you lose an additional **1/1D6 SAN for Violence**--+| --+| [c] [button]SAN::~TheScenario|repeating_sanlosses_$0_scenelossb[/button] [/c] --<| }}
1612491018
Kurt J.
Pro
API Scripter
Marco M. said: Awesome!! Is there a way to 1. change the color of a button? 2. do a round up instead of down? !scriptcard {{ --#sourceToken|@{target|token_id} --#emoteText|@{target|token_name} starts eating the body --#titleCardBackground|#000000 --#buttonCardBackground|#000000 --#titleCardFontColor|#FFFFFF --#titleFontFace|Arial --#evenRowBackground|#FFFFFF --#oddRowBackground|#F2F3F4 --=RitualTarget|99-@{target|sanity_points} --=RollR|1d100 --=SLossLearn|1d20 --=SLossCast|1d10 --=WPLossCast|20 --=WPLossCast1|[$WPLossCast] / 2 --=SLossCast1|[$SLossCast] / 2) --#title|Ageless Banquet --#leftsub|*Elaborate Ritual* --+[#990000]Study time:[/#]| weeks; [$SLossLearn] SAN; +1 *Unnatural* --+[#990000]Activation:[/#]| days --#leftsub|([$RitualTarget]%) --+[#990000]Ritual:[/#]| Supposedly discovered by an ancient, infamous Congo tribe, this days-long sacrificial ritual invokes Shub-Niggurath in a litany of other, more traditional spirits. A human sacrificial victim is slain, dismembered, cooked, and eaten. The ritual costs **20 WP** from the sacrifice and the operator, and costs the operator **1D10 SAN** in addition to **SAN** lost from the violence of the sacrifice. \\ Consuming a human body costs a further **1/1D6 SAN** for **violence**. The operator does not age for one year following the ritual. Other versions are rumored to stem from other cultural traditions and to involve drinking blood, but not eating flesh. --+[#990000]Result:[/#]| [$RollR] --?[$RollR] -le [$RitualTarget]|>Success1|>Failure1 --X| --:Success1| --?[$RollR] -eq 1 -or ?[$RollR] -eq 11 -or ?[$RollR] -eq 22 -or ?[$RollR] -eq 33 -or ?[$RollR] -eq 44 -or ?[$RollR] -eq 55 -or ?[$RollR] -eq 66 -or ?[$RollR] -eq 77 -or ?[$RollR] -eq 88 -or ?[$RollR] -eq 99|>Critical|>Success --X| --:Success| --+[#990000]Success:[/#]|: the ritual worked as described, you lose [$WPLossCast]WP and [$SLossCast]. -->Fin| --<| --:Critical| --+[#990000]Critical:[/#]|: the ritual worked **better** than intended, you lose [$WPLossCast]WP and [$SLossCast]. -->Fin| --<| --:Failure1| --?[$RollR] -eq 1 -or ?[$RollR] -eq 11 -or ?[$RollR] -eq 22 -or ?[$RollR] -eq 33 -or ?[$RollR] -eq 44 -or ?[$RollR] -eq 55 -or ?[$RollR] -eq 66 -or ?[$RollR] -eq 77 -or ?[$RollR] -eq 88 -or ?[$RollR] -eq 99|>Fumble|>Failure --X| --:Failure| --+[#990000]Failure:[/#]|:the ritual didn't work, you lose [$WPLossCast1]WP and [$SLossCast1] or you can force the ritual to work by spending [$WPLossCast]/2 WP and [$SLossCast]/2 and 1POW. -->Fin| --<| --:Fumble| --+[#990000]Fumble:[/#]|the ritual didn't work, you lose [$WPLossCast1]/2 WP and [$SLossCast1]/2 or you can force the ritual to work by spending [$WPLossCast]WP and [$SLossCast] and 1POW. -->Fin| --<| --:Fin| --+[#990000]Additional loss:[/#]|: For eating the body you lose an additional **1/1D6 SAN for Violence**--+| --+| [c] [button]SAN::~TheScenario|repeating_sanlosses_$0_scenelossb[/button] [/c] --<| }} The ugly pink buttons are built into Roll20. The only way I know of to change them is to use something like Styler (chrome addon) to modify the associated styles. That said, my Encounter Helper addon creates it own buttons, so I could look at porting that code over to ScriptCards to allow customization of buttons. Gimme a bit of research time and I'll see what I can come up with. As for rounding up, I'll include a setting that allows rounding to be toggled to round up instead of down. That should be fairly easy to implement.
1612491438
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
thank you so much... and it's an amazing script
1612493900
timmaugh
Pro
API Scripter
This does look like quite the script, Kurt. Well done! Kurt J. said: The ugly pink buttons are built into Roll20. The only way I know of to change them is to use something like Styler (chrome addon) to modify the associated styles. That said, my Encounter Helper addon creates it own buttons, so I could look at porting that code over to ScriptCards to allow customization of buttons. Gimme a bit of research time and I'll see what I can come up with. I allow customizable buttons in InsertArg . The user can enter (some) CSS into the command line or store a bit of CSS in a config handout. You can see an example in that script/thread, if it helps. If you want to steal the code, I can get you the relevant lines.
1612494532
Kurt J.
Pro
API Scripter
timmaugh said: This does look like quite the script, Kurt. Well done! Kurt J. said: The ugly pink buttons are built into Roll20. The only way I know of to change them is to use something like Styler (chrome addon) to modify the associated styles. That said, my Encounter Helper addon creates it own buttons, so I could look at porting that code over to ScriptCards to allow customization of buttons. Gimme a bit of research time and I'll see what I can come up with. I allow customizable buttons in InsertArg . The user can enter (some) CSS into the command line or store a bit of CSS in a config handout. You can see an example in that script/thread, if it helps. If you want to steal the code, I can get you the relevant lines. Thanks :) I ended up porting my button code over from EncounterHelper... turned out to be pretty easy, so it will be in the next release along with the roundup option.
1612498544
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
you are the best!
timmaugh said: Kurt J. said: GiGs said: Alternatively, just let me know what i need to change in MEGS to work with scriptcards. I think the only thing that would need to change is in this function: const getSender = msg => { const character = findObjs({ type: 'character', name: msg.who })[0], player = getObj('player', msg.playerid); if (character) return 'character|'+character.id; else return 'player|'+player.id; }; When using sendChat, the SpeakingAs parameter fills in msg.who, but msg.playerid will always be "API" (I haven't found a way to change that). ScriptCards (and powercards) just pass along whatever they got for msg.who so if I'm reading things right, the only time the crash indicated above would happen is when the GM (who's msg.who value doesn't equal a character name) runs something that calls !megs via the API. In that case the character lookup will fail by name (for example, my msg.who is "Kurt J (GM)" which isn't a valid character name) and the script will try looking up a player by ID, which will also result in undefined since playerid will be API, which isn't a valid player. Alternatively, you could implement SelectManager for any script that might expect to be called by another API. I just updated SelectManager to also store the  msg.who  and  msg.playerid  properties, so now it tracks all of the items that are typically changed when a message goes through an API call. If you have your script declared as dependent on SelectManager, you could use it directly: msg.who = SelectManager.GetWho(); Otherwise, if you left it optional (until SelectManager gets into the one-click): let getWho = () => {}; on('ready', () => { if(undefined !== typeof SelectManager) getWho = () => SelectManager.GetWho (); }); // ... // after making sure this script should catch the message msg.who = getWho(); I'm headed over to update the script thread with the new access, then I'll submit it to the one-click. Should hopefully make it in next week. Tim - I didn't know that SelectManager existed and followed the link to review and implement.  I did the following: 1) added SelectManager to my active scripts 2) added the 3 lines of code (referenced in option 2) to three different API functions (ScriptCards, StatusMarkers, and ChatSetAttr). The ChatSetAttr function has syntax for apply changes to the currently selected token     ScriptCards version: '--@modbattr|_sel _HP|[$Heal]' This code wasn't working previously, with an error message stating that no Token was selected.  It now works - Thank You! I'm still a little confused around how to implement your Option 1, and the comments in the !ScriptCards forum (2/4/21 @12:31) you are making to improve ScriptManager.
1612554538
Duncan R.
Pro
Sheet Author
Hi. Came across scriptcards just after taking out my Pro membership. I have it nearly doing what I want, the the only thing is some of my modifiers are stored in fieldsets. Is there any way to access these within scriptcards? I could do it by adding attributes directly to the character sheet or customising it, but that isn’t very maintainable. So the only other way I can think of is calling an API from within scriptcards.
1612556107
Kurt J.
Pro
API Scripter
Duncan R. said: Hi. Came across scriptcards just after taking out my Pro membership. I have it nearly doing what I want, the the only thing is some of my modifiers are stored in fieldsets. Is there any way to access these within scriptcards? I could do it by adding attributes directly to the character sheet or customising it, but that isn’t very maintainable. So the only other way I can think of is calling an API from within scriptcards. I'm not familiar with the sheet design process, but I'm assuming that a fieldset is what gives you repeating rows on a sheet? I have been contemplating how to handle retrieving repeating row data, and I've got a few ideas on how to handle it. Hopefully I'll get some time to implement it over the weekend.
1612558658
Duncan R.
Pro
Sheet Author
Yes that is correct the repeating rows, they appear in the character sheet html as fieldsets. If you get time to look at the issue that would be amazing. I have done a tiny bit of JS and HTML over the years, but completely new to the roll20 API, so would take me ages. I am running the Expanse/AGE system, but I don't see that should be a huge issue,
Kurt J. said: Duncan R. said: Hi. Came across scriptcards just after taking out my Pro membership. I have it nearly doing what I want, the the only thing is some of my modifiers are stored in fieldsets. Is there any way to access these within scriptcards? I could do it by adding attributes directly to the character sheet or customising it, but that isn’t very maintainable. So the only other way I can think of is calling an API from within scriptcards. I'm not familiar with the sheet design process, but I'm assuming that a fieldset is what gives you repeating rows on a sheet? I have been contemplating how to handle retrieving repeating row data, and I've got a few ideas on how to handle it. Hopefully I'll get some time to implement it over the weekend. It would be nice if someone would write a script that would make it easy to manage (view/add/modify/delete) repeating row data items.   
1612560814
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
Duncan R. said: Hi. Came across scriptcards just after taking out my Pro membership. I have it nearly doing what I want, the the only thing is some of my modifiers are stored in fieldsets. Is there any way to access these within scriptcards? I could do it by adding attributes directly to the character sheet or customising it, but that isn’t very maintainable. So the only other way I can think of is calling an API from within scriptcards. mmmh it depends what you need to do: if you know the position of your modifier you can simply do this repeating_<namefield>_$<number>_<nameattribute> If a roll is the sum of all the modifiers in a repeating section... well I'd do it on the sheet. Make an hidden variable that is triggered on:opened  or on:change , and do the sum over all the elements in an array (containing all the ids). 
1612565577
Kurt J.
Pro
API Scripter
ScriptCards v 0.0.11 There is a new version of ScriptCards up on the GIST. Here are the changes/updates: Button Customization and New Defaults - Buttons added through the [button]Text::Action[/button] sequence now have the blue background of the title card by default (instead of Roll20's dreaded bright pink buttons). New settings for buttonbackgroundcolor , buttontextcolor , and buttonbordercolor allow you to customize the appearance of your buttons.              Plain Text in Roll Equations - You could previously include "flavor text" in rolls by enclosing it in square brackets like [Strength]. If you set the allowplaintextinrolls setting to a non-zero value, you can now exclude the square brackets if desired. New Round Up Setting - By default, integer division rounds down. If roundup is set to a non-default (the default is 0) integer division will round up instead. Dice Font Support - Roll20 includes fonts for each type of standard dice, and there are now inline formatting options to allow you display them in your output. These format markup sequences are [d4]..[/d4], [d6]..[/d6], [d8]..[d8], [d10]..[/d10], [d12]..[/d12] and [d20]..[/d20], so for example to display an 8-sided die on the 4 face: [d8]4[/d8]. Of course variables can be used to specify the face. There are new settings to allow for customization of how the dice are displayed: dicefontcolor , dicefontsize , and usehollowdice .              
How do I whisper the card to myself (GM only)?
1612566012
Kurt J.
Pro
API Scripter
Will M. said: How do I whisper the card to myself (GM only)? I forgot to add this :) Next version! :)
Kurt J. said: Will M. said: How do I whisper the card to myself (GM only)? I forgot to add this :) Next version! :) I've spent the past 2 days converting my macros over to this ScriptCards.  Loving the functionality.
Kurt J. said: Will M. said: How do I whisper the card to myself (GM only)? I forgot to add this :) Next version! :) Ah! I was going to ask the same thing. Hugely loving what you've done so far, Kurt, and looking forward to whisper functionality!
1612566980
Duncan R.
Pro
Sheet Author
Marco M. said: mmmh it depends what you need to do: if you know the position of your modifier you can simply do this repeating_<namefield>_$<number>_<nameattribute> If a roll is the sum of all the modifiers in a repeating section... well I'd do it on the sheet. Make an hidden variable that is triggered on:opened  or on:change , and do the sum over all the elements in an array (containing all the ids).  I don't think, without modifying the character sheet that would be possible (and I don't really want to start changing them from the support sheets if I can help it). They are free text lists, so they could be in any order and what you are looking for may or may not be there. There is two way on the sheet you could do it, either manually calculate it by the abilities and focus etc, or take it from the summary. But even the summary is a list. So for this section (screenshot and code below), I would want to check if a weapon type of 'Pistol' existed if it did I would want to pass the +5 to scriptcards, if it didn't exist I would want to default to 0. The list is free text and can appear in any order, or not at all, and obviously, a typo in the weapon name would still mess things up. Of course, having been using APIs for about 3 days I could be talking rubbish. <div class="row"> <div class="section sectionfull attack-container"> <div class="section-name"> <div class="col repeatingcol col-attack-name"> <span data-i18n="attack-u">WEAPON TYPE</span> </div> <div class="col repeatingcol col-attack-range"> <span data-i18n="range-u">RANGE</span> </div> <div class="col repeatingcol col-attackdice"> <span data-i18n="roll-u">ATT. MOD.</span> </div> <div class="col repeatingcol col-attack-damage"> <span data-i18n="damage-u">DAMAGE</span> </div> </div> <fieldset class="repeating_attack-list"> <div class="col repeatingcol col-attack-name"> <input type="text" name="attr_attack-name"> </div> <div class="col repeatingcol col-attack-range"> <input type="text" name="attr_range"> </div> <div class="col repeatingcol col-attackdice"> <input type="text" placeholder="1" name="attr_attackroll"> <button type="roll" class="attackroll-noaim" value="@{wtype}&{template:default} {{name=@{char-name-option}@{attack-name}}}{{Roll=[[1d6cs>7cf<0]] [[1d6cs>7cf<0]] [[1d6cs>1cf<6]]}}{{Bonus=[[@{attackroll}]]}}{{Range (+0/-2)=@{range}}} }" name="roll_attackdice"></button> <button type="roll" class="attackroll-withprompt" value="@{wtype}&{template:default} {{name=@{char-name-option}@{attack-name}}}{{Roll=[[1d6cs>7cf<0]] [[1d6cs>7cf<0]] [[1d6cs>1cf<6]]}}{{Bonus=[[@{attackroll}]]}}{{Aim=[[@{aim-select}]]}}{{Range (+0/-2)=@{range}}}}" name="roll_attackdice"></button> </div> <div class="col repeatingcol col-attack-damage"> <input type="text" placeholder="2d6+1" name="attr_attack-damage"> <button type="roll" value="@{wtype}&{template:default} {{name=@{char-name-option}@{attack-name}}}{{Damage=[[@{attack-damage}]]}}" name="roll_weapondamage"></button> </div> </fieldset> <div class="col-weapon-groups"> <input type="text" placeholder="Weapon groups" name="attr_weapon-groups"> </div> </div>
1612567329
Kurt J.
Pro
API Scripter
ScriptCards 0.0.11a - Whisper Support Whisper support is in. Set whisper to names, "gm" or self (separated by commas, so "self,gm" for example) to send card as a whisper. (ie, --#whisper|gm) You an also set  showfromfornonwhispers to a non-zero value to include senders on non-whisper cards. By default this is off.
1612569352

Edited 1612569379
Marco M.
KS Backer
Sheet Author
API Scripter
Compendium Curator
Duncan R. said: I don't think, without modifying the character sheet that would be possible (and I don't really want to start changing them from the support sheets if I can help it). They are free text lists, so they could be in any order and what you are looking for may or may not be there. There is two way on the sheet you could do it, either manually calculate it by the abilities and focus etc, or take it from the summary. But even the summary is a list. So for this section (screenshot and code below), I would want to check if a weapon type of 'Pistol' existed if it did I would want to pass the +5 to scriptcards, if it didn't exist I would want to default to 0. The list is free text and can appear in any order, or not at all, and obviously, a typo in the weapon name would still mess things up. Of course, having been using APIs for about 3 days I could be talking rubbish. <div class="row"> <div class="section sectionfull attack-container"> <div class="section-name"> <div class="col repeatingcol col-attack-name"> <span data-i18n="attack-u">WEAPON TYPE</span> </div> <div class="col repeatingcol col-attack-range"> <span data-i18n="range-u">RANGE</span> </div> <div class="col repeatingcol col-attackdice"> <span data-i18n="roll-u">ATT. MOD.</span> </div> <div class="col repeatingcol col-attack-damage"> <span data-i18n="damage-u">DAMAGE</span> </div> </div> <fieldset class="repeating_attack-list"> <div class="col repeatingcol col-attack-name"> <input type="text" name="attr_attack-name"> </div> <div class="col repeatingcol col-attack-range"> <input type="text" name="attr_range"> </div> <div class="col repeatingcol col-attackdice"> <input type="text" placeholder="1" name="attr_attackroll"> <button type="roll" class="attackroll-noaim" value="@{wtype}&{template:default} {{name=@{char-name-option}@{attack-name}}}{{Roll=[[1d6cs>7cf<0]] [[1d6cs>7cf<0]] [[1d6cs>1cf<6]]}}{{Bonus=[[@{attackroll}]]}}{{Range (+0/-2)=@{range}}} }" name="roll_attackdice"></button> <button type="roll" class="attackroll-withprompt" value="@{wtype}&{template:default} {{name=@{char-name-option}@{attack-name}}}{{Roll=[[1d6cs>7cf<0]] [[1d6cs>7cf<0]] [[1d6cs>1cf<6]]}}{{Bonus=[[@{attackroll}]]}}{{Aim=[[@{aim-select}]]}}{{Range (+0/-2)=@{range}}}}" name="roll_attackdice"></button> </div> <div class="col repeatingcol col-attack-damage"> <input type="text" placeholder="2d6+1" name="attr_attack-damage"> <button type="roll" value="@{wtype}&{template:default} {{name=@{char-name-option}@{attack-name}}}{{Damage=[[@{attack-damage}]]}}" name="roll_weapondamage"></button> </div> </fieldset> <div class="col-weapon-groups"> <input type="text" placeholder="Weapon groups" name="attr_weapon-groups"> </div> </div> mmmh if you need the modifier just to roll an attack why don't just adding a button inside the script? --+| [c] [button]ATTACK::~selected|repeating_attack-list_$0_attackdice[/button] [/c] It might be too simple, but works wonderfully. And now you can style your box as your game output for consistency
Kurt J. said: ScriptCards 0.0.11a - Whisper Support Whisper support is in. Set whisper to names, "gm" or self (separated by commas, so "self,gm" for example) to send card as a whisper. (ie, --#whisper|gm) You an also set  showfromfornonwhispers to a non-zero value to include senders on non-whisper cards. By default this is off. Nice - It Works!
1612573943
Duncan R.
Pro
Sheet Author
Marco M. said: mmmh if you need the modifier just to roll an attack why don't just adding a button inside the script? --+| [c] [button]ATTACK::~selected|repeating_attack-list_$0_attackdice[/button] [/c] It might be too simple, but works wonderfully. And now you can style your box as your game output for consistency Based on the above (thanks) that gets me a bit further I can get it to appear correctly in the script by doing --=attackbonus|@{selected|repeating_attack-list_$0_attackroll} but I still have the original issue that I need to make sure that I always put weapons (or whatever you are selecting) in exactly the same order for every weapon on every character sheet, as I cant search for the correct field. So it works but it still isn't maintainable, especially once you have lots of players rolling their own characters. So I sort of circle back around to a call to an external API or a feature in ScriptCards to find the right item in the list. Unless I am missing something?
1612575214
Kurt J.
Pro
API Scripter
Duncan R. said: Marco M. said: mmmh if you need the modifier just to roll an attack why don't just adding a button inside the script? --+| [c] [button]ATTACK::~selected|repeating_attack-list_$0_attackdice[/button] [/c] It might be too simple, but works wonderfully. And now you can style your box as your game output for consistency Based on the above (thanks) that gets me a bit further I can get it to appear correctly in the script by doing --=attackbonus|@{selected|repeating_attack-list_$0_attackroll} but I still have the original issue that I need to make sure that I always put weapons (or whatever you are selecting) in exactly the same order for every weapon on every character sheet, as I cant search for the correct field. So it works but it still isn't maintainable, especially once you have lots of players rolling their own characters. So I sort of circle back around to a call to an external API or a feature in ScriptCards to find the right item in the list. Unless I am missing something? Support for repeating attributes is coming for ScriptCards... I'm just working on how to do it in a reasonable way. Right now my plan is to have a statement type that will load a section into the script by providing a section name, an attribute name to search, and a string to search for. So, for example, you could search "attack","attkname","Greatsword" (5E sheet) and it would look for a repeating_attack_XXX_atkname that matched "Greatsword" and make all of its properties available through a syntax similar to the standard attribute inclusion. I have this partially working right now, but I'd like to enhance it a bit before including it in a release.
Can a button be used to call an --@ API command? If so, what is the right syntax? Or do I need to store that API command in a separate variable?
Kurt this is amazing! Was slacking a bit on forum threads but this got me hooked :D had to read all posts and cant wait to give it a try :)
OK, so after banging my (non-programmer) head against the wall, I've got a rudimentary healing potion macro (using Scriptcards) up and running. Yay! Now I'm trying to write a scriptcard to show my party's potion inventory (how many of each type of healing potion each character has). I worked off the health status macro on the Wiki and this is what I came up with: !scriptcard  {{   --#title|Display Healing Potions   --#leftsub|Team A   -->PotionCheck|@{Idina Barzin|character_id}   -->PotionCheck|@{Iorminas|character_id}   -->PotionCheck|@{Leonora Duarte|character_id}   -->PotionCheck|@{Melody Litchfield|character_id}   -->PotionCheck|@{Thezumin Yeltoris|character_id}   --X|End of card Execution   --:PotionCheck|   --:Healing|   --=Healing|[*[%1%]:other_resource]   --=HealingColor|00C301   --?[$Healing] -ge 1|HealingSkip   --=HealingColor|FF0000   --:HealingSkip|   --^|GreaterHealing   --:GreaterHealing|   --=GreaterHealing|[*[%1%]:repeating_resource_$0_resource_left]   --=GreaterHealingColor|00C301   --?[$GreaterHealing] -ge 1|GreaterHealingSkip   --=GreaterHealingColor|FF0000   --:GreaterHealingSkip|   --^|SuperiorHealing   --:SuperiorHealing|   --=SuperiorHealing|[*[%1%]:repeating_resource_$0_resource_right]   --=SuperiorHealingColor|00C301   --?[$SuperiorHealing] -ge 1|SuperiorHealingSkip   --=SuperiorHealingColor|FF0000   --:SuperiorHealingSkip|   --^|SupremeHealing   --:SupremeHealing|   --=SupremeHealing|[*[%1%]:repeating_resource_$1_resource_left]   --=SupremeHealingColor|00C301   --?[$SupremeHealing] -ge 1|SupremeHealingSkip   --=SupremeHealingColor|FF0000   --:SupremeHealingSkip|   --^|PotionDisplay      --:PotionDisplay|   --+[*[%1%]:character_name]:|[b][#[$HealingColor.RollText]][*[%1%]:other_resource][/#][/b] healing, [b][#[$GreaterHealingColor.RollText]][*[%1%]:repeating_resource_$0_resource_left][/#][/b] greater healing, [b][#[$SuperiorHealingColor.RollText]][*[%1%]:repeating_resource_$0_resource_right][/#][/b] superior healing, [b][#[$SupremeHealingColor.RollText]][*[%1%]:repeating_resource_$1_resource_left][/#][/b] supreme healing   --<|End of PotionDisplay   --<|End of PotionCheck }} It works fine, *except* that it persistently gets the number of superior healing potions wrong for the first character on the list (Idina). Always says she has 2 potions of superior healing when the character sheet clearly says 0. What am I doing wrong/missing?
1612753882
Kurt J.
Pro
API Scripter
Jay R. said: OK, so after banging my (non-programmer) head against the wall, I've got a rudimentary healing potion macro (using Scriptcards) up and running. Yay! Now I'm trying to write a scriptcard to show my party's potion inventory (how many of each type of healing potion each character has). I worked off the health status macro on the Wiki and this is what I came up with: !scriptcard  {{   --#title|Display Healing Potions   --#leftsub|Team A   -->PotionCheck|@{Idina Barzin|character_id}   -->PotionCheck|@{Iorminas|character_id}   -->PotionCheck|@{Leonora Duarte|character_id}   -->PotionCheck|@{Melody Litchfield|character_id}   -->PotionCheck|@{Thezumin Yeltoris|character_id}   --X|End of card Execution   --:PotionCheck|   --:Healing|   --=Healing|[*[%1%]:other_resource]   --=HealingColor|00C301   --?[$Healing] -ge 1|HealingSkip   --=HealingColor|FF0000   --:HealingSkip|   --^|GreaterHealing   --:GreaterHealing|   --=GreaterHealing|[*[%1%]:repeating_resource_$0_resource_left]   --=GreaterHealingColor|00C301   --?[$GreaterHealing] -ge 1|GreaterHealingSkip   --=GreaterHealingColor|FF0000   --:GreaterHealingSkip|   --^|SuperiorHealing   --:SuperiorHealing|   --=SuperiorHealing|[*[%1%]:repeating_resource_$0_resource_right]   --=SuperiorHealingColor|00C301   --?[$SuperiorHealing] -ge 1|SuperiorHealingSkip   --=SuperiorHealingColor|FF0000   --:SuperiorHealingSkip|   --^|SupremeHealing   --:SupremeHealing|   --=SupremeHealing|[*[%1%]:repeating_resource_$1_resource_left]   --=SupremeHealingColor|00C301   --?[$SupremeHealing] -ge 1|SupremeHealingSkip   --=SupremeHealingColor|FF0000   --:SupremeHealingSkip|   --^|PotionDisplay      --:PotionDisplay|   --+[*[%1%]:character_name]:|[b][#[$HealingColor.RollText]][*[%1%]:other_resource][/#][/b] healing, [b][#[$GreaterHealingColor.RollText]][*[%1%]:repeating_resource_$0_resource_left][/#][/b] greater healing, [b][#[$SuperiorHealingColor.RollText]][*[%1%]:repeating_resource_$0_resource_right][/#][/b] superior healing, [b][#[$SupremeHealingColor.RollText]][*[%1%]:repeating_resource_$1_resource_left][/#][/b] supreme healing   --<|End of PotionDisplay   --<|End of PotionCheck }} It works fine, *except* that it persistently gets the number of superior healing potions wrong for the first character on the list (Idina). Always says she has 2 potions of superior healing when the character sheet clearly says 0. What am I doing wrong/missing? One of the quirks of repeating sections on roll20 is that the order isn't necessarily what you might expect it to be, especially if rows were added/deleted on a given character. This means that $0 might be the one that looks like it is in the first added repeating resources spot, but it might not be. The next version of ScriptCards will have a mechanism for dealing with repeating sections without relying on index numbers. Currently I'm targeting Monday or Tuesday night for that release. The code is done, but I need to do some more testing and documenting.
1612753957
Kurt J.
Pro
API Scripter
Jay R. said: Can a button be used to call an --@ API command? If so, what is the right syntax? Or do I need to store that API command in a separate variable? If the first character in a button's command property is an exclamation point, the same _ to -- replacement code will be run on the command text, so a button can make API calls by including the command directly, but not by using --@.
Kurt J. said: It works fine, *except* that it persistently gets the number of superior healing potions wrong for the first character on the list (Idina). Always says she has 2 potions of superior healing when the character sheet clearly says 0. What am I doing wrong/missing? One of the quirks of repeating sections on roll20 is that the order isn't necessarily what you might expect it to be, especially if rows were added/deleted on a given character. This means that $0 might be the one that looks like it is in the first added repeating resources spot, but it might not be. The next version of ScriptCards will have a mechanism for dealing with repeating sections without relying on index numbers. Currently I'm targeting Monday or Tuesday night for that release. The code is done, but I need to do some more testing and documenting. Wow, I had no idea! Been assuming that seeing the $0 or $1 after hovering over the field meant I could just call that field via ChatSetAttr and all would be well. Thanks for the heads-up. Looking forward to that next version!
Kurt J. said: Jay R. said: Can a button be used to call an --@ API command? If so, what is the right syntax? Or do I need to store that API command in a separate variable? If the first character in a button's command property is an exclamation point, the same _ to -- replacement code will be run on the command text, so a button can make API calls by including the command directly, but not by using --@. Awesome, good to know!
1612761871
timmaugh
Pro
API Scripter
Will M. said: Tim - I didn't know that SelectManager existed and followed the link to review and implement.  I did the following: ...snip... The ChatSetAttr function has syntax for apply changes to the currently selected token     ScriptCards version: '--@modbattr|_sel _HP|[$Heal]' This code wasn't working previously, with an error message stating that no Token was selected.  It now works - Thank You! I'm still a little confused around how to implement your Option 1, and the comments in the !ScriptCards forum (2/4/21 @12:31) you are making to improve ScriptManager. First, glad that helped make it work! That first option (the script-dependency path) would be for the script developer to implement. For instance, once SelectManager is in the 1-click install package (next week), if Jakob updated ChatSetAttr himself, he could edit the script.json file to require SelectManager to be installed any time a user installed ChatSetAttr. Since he would then know that SelectManager would always be available, he could use the first option to just reach out and access the appropriate functions straight off the library. But that option requires both scripts to be installed from the 1-click.
1612794440

Edited 1612794483
David M.
Pro
API Scripter
Noticed a minor parsing quirk: Leading spaces in a conditional branch label appear to be allowed in the True branch, but not the False branch. In the example scriptcard below, this will work: --?[&Val_1] -inc SomeText| >SetVal2;[&Val_1]|>SetVal2;Some other text was entered but this won't: --?[&Val_1] -inc SomeText|>SetVal2;[&Val_1]| >SetVal2;Some other text was entered Not sure which behavior is intentional, so just bringing it up :) !scriptcard {{ --#title|If/Then/Else + Function with Arg --:Initialize String Var| --&Val_1|+?{InputVal?|SomeText} --+Val_1 =|[&Val_1] --:Set Val_2 equal to Val_1 if user entered "SomeText", otherwise give alternate msg| --?[&Val_1] -inc SomeText|>SetVal2;[&Val_1]|>SetVal2;Some other text was entered --+Val_2 =|[&Val_2] --X| End Macro --:SetVal2| --&Val_2|[%1%] --<| }}
1612801527
timmaugh
Pro
API Scripter
Marco M. said: Duncan R. said: Hi. Came across scriptcards just after taking out my Pro membership. I have it nearly doing what I want, the the only thing is some of my modifiers are stored in fieldsets. Is there any way to access these within scriptcards? I could do it by adding attributes directly to the character sheet or customising it, but that isn’t very maintainable. So the only other way I can think of is calling an API from within scriptcards. mmmh it depends what you need to do: if you know the position of your modifier you can simply do this repeating_<namefield>_$<number>_<nameattribute> If a roll is the sum of all the modifiers in a repeating section... well I'd do it on the sheet. Make an hidden variable that is triggered on:opened  or on:change , and do the sum over all the elements in an array (containing all the ids).  I updated APILogic this morning to help with this very question. (APIL should intercept messages before they reach the intended script destination, letting you perform checks on the command line and do things like perform if/else checks and evaluate requests for the name of a repeating sheet item). I ...think?... I read that Kurt was implementing his own way of differentiating a repeating item, which will probably be more apropos to the ScriptCards command syntax once he releases it. But if you are in a pinch until that gets in place, check out this post  and the associated thread to see how to do it in an APIL tag embedded in a ScriptCards call.
1612826357

Edited 1612831905
Kurt J.
Pro
API Scripter
ScriptCards 0.0.13 is now available on the Development GIST A new YouTube video covering a deep-dive on an enhanced version of the Magic Missile script is available at&nbsp; <a href="https://www.youtube.com/watch?v=u50xvNzS9Zk" rel="nofollow">https://www.youtube.com/watch?v=u50xvNzS9Zk</a> &nbsp;where I cover adding visual and audio effects to the card, tracking spell slot usage, conditional subtitle assignment, and applying damage with both token-mod and with alterbars. Lots of updates in 0.0.13, so here we go: Bug Fix: Fixed a parsing bug that didn't allow leading spaces before the "false" branch of a conditional. New Operators: Two new conditional operators have been added, -eqi and -nei. These are case-insensitive versions of -eq and -ne (-inc is already non-case sensitive). Decimals In Roll Equations: Prior to 0.0.13, numbers with decimals were not recognized as numbers by the roll processor. Variable Replacement Changes : The substitution code for string variables is now a separate function from roll variable replacement. This allows me to run string variable replacement on the content of a --= statement, so you could store dice roll information in a string (--&amp;) and then pass that to a roll assignment. Repeating Section Access : It is now possible. The implementation I've gone with is to allow a single repeating row to be "active" at any point while the script is running. There is a new statement type (--R) to work with repeating section rows. You can find a specific row by looking for a key value in the row, or you can iterate through all of the rows in the section. This will probably end up generating an entire video on its own, but please check the wiki for details . Built-In Functions : Another new statement type (--~) allows functions built into ScriptCards to be run and assign their results to a roll variable. For the introduction of this feature, there is only one function (well, three, but they all do almost the same thing). These are "distance", "euclideandistance", and "manhattandistance" that measure the distance between tokens. The default (distance) uses Chebyshev distance, which is the distance measurement that D&amp;D 5E (and 4E) uses. Again, check the wiki for additional details. The idea behind this feature is to allow for functionality that would be difficult, lengthy, or impossible to implement directly as a ScriptCard script, so I am open to ideas as to what kinds of things would be useful here.
1612828206
Duncan R.
Pro
Sheet Author
Looks good, thanks for all the effort. I have added in the new API script version but getting a bit late here now, so a test 'the repeat function' tomorrow task now. The -eqi and -nei change made me think. Is the Rfind case sensitive, I couldn't see it in the Wiki, I assume it is?
Kurt J. said: ScriptCards 0.0.13 is now available on the Development GIST A new YouTube video covering a deep-dive on an enhanced version of the Magic Missile script is available at&nbsp; <a href="https://www.youtube.com/watch?v=u50xvNzS9Zk" rel="nofollow">https://www.youtube.com/watch?v=u50xvNzS9Zk</a> &nbsp;where I cover adding visual and audio effects to the card, tracking spell slot usage, conditional subtitle assignment, and applying damage with both token-mod and with alterbars. Lots of updates in 0.0.13, so here we go: Repeating Section Access : It is now possible. The implementation I've gone with is to allow a single repeating row to be "active" at any point while the script is running. There is a new statement type (--R) to work with repeating section rows. You can find a specific row by looking for a key value in the row, or you can iterate through all of the rows in the section. This will probably end up generating an entire video on its own, but please check the wiki for details . Built-In Functions : Another new statement type (--~) allows functions built into ScriptCards to be run and assign their results to a roll variable. For the introduction of this feature, there is only one function (well, three, but they all do almost the same thing). These are "distance", "euclideandistance", and "manhattandistance" that measure the distance between tokens. The default (distance) uses Chebyshev distance, which is the distance measurement that D&amp;D 5E (and 4E) uses. Again, check the wiki for additional details. The idea behind this feature is to allow for functionality that would be difficult, lengthy, or impossible to implement directly as a ScriptCard script, so I am open to ideas as to what kinds of things would be useful here. *mind exploding because of things now possible* Can't wait to this stuff out!