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

1633130360
Kurt J.
Pro
API Scripter
timmaugh said: Kurt's exactly right, but you'll also need to defer the get statement (which would retrieve the variable from the Mule): get^.[&Form] I wrote up a longer explanation in the Muler thread . @Kurt, it didn't apply this time, but this question made me wonder about a "re-entry deferral" character for SC... or if that's the right concept. Basically, it would come down to how you handle the reentry. I'm just wondering if there would be a way to expose metascript constructs (or other constructs) only *after* reentry. For instance, if you expect a downstream/outbound call to set a Mule variable, you wouldn't want to retrieve it until after the SC was reentered. The hang-up is that the metascripts would only trigger if the message containing them went through the Roll20 parser, so if you store the message object from the initial SC call (with all of the processing done in it, including any command line changes and/or variables, arrays, etc.), then by the time SC received the reentry command to "un-mothball" that stored message object, it would be too late -- that unmothballing wouldn't go through the parsers. You have a way better understanding of that reentry coding, so I'll leave it to you, but I could see at least the above situation potentially solved by a SC dispatched call with a newly generated, prepended UUID, which SC would know to catch. By the time it caught it, however, the metascripts would have had their chance, too. !-M1234567890abcdef_script <<existing command line after deferral removal>> Then the messages would have to be merged (old/saved with the newly caught). This is the same process ZeroFrame uses. Anyway, it might be not worth the effort, but I thought I'd mention it! I'd have to do some testing, but it should actually work this way already (assuming I'm understanding it correctly). When a reentrant script is stashed, the original text of the script is saved and simply reloaded when the reentrant call is made, so the deferral character doesn't get dealt with until the --@ line executes. In fact, the reentrant section could be executed multiple times with different things to get deferred and it should behave as expected. Essentially the only thing pre-parsed are --: label names so other lines can refer to them. Everything else is interpreted as the line is executed.
1633133199

Edited 1633133446
timmaugh said: get^.[&Form] Ok, I'm getting closer . !script {{ --#whisper|gm --#sourcetoken|@(selected|token_id) --#activepage|[*S:t-pageid] --=Snap|[*P:snapping_increment] --=Scale|[*P:scale_number] / 5 --=TokenScale|70 * [$Snap] * [$Scale] --~Name|string;before; ;[*S:character_name] --#title|[&Name]'s Wildshapes --#leftsub|[*S:class_resource] Uses Left --#reentrant|[&Name]WS --?[*S:class_resource] -lt 1|NoWS --:WSLookup| --+Large Land Animals|[rbutton]Brown Bear::WildShape;Brown Bear[/rbutton] [rbutton]Giant Goat::WildShape;Giant Goat[/rbutton] [rbutton]Warhorse::WildShape;Warhorse[/rbutton] --X| --:WildShape|chosen form --#hideTitleCard|1 --~Form|string;replace; ;;[&reentryval] --@script|_#hideCard|1 _#title|SettingVars| _#debug|1 _&Side|get^^.[&Form] {^& mule [&Name].WSMule} _=hp|@^([&Name]'s [&reentryval]|npc_hpformula) {^& log} --&Size|[*@^([&Name]'s [&reentryval]|character_id)|token_size] --@token-mod|_set currentside|[&Side] height|[$TokenScale]*[&Size] width|[$TokenScale]*[&Size] represents|"[&Name]'s [&reentryval]" bar1_link|hp hp|[$hp] bar2_link|npc_ac bar3_link|passive_wisdom --X| --:NoWS| --+No More Wildshapes!|Rest before using. --X| }} And here is my log output:   LOOP 1 !script --#hideCard|1 --#title|SettingVars| --#debug|1 --&Side|get^.BrownBear {& mule Diane.WSMule} --=hp|@(Diane's Brown Bear|npc_hpformula) {& log}   SELECTMANAGER   MULERGET !script --#hideCard|1 --#title|SettingVars| --#debug|1 --&Side|get^.BrownBear --=hp|@(Diane's Brown Bear|npc_hpformula)   FETCH !script --#hideCard|1 --#title|SettingVars| --#debug|1 --&Side|get^.BrownBear --=hp| NOTES: Unable to find character for @(Diane's Brown Bear|npc_hpformula). Using default value.   MATHOPS   MULERSET   LOOP 2 !script --#hideCard|1 --#title|SettingVars| --#debug|1 --&Side|get^.BrownBear --=hp|   SELECTMANAGER   MULERGET   FETCH   MATHOPS   MULERSET   OUTRO FINAL MESSAGE !script --#hideCard|1 --#title|SettingVars| --#debug|1 --&Side|get^.BrownBear --=hp|   So, the mule is loaded at the right time: check! But now the get  fails--I have also tried adding a second deferral (i.e. get^^.[&Form] ) and removing the get  deferral, which have both failed. My best guess is that the reason for this originates in ScriptCards rather than the Metascripts, because I *think* it's up to ScriptCards to detect the deferral character in this instance. The fetch  call is also failing for some reason, even though the exact same call works outside this SC. (I.e., I can use @(Diane's Brown Bear|npc_hpformula) in a different context altogether, and get the correct result of 4d10+12.
1633145768
timmaugh
Pro
API Scripter
Kurt J. said: I'd have to do some testing, but it should actually work this way already (assuming I'm understanding it correctly). When a reentrant script is stashed, the original text of the script is saved and simply reloaded when the reentrant call is made, so the deferral character doesn't get dealt with until the --@ line executes. In fact, the reentrant section could be executed multiple times with different things to get deferred and it should behave as expected. Essentially the only thing pre-parsed are --: label names so other lines can refer to them. Everything else is interpreted as the line is executed. Hmm... the "original" message that is stored would be, I think, the already-modified-by-metascripts command line. If it isn't part of the button that would drive the re-entry (so that it would pass through the Roll20 parsers), then by the time ScriptCards would load it, it might be too late for metascripts (that's where I was suggesting a "hidden" message). But the idea of a reentry deferral character would be slightly different from the deferral character for an outbound call. For instance, if I put meta constructs in the body of a SC call, they will get processed immediately. If I put constructs in an outbound call from SC, I can use the deferral character to delay their detection until the command is dispatched -- whether that is on the first pass through the ScriptCard code or after reentry. However, if that outbound call performed some function which needed to be detected by a metascript construct *after* that, in the main body of the ScriptCard after reentry, then the user might need a way to make sure the meta construct is detected at the point the script is re-entered... (if it makes sense that line-processing would continue after reentry -- and like you say, the line isn't interpreted until the line is executed). I'm not sure I'm explaining this very well...
1633147430
timmaugh
Pro
API Scripter
Colin C. said: Ok, I'm getting closer . So, the mule is loaded at the right time: check! But now the get  fails--I have also tried adding a second deferral (i.e. get^^.[&Form] ) and removing the get  deferral, which have both failed. My best guess is that the reason for this originates in ScriptCards rather than the Metascripts, because I *think* it's up to ScriptCards to detect the deferral character in this instance. The fetch  call is also failing for some reason, even though the exact same call works outside this SC. (I.e., I can use @(Diane's Brown Bear|npc_hpformula) in a different context altogether, and get the correct result of 4d10+12. What does the WSMule mule look like on the Diane character? Does it have a BrownBear value (capitalization and space matter)? If so, then one thing to try would be to include the /get portion of the get statement on the backend of the variable name as a clear signal to the parser that the name of the variable has completed: get.variable/get You definitely only want one ^ character, which ScriptCards will remove so that your get statement is available for detection. You might also try including the mule name in your retrieval, so altogether, that would look like: get^.WSMule.BrownBear/get ...or even... get^.Diane.WSMule.BrownBear/get As for the Fetch retrieval failing, I initially wondered if the apostrophe was causing a problem, but I have been able to test that character name in my game, and it returns just fine. As a quick fix, you should be able to use standard (but deferred) roll20 sheet calls, which will be exposed when SC removes the deferral character: @^{Diane's Brown Bear|npc_hpformula} That should work, too... but it's strange that Fetch isn't getting what you need. If you want, you can drop me a PM and invite me to the game and I can poke around to try to see what is going on.
Sadly, I am no closer with those changes. PM incoming.
1633354550

Edited 1633354633
Kurt J.
Pro
API Scripter
timmaugh said: Colin C. said: Ok, I'm getting closer . So, the mule is loaded at the right time: check! But now the get  fails--I have also tried adding a second deferral (i.e. get^^.[&Form] ) and removing the get  deferral, which have both failed. My best guess is that the reason for this originates in ScriptCards rather than the Metascripts, because I *think* it's up to ScriptCards to detect the deferral character in this instance. The fetch  call is also failing for some reason, even though the exact same call works outside this SC. (I.e., I can use @(Diane's Brown Bear|npc_hpformula) in a different context altogether, and get the correct result of 4d10+12. What does the WSMule mule look like on the Diane character? Does it have a BrownBear value (capitalization and space matter)? If so, then one thing to try would be to include the /get portion of the get statement on the backend of the variable name as a clear signal to the parser that the name of the variable has completed: get.variable/get You definitely only want one ^ character, which ScriptCards will remove so that your get statement is available for detection. You might also try including the mule name in your retrieval, so altogether, that would look like: get^.WSMule.BrownBear/get ...or even... get^.Diane.WSMule.BrownBear/get As for the Fetch retrieval failing, I initially wondered if the apostrophe was causing a problem, but I have been able to test that character name in my game, and it returns just fine. As a quick fix, you should be able to use standard (but deferred) roll20 sheet calls, which will be exposed when SC removes the deferral character: @^{Diane's Brown Bear|npc_hpformula} That should work, too... but it's strange that Fetch isn't getting what you need. If you want, you can drop me a PM and invite me to the game and I can poke around to try to see what is going on. The deferral characters currently only support &{...}, @(...) and *(...) since those were what was available at the time. I'll add deferral character support for get. to the github version later today.
1633357219
timmaugh
Pro
API Scripter
Ahh... so it isn't a wholesale replacement of that character in the outbound command line? You are letting the user pick an alternate deferral character, so you *could* do a wholesale replacement of that character, if you wanted. The user would just have to pick a character that doesn't otherwise appear in their command line. If you're going to add it by particular formation, though, you probably should add both: get. and set. ...as that is the other side of getting/setting a mule variable. =D
This may be a stupid question but is it possible to perform multiple actions to a single test on a --? or --c command?  For example:   --? [$X] -eq 1|=Y;42 (and?) =Z; 24|=A;0 This would test X for a 1, and if true, assign 42 to the variable Y and 24 to Z otherwise (else) set A to 0. or   --?[$X] -eq 1|=Y;42 (and?) >OhBoy;[$Y]|=A;0 which would make the same test, assign a value to a variable then send the variable as a parameter to subroutine "OhBoy" otherwise (else) set A to 0.
Yes, but you need different notation to do it. This section of the wiki refers to "code blocks" which is essentially what you're looking for.
Hi everyone :-) Is it possible to do the following with ScriptCards: "If string S is empty, then execute procedure P" ?
Assuming you are defining a procedure as a subroutine then yes, but it takes a little trick to test for an empty string.  I believe the syntax is:   --?[&MyString]X -eq X|PROC_P   ....   code     ...    --:PROC_P| If &MyString is empty, then X is equal to X and the conditional is TRUE taking you to your procedure PROC_P. Will
Will M. said: Assuming you are defining a procedure as a subroutine then yes, but it takes a little trick to test for an empty string.  I believe the syntax is:   --?[&MyString]X -eq X|PROC_P   ....   code     ...    --:PROC_P| If &MyString is empty, then X is equal to X and the conditional is TRUE taking you to your procedure PROC_P. Will That works! Thank you so much! :-D
1633457765

Edited 1633572847
I just added three new scripts to the Working and Sharing forum: Fortune Teller - Link A fun and creative fortune generator script with over 940,000 different possible outcomes.  Great for role-playing.  Sends 3 cards to the party chat and whispers Event/Person/Outcome meaning to the GM, prompting them for a creative fortune.  More details on the linked post. Set Monster HP (With a Twist) -  Link For all selected NPCs, resets HP based on several methods: Default - Standard static HP based on NPC_HPFormula (no randomness) Random - Uses the NPC_HPFormula to derive HP Random High (x Rolls) - Will take the highest value of x(2,5, or 10) random rolls.  Random Low (x Rolls) - Will take the lowest value of x(2,5, or 10) random rolls.  Adder - A value (+/-) to add to the final result.  Can also be in roll syntax (e.g.; 2d6) Manage Token Tooltips -  Link A simple script to add, remove, show/hide the new tooltip token field.  Can work on all selected tokens at once.   It does require the new version of TokenMod 0.8.72.  
Hi everyone :-) Could someone show me an example of how to implement the functions that the wiki mentions under the heading: "Mathematical Functions in Roll Expressions"? I've tried a few possibilities, but to no avail...
1633462426

Edited 1633462622
David M.
Pro
API Scripter
!script {{   --=val|1d6-20   --+val|[$val]   --=val|[$val] {ABS}   --+absolute val|[$val] }} EDIT - Multiple functions can be used in the roll. They just read left to right like normal. The following takes the sqrt of 9, subtracts 5, and takes the absolute value of the whole thing: !script {{   --=val|9 {SQRT} - 5 {ABS}   --+val|[$val] }}
David M. said: !script {{   --=val|9 {SQRT} - 5 {ABS}   --+val|[$val] }} Thanks for replying, you're very helpful :-) I see where you're going there with that code (the one that I quoted)... but...  wouldn't we expect its output to be 2? Because, yeah... when I run it, I get 4 as the output o_O And when I modify your code to make it just take the square root of 9, then I get 9 as the output! Hmm...   it seems that either we're both doing something wrong, or that there's a bug in the SQRT function. Right? Or am I missing something? P.S. I tested all of the math functions, and then posted my findings as an issue on the scriptcards github page, just to be safe. Maybe it will be useful, and maybe not... but it's nice to at least  try to help... it's the thought that counts, eh? :-)
1633469155

Edited 1633469548
David M.
Pro
API Scripter
What version are you running? I am running 1.4.1  1.4.4, and when I run the quoted code, I get 2. Looks like you might have an older version that doesn't support the {MATH} expressions? Since (9-5=4) EDIT - I checked the changelog - {SQRT} was added in v1.4.1
David M. said: What version are you running? I am running 1.4.1  1.4.4, and when I run the quoted code, I get 2. Looks like you might have an older version that doesn't support the {MATH} expressions? Since (9-5=4) EDIT - I checked the changelog - {SQRT} was added in v1.4.1 Interesting...   originally, I installed ScriptCards via the API library drop-down menu... and when I click on the "ScriptCards" tab, to try to see which version I'm using, then all that I see is "Version: Latest"...   so I'm afraid that I have no idea which version I'm using... By the way, should I not be using the API-library version? I thought that was the best option, because then I would get automatic updates whenever ScriptCards is updated. But should I be installing and updating ScriptCards manually instead? I realize that this is probably a complete newbie question, but hey, I am a ScriptCards newbie, so... heheh :-)
1633518607
David M.
Pro
API Scripter
Ronnie, it really just depends if you want/need to use the latest features that are in the development versions. It is common for script authors to wait a while before pushing new versions to 1-click to allow for additional testing by the user base in case there are hidden bugs that have been inadvertently introduced. I know I've been bitten when pushing to 1-click too soon, and if there is a problem, authors don't have the ability to immediately roll back as 1-click is only updated once/week. According to the wiki, the 1-click version is 1.4.0e, so that seems to explain what is going on with your testing of the new math functions. When you restart your sandbox, Scriptcards outputs a line in the api console that tells you what version you have installed. It will look something like this: "-=> ScriptCards - 1.4.4 by Kurt Jaegers Ready <=- Meta Offset : 10878"
David M. said: Ronnie, it really just depends if you want/need to use the latest features that are in the development versions. It is common for script authors to wait a while before pushing new versions to 1-click to allow for additional testing by the user base in case there are hidden bugs that have been inadvertently introduced. I know I've been bitten when pushing to 1-click too soon, and if there is a problem, authors don't have the ability to immediately roll back as 1-click is only updated once/week. According to the wiki, the 1-click version is 1.4.0e, so that seems to explain what is going on with your testing of the new math functions. When you restart your sandbox, Scriptcards outputs a line in the api console that tells you what version you have installed. It will look something like this: "-=> ScriptCards - 1.4.4 by Kurt Jaegers Ready <=- Meta Offset : 10878" Thank you kindly, sir, good to know :-)
Hey folks, I'm reworking some cards for a friend's Mutants &amp; Masterminds game, and I'm getting a weird error in the API console even though things seem to work ok on the VTT. I believeit has something to do with the code blocks I've created as the error only pops up when the attack is not a miss. I'd love another eyeball or two on it to make sure I'm not doing something fixed because of formatting.&nbsp; The error in the console is "(node:25) UnhandledPromiseRejectionWarning: ReferenceError: CustomEvent is not defined &nbsp; &nbsp; at setActiveCharacterId (eval at messageHandler (evalmachine.&lt;anonymous&gt;:713:6), &lt;anonymous&gt;:22:14) &nbsp; &nbsp; at eval (eval at messageHandler (evalmachine.&lt;anonymous&gt;:713:6), &lt;anonymous&gt;:63:9) &nbsp; &nbsp; at &lt;anonymous&gt; &nbsp; &nbsp; at processTicksAndRejections (internal/process/task_queues.js:97:5) &nbsp; &nbsp; at async worker (eval at messageHandler (evalmachine.&lt;anonymous&gt;:713:6), &lt;anonymous&gt;:126:17) &nbsp; &nbsp; at async Array.accessSheet (eval at messageHandler (evalmachine.&lt;anonymous&gt;:713:6), &lt;anonymous&gt;:578:32)" "(node:25) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see <a href="https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode" rel="nofollow">https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode</a>). (rejection id: 2)" "(node:25) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code." And here is the card itself !scriptcard {{&nbsp; +++M&amp;M3E+++ --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} &nbsp; --Lsettings|[*S:character_name] &nbsp; --?[*S:op_npc] -eq on|&gt;NPCSettings &nbsp; --#title|[*S:character_name] - Thrown Object &nbsp;&nbsp; &nbsp; --Rfind|[*S:character_id];Throw;repeating_rangedcombat;specialty &nbsp; --?"[*R:specialty]" -inc Loaded|[ --=CombatSkill|0 --=SkillRank|0 --]|[ --=CombatSkill|[*R:specialty_rank] --=SkillRank|[*R:specialty_rank] --]| &nbsp; --=AttackRoll|1d20 [Base] + [*S:dexterity] [DEX] + [$CombatSkill] [Skill] &nbsp; --=WhatToHit|10 + [*T:dodge] &nbsp; --=ResistanceDC|15 + [*T:strength] &nbsp; --=ResistanceCheck|1d20 + [*T:toughness] &nbsp;&nbsp; &nbsp; --+Catch|[*S:character_name] rolls a [$AttackRoll] to throw an object at [*T:character_name]. &nbsp;&nbsp; &nbsp; --:FindAnyImpCrit|Character ID;Attack Name --Rfirst|[*S:character_id];repeating_advantages --:ImpCritLoop| --?"[*R:name]" -inc Loaded|LoopDone --?"[*R:name]" -inc "Improved Critical" -and "[*R:name]" -inc "Throw"|HowMuchImpCrit --Rnext| --^ImpCritLoop| --:HowMuchImpCrit| --~Before|string;before;:;[*R:name] --~After|string;after;critical ;[&amp;Before] --=ImpCritValue|[&amp;After] --=CritRange|20 - [$ImpCritValue] --:LoopDone| &nbsp;&nbsp; &nbsp; --:HitDetermination| --?[$AttackRoll.Base] -eq 1 -or [$AttackRoll] -lt [$WhatToHit]|Miss --?[$AttackRoll.Base] -eq 20 -and [$AttackRoll] -ge [$WhatToHit]|Crit|Hit --?[$AttackRoll.Base] -ge [$CritRange] -and [$AttackRoll] -ge [$WhatToHit]|Crit|Miss --?[$AttackRoll] -ge [$WhatToHit]|Hit --:Miss| --+Miss|[i][*T:character_name] avoids the thrown object![/i] --X| --:Crit| --IWhat ; additional effect?|q;AddEffect;Choose your additional critical effect|Increased Effect|Added Effect|Alternate Effect --?"[&amp;AddEffect]" -eq "Increased Effect"|=ResistanceCheck;[$ResistanceCheck] - 5 --=Difference|[$ResistanceDC] - [$ResistanceCheck]&nbsp;&nbsp; --?[$Difference] -lt 1|Resisted --=DegreeSuccess|[$Difference] \ 5 + 1 --&gt;DamageDegreeResult| --+Critical Hit!| [i] Choose your [&amp;AddEffect] for this critical hit. [/i] --X| &nbsp;&nbsp; --:Hit| --=Difference|[$ResistanceDC] - [$ResistanceCheck]&nbsp;&nbsp; --?[$Difference] -lt 1|Resisted --=DegreeSuccess|[$Difference] \ 5 + 1 --&gt;DamageDegreeResult| --X| --:Resisted| --+Resisted!| [i][*T:character_name] has resisted any damage from the thrown object.[/i] --X| --:DamageDegreeResult| --?[$DegreeSuccess] -eq 1|[ --+Failed|[i][*T:character_name] takes a –1 circumstance penalty to further resistance checks against damage.[/i] --@modbattr|_silent _charid [*T:character_id] _injuries|+1 --]| --?[$DegreeSuccess] -eq 2|[ --+Failed|[i][*T:character_name] takes a –1 circumstance penalty to further resistance checks against damage and is [b]dazed[/b] until the start of their next turn.[/i] --@modbattr|_silent _charid [*T:character_id] _injuries|+1 --@setattr|_silent _charid [*T:character_id] _dazed|on --]| --?[$DegreeSuccess] -eq 3|[ --?[*T:staggered] -eq on|FourthDegree --+Failed|[i][*T:character_name] takes a –1 circumstance penalty to further resistance checks against damage and is [b]staggered[/b] until they recover.[/i] --@modbattr|_silent _charid [*T:character_id] _injuries|+1 --@setattr|_silent _charid [*T:character_id] _staggered|on --]| --:FourthDegree| --?[$DegreeSuccess] -ge 4|[ --+Out!|[i][*T:character_name] has been incapacitated![/i] --@setattr|_silent _charid [*T:character_id] _incapacitated|on --]| --&lt;| }} Thanks!
1633701212
Kurt J.
Pro
API Scripter
Erik M. said: Hey folks, I'm reworking some cards for a friend's Mutants &amp; Masterminds game, and I'm getting a weird error in the API console even though things seem to work ok on the VTT. I believeit has something to do with the code blocks I've created as the error only pops up when the attack is not a miss. I'd love another eyeball or two on it to make sure I'm not doing something fixed because of formatting.&nbsp; The error in the console is "(node:25) UnhandledPromiseRejectionWarning: ReferenceError: CustomEvent is not defined &nbsp; &nbsp; at setActiveCharacterId (eval at messageHandler (evalmachine.&lt;anonymous&gt;:713:6), &lt;anonymous&gt;:22:14) &nbsp; &nbsp; at eval (eval at messageHandler (evalmachine.&lt;anonymous&gt;:713:6), &lt;anonymous&gt;:63:9) &nbsp; &nbsp; at &lt;anonymous&gt; &nbsp; &nbsp; at processTicksAndRejections (internal/process/task_queues.js:97:5) &nbsp; &nbsp; at async worker (eval at messageHandler (evalmachine.&lt;anonymous&gt;:713:6), &lt;anonymous&gt;:126:17) &nbsp; &nbsp; at async Array.accessSheet (eval at messageHandler (evalmachine.&lt;anonymous&gt;:713:6), &lt;anonymous&gt;:578:32)" "(node:25) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see <a href="https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode" rel="nofollow">https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode</a>). (rejection id: 2)" "(node:25) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code." And here is the card itself !scriptcard {{&nbsp; +++M&amp;M3E+++ --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} &nbsp; --Lsettings|[*S:character_name] &nbsp; --?[*S:op_npc] -eq on|&gt;NPCSettings &nbsp; --#title|[*S:character_name] - Thrown Object &nbsp;&nbsp; &nbsp; --Rfind|[*S:character_id];Throw;repeating_rangedcombat;specialty &nbsp; --?"[*R:specialty]" -inc Loaded|[ --=CombatSkill|0 --=SkillRank|0 --]|[ --=CombatSkill|[*R:specialty_rank] --=SkillRank|[*R:specialty_rank] --]| &nbsp; --=AttackRoll|1d20 [Base] + [*S:dexterity] [DEX] + [$CombatSkill] [Skill] &nbsp; --=WhatToHit|10 + [*T:dodge] &nbsp; --=ResistanceDC|15 + [*T:strength] &nbsp; --=ResistanceCheck|1d20 + [*T:toughness] &nbsp;&nbsp; &nbsp; --+Catch|[*S:character_name] rolls a [$AttackRoll] to throw an object at [*T:character_name]. &nbsp;&nbsp; &nbsp; --:FindAnyImpCrit|Character ID;Attack Name --Rfirst|[*S:character_id];repeating_advantages --:ImpCritLoop| --?"[*R:name]" -inc Loaded|LoopDone --?"[*R:name]" -inc "Improved Critical" -and "[*R:name]" -inc "Throw"|HowMuchImpCrit --Rnext| --^ImpCritLoop| --:HowMuchImpCrit| --~Before|string;before;:;[*R:name] --~After|string;after;critical ;[&amp;Before] --=ImpCritValue|[&amp;After] --=CritRange|20 - [$ImpCritValue] --:LoopDone| &nbsp;&nbsp; &nbsp; --:HitDetermination| --?[$AttackRoll.Base] -eq 1 -or [$AttackRoll] -lt [$WhatToHit]|Miss --?[$AttackRoll.Base] -eq 20 -and [$AttackRoll] -ge [$WhatToHit]|Crit|Hit --?[$AttackRoll.Base] -ge [$CritRange] -and [$AttackRoll] -ge [$WhatToHit]|Crit|Miss --?[$AttackRoll] -ge [$WhatToHit]|Hit --:Miss| --+Miss|[i][*T:character_name] avoids the thrown object![/i] --X| --:Crit| --IWhat ; additional effect?|q;AddEffect;Choose your additional critical effect|Increased Effect|Added Effect|Alternate Effect --?"[&amp;AddEffect]" -eq "Increased Effect"|=ResistanceCheck;[$ResistanceCheck] - 5 --=Difference|[$ResistanceDC] - [$ResistanceCheck]&nbsp;&nbsp; --?[$Difference] -lt 1|Resisted --=DegreeSuccess|[$Difference] \ 5 + 1 --&gt;DamageDegreeResult| --+Critical Hit!| [i] Choose your [&amp;AddEffect] for this critical hit. [/i] --X| &nbsp;&nbsp; --:Hit| --=Difference|[$ResistanceDC] - [$ResistanceCheck]&nbsp;&nbsp; --?[$Difference] -lt 1|Resisted --=DegreeSuccess|[$Difference] \ 5 + 1 --&gt;DamageDegreeResult| --X| --:Resisted| --+Resisted!| [i][*T:character_name] has resisted any damage from the thrown object.[/i] --X| --:DamageDegreeResult| --?[$DegreeSuccess] -eq 1|[ --+Failed|[i][*T:character_name] takes a –1 circumstance penalty to further resistance checks against damage.[/i] --@modbattr|_silent _charid [*T:character_id] _injuries|+1 --]| --?[$DegreeSuccess] -eq 2|[ --+Failed|[i][*T:character_name] takes a –1 circumstance penalty to further resistance checks against damage and is [b]dazed[/b] until the start of their next turn.[/i] --@modbattr|_silent _charid [*T:character_id] _injuries|+1 --@setattr|_silent _charid [*T:character_id] _dazed|on --]| --?[$DegreeSuccess] -eq 3|[ --?[*T:staggered] -eq on|FourthDegree --+Failed|[i][*T:character_name] takes a –1 circumstance penalty to further resistance checks against damage and is [b]staggered[/b] until they recover.[/i] --@modbattr|_silent _charid [*T:character_id] _injuries|+1 --@setattr|_silent _charid [*T:character_id] _staggered|on --]| --:FourthDegree| --?[$DegreeSuccess] -ge 4|[ --+Out!|[i][*T:character_name] has been incapacitated![/i] --@setattr|_silent _charid [*T:character_id] _incapacitated|on --]| --&lt;| }} Thanks! That error message indicates that the problem is coming from the character sheet. If I had to guess, when setting an attribute in the DamageDegreeResult section of the character sheet, there is a listener on the character sheet that is supposed to do something with a value is changed, but the event it is attempting to call is not defined in the sheet's code.
Kurt J. said: The deferral characters currently only support &amp;{...}, @(...) and *(...) since those were what was available at the time. I'll add deferral character support for get. to the github version later today. Did this get tackled?
Kurt J. said: That error message indicates that the problem is coming from the character sheet. If I had to guess, when setting an attribute in the DamageDegreeResult section of the character sheet, there is a listener on the character sheet that is supposed to do something with a value is changed, but the event it is attempting to call is not defined in the sheet's code. Ah, thanks! That makes sense as the injuries attribute changes the Toughness one for future Toughness checks.&nbsp;
1633786090

Edited 1633786109
Kurt J.
Pro
API Scripter
Colin C. said: Kurt J. said: The deferral characters currently only support &amp;{...}, @(...) and *(...) since those were what was available at the time. I'll add deferral character support for get. to the github version later today. Did this get tackled? I just pushed these to the GitHub as version 1.4.5. My initial implementation didn't work so I changed my approach :) Right now, the pattern being checked is "get^." or "set^." (the ^ can be a customized deferral character). Currently I don't have support for multiple deferrals (get^^. for example) though if such a thing becomes necessary I can revisit it. That should only be required if you need not only ScriptCards to defer the meta lookup but the script you are calling as well. Hopefully that doesn't come up often :)
Psyched to check if it gets me where I'm trying to go! Thanks for an amazing script and fantastic support!
I'd like to ask the mastermind himself (Kurt) a question, if I may :-) Would you recommend combining ScriptCards and Airbag? I haven't used Airbag before, but I'm thinking about maybe starting now... but I'm not quite sure, though. Here's the link to the Airbag page, by the way: <a href="https://app.roll20.net/forum/post/7289686/script-airbag-api-crash-handler" rel="nofollow">https://app.roll20.net/forum/post/7289686/script-airbag-api-crash-handler</a>
@Kurt - anyone having issues with 1.4.5?&nbsp; I am having several macros blow that were working before. I reloaded an older version and the errors stopped.&nbsp; This was the main error msg... For reference, the error message generated was:&nbsp; ReferenceError: findObj is not defined ReferenceError: findObj is not defined at replaceVariableContent (apiscript.js:17090:18) at apiscript.js:15281:21 at eval (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:168:1), &lt;anonymous&gt;:65:16) at Object.publish (eval at &lt;anonymous&gt; (/home/node/d20-api-server/api.js:168:1), &lt;anonymous&gt;:70:8) at /home/node/d20-api-server/api.js:1736:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) at Id.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:489) at Zd.Ld.Mb (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:94:425)
1633918746
timmaugh
Pro
API Scripter
That's line 2275... it just needs to be changed to... findObjs( ...with an 's'. You can do that yourself if you're in a pinch (until Kurt gets that corrected).
1633953650

Edited 1633953856
Kurt J.
Pro
API Scripter
ScriptCards 1.4.6 available on GitHub I've pushed a few changes to the GitHub: Corrected the findObj sandbox crash as pointed out by @Michael C. and @timmaugh above. Sorry about that. Added MarkStart/MarkStop support for AirBag as suggested by @Ronnie McDurgen. I've tested this without &nbsp;AirBag installed, but I haven't actually tried it with AirBag as I'll need to set up a game with AirBag as the first and last script and I just haven't had the chance to do that yet. If you do have AirBag installed, ScriptCards will call the marker functions to let AirBag know its line numbers. From 1.4.5 (I didn't make a separate post for it): Added Meta Script deferral support for get and set constructs.
Hey Kurt - that did clear up that issue - and thanks! - but appears to have created another.&nbsp; This line previously printed the character name in a different color: &nbsp; &nbsp; &nbsp;--+|[c][#ffffff]And the Victim...err..Lucky Winner is: [/#][b][#141E61][*[&amp;ThisTarget]:character_name][/#][/b][/c] And the Victim...err..Lucky Winner is:&nbsp; Niang Rumblestout The same line (which prints correctly in a prior version) now prints out: And the Victim...err..Lucky Winner is: [/#] Patch [/#]
1633965268
Kurt J.
Pro
API Scripter
Michael C. said: Hey Kurt - that did clear up that issue - and thanks! - but appears to have created another.&nbsp; This line previously printed the character name in a different color: &nbsp; &nbsp; &nbsp;--+|[c][#ffffff]And the Victim...err..Lucky Winner is: [/#][b][#141E61][*[&amp;ThisTarget]:character_name][/#][/b][/c] And the Victim...err..Lucky Winner is:&nbsp; Niang Rumblestout The same line (which prints correctly in a prior version) now prints out: And the Victim...err..Lucky Winner is: [/#] Patch [/#] Michael, &nbsp; 1.4.6a (up now) should fix that issue. I was attempting to add another way to reference roll tables, but I forgot that [#...] was already taken :) - Kurt
I'd like to ask the mastermind himself (Kurt) another question, if I may :-) Would it be possible to make ScriptCards become completely non-responsive after an API-sandbox crash? I was in a game recently, and my resource-spending ScriptCards output-cards kept showing up normally whenever the players pressed their resource-spending buttons, despite the fact that the sandbox had crashed... and thus, we all thought that those game resources were actually being spent, which resulted in a large, stealthy bias creeping into our game...&nbsp; &nbsp;and now we're scared to use ScriptCards again, because we don't know if we can trust what the output cards are reporting :-/ P.S. I tried to implement a hacky solution to the problem, by modifying my Scriptcards-macros so that the output cards report the resource-value both before AND after spending the resource... but the roll20 database doesn't update fast enough for that to work :-/
Also, I'd like to ask (if I may) anyone who is interested in this feature... <a href="https://app.roll20.net/forum/post/10432957/a-gm-only-popup-that-simply-says-your-api-sandbox-has-crashed/" rel="nofollow">https://app.roll20.net/forum/post/10432957/a-gm-only-popup-that-simply-says-your-api-sandbox-has-crashed/</a> ...if you would be willing to help us both out by upvoting it? :-)
@Kurt - no worries, mate!&nbsp; T'aint one t'ing, it's t'other!
1633991588
Kurt J.
Pro
API Scripter
Ronnie McDurgen said: I'd like to ask the mastermind himself (Kurt) another question, if I may :-) Would it be possible to make ScriptCards become completely non-responsive after an API-sandbox crash? I was in a game recently, and my resource-spending ScriptCards output-cards kept showing up normally whenever the players pressed their resource-spending buttons, despite the fact that the sandbox had crashed... and thus, we all thought that those game resources were actually being spent, which resulted in a large, stealthy bias creeping into our game...&nbsp; &nbsp;and now we're scared to use ScriptCards again, because we don't know if we can trust what the output cards are reporting :-/ P.S. I tried to implement a hacky solution to the problem, by modifying my Scriptcards-macros so that the output cards report the resource-value both before AND after spending the resource... but the roll20 database doesn't update fast enough for that to work :-/ The sandbox "crashes" in two stages. The first time it crashes, it spins up a replacement sandbox and continues basically normally. If it crashes again before it has been manually restarted (by clicking the restart button, saving changes to a script, or shutting down the game and letting it time out and starting it up again) then the sandbox just stops functioning completely. As far as I know, there isn't a way for an API script to determine if the first crash has happened. When the second crash happens, all API scripts should be inactive. One quick-and-dirty solution might be (assuming you are using chatsetattr to make the modifications to sheets) is to remove the _silent (--silent) from the calls so chatsetattr reports the changes it made. If it is a different script making the changes, perhaps there is a non-silent configuration for that as well that would help. In your "green bar" thread, I posted a quick script that will display a message when the sandbox starts/restarts, which would alert you to that first crash.
You can also monitor if the API is on using this little svcript from the one and only TheAaron : <a href="https://app.roll20.net/forum/post/1567329/script-apiheartbeat-a-visual-cue-that-the-api-is-running/?pagenum=1" rel="nofollow">https://app.roll20.net/forum/post/1567329/script-apiheartbeat-a-visual-cue-that-the-api-is-running/?pagenum=1</a> That really helps
Huge thanks to Kurt for helping me with this! :-D By the way, if someone here wants to make use of the awesome script-duo that Kurt and The Aaron created for me, then you can open this link here :-) <a href="https://app.roll20.net/forum/post/10433120/could-someone-create-this-teeeeeensy-api-script-for-me/" rel="nofollow">https://app.roll20.net/forum/post/10433120/could-someone-create-this-teeeeeensy-api-script-for-me/</a>
EDIT : never mind, I figured it out, and then I fixed the "5E by Roll20" wiki so that people will be able to easily find this information in the future :-) . . . The original post was: --- I'd like to ask the mastermind himself (Kurt) another question, if I may :-) Is it possible for ScriptCards to read which of the spells in the "5E by Roll20" spell-list are actually prepared? (That is to say, which spells have the "checkmark" next to them.) And, if not, would it mayhaps perhaps be possible to add that feature? Because yeah,&nbsp; I have a nifty bit of pseudocode written out that I might be able to implement if I were to gain access to that feature :-D
So I found someone else's script card for attacks and thought it was wonderful. I made a few tweaks for my table and was absolutely ecstatic it seems to take into account damage resist/immunity from things like slashing, fire, etc. But I tried to make it so if I had a silvered weapon (in this case attack 1) it would work against werewolves. What I noticed is, if I put silver the weapon now affects even creatures that require a magical weapon. Turns out any text there (tried gold) also does this. Any help on what I'm setting it up wrong with? I've tried silver, silvered weapon, or silvered. Thanks again and kudos to the&nbsp; !Scriptcard {{ --#sourceToken|@{selected|token_id} --#targetToken|@{target|token_id} --/| &gt;&gt;&gt;&gt;&gt; Formatting &lt;&lt;&lt;&lt;&lt; --#titlecardbackgroundimage|linear-gradient(360deg, rgba(2,0,36,1) 0%, rgba(0,227,208,1) 100%); --#emoteBackground|#transparent --#titleCardBackground|#00e3d0 --#titlefontsize|1.75em --#titlefontlineheight|1.75em --#titleFontColor|white --#titlefontface|Shadows Into Light --#subtitleFontSize|12px --#subtitleFontFace|Verdana --#evenRowBackground|#B6AB91 --#evenRowFontColor|#000000 --#oddRowBackground|#CEC7B6 --#oddRowFontColor|#000000 --#Title|Attack --#whisper|self,gm --/his will whisper the possible attacks that can be used. It will whisper the buttons to the PC and the DM, that way the DM can see where the Player is at in the process. --+Choose your weapon.| [rbutton]Silvered Glaive::knowYourWeapon;1[/rbutton] [rbutton]Glaive::knowYourWeapon;2[/rbutton] [rbutton]Javelin::knowYourWeapon;3[/rbutton] [rbutton]Light Crossbow::knowYourWeapon;4[/rbutton] [rbutton]Handaxe Melee::knowYourWeapon;5/rbutton][rbutton]Handaxe Thrown::knowYourWeapon;6[/rbutton] --X| --:knowYourWeapon| --#whisper|self,gm --=Which|[&amp;reentryval] --?[$Which] -eq 1|&gt;Attack;Glaive;silver slashing;1d10; @{strength_mod} [STR];none;no;10 ft;melee;no;0;yes --?[$Which] -eq 2|&gt;Attack;Glaive;slashing;1d10; @{strength_mod} [STR];none;no;10 ft;melee;no;0;yes --?[$Which] -eq 3|&gt;Attack;Javelin;slashing;1d6; @{strength_mod} [STR];Javelin;yes;30/120;thrown;no;0;yes --?[$Which] -eq 4|&gt;Attack;Light Crossbow;piercing;1d4; @{dexterity_mod} [DEX];Bolts;yes;80/320;ranged;no;0;yes --?[$Which] -eq 1|&gt;Attack;Handaxe;slashing;1d6; @{strength_mod} [STR];Handaxe;no;5 ft;melee;no;0;yes --?[$Which] -eq 2|&gt;Attack;Handaxe;slashing;1d6; @{strength_mod} [STR];Handaxe;yes;20/60;thrown;no;0;yes --/This will pass down the variables to save them for use later. --:Attack|Variables are 1 Weapon Name;2 damage type;3 damage dice amount;4 damage modifier;5 ammo;6 If it will use ammo;7 range;8 melee, ranged, or thrown;9 magical;10 Magic Level (Sword +2 would just be 2.);Profficient(Yes or No) --&amp;Weapon|[%1%] --=Weap|[%1%] --&amp;DamageType|[%2%] --&amp;DamageAmount|[%3%] --&amp;DamageMod|[%4%] --&amp;ResourceUsed|[%5%] --&amp;SpendAmmo|[%6%] --&amp;Range|[%7%] --&amp;AttackType|[%8%] --&amp;Magical|[%9%] --&amp;MagicLvl|[%10%] --&amp;Prof|[%11%] --#Title|[&amp;Weapon] --#leftsub|[&amp;AttackType] Attack --#rightsub|[&amp;Range] --&gt;Proficient|Check for the yes or no on &amp;Prof. If yes, will add proficency bonus. --&gt;MagicalWeapon|Will check if yes or no on &amp;Magical and add &amp;MagicLvl bonus to attack and damage. This example also adds damage from Dragon slayer for example. --/This section will check if there is a resource needed for an attack. Since a handaxe can be thrown, the PC may not have it in order to attack. First it will see if there is Ammo needed, then it will find where it is, and then it will check if the PC still has some. --?"[&amp;ResourceUsed]" -eq "none"|noAmmoNeeded --&gt;GetAndCheckAmmoInformation|[*S:character_id];[&amp;ResourceUsed];Ammoname;Ammo --&gt;AmmoAvailable| --:noAmmoNeeded| --/This will whisper to the DM and Player the possible rolls and allow the DM to inform the player for where they ar at. --&amp;Bardic|?{Bardic Inspiration [1d6]|No,0|Yes, 1d6} --+Choose an attack roll type.|[rbutton]Standard::knowYourRoll1;1d20[/rbutton][rbutton]Advantage::knowYourRoll1;2d20kh1[/rbutton][rbutton]Disadvantage::knowYourRoll1;2d20kl1[/rbutton] --X| DONE --:knowYourRoll1| --=AttackRoll|[&amp;reentryval] + [&amp;DamageMod][&amp;PB]+@{selected|global_attack_mod} [GLOBE]+[&amp;Bardic][Bardic] --#emoteText|@{selected|token_name} attempts to attack @{target|token_name} with their [&amp;Weapon]. --&gt;RollResults|I have a seperate procedure for roll result due to PCs having spells and abilities like Bless and Bardic Inspiration. --?[$AttackRoll.Base] -eq 20|Crit --?[$AttackRoll.Base] -eq 1|Fumble --/This is where you can put roll modifier procedures like bless and bardic inspiration, as these will just add to the roll, they won't affect Crit or Fumble. I will provide examples of those procedures of how I have them at the bottom. --=AttackRoll|[$AttackRoll] --?[$AttackRoll.Total] -lt @{target|npc_AC}|Miss --:Hit| --#whisper| --&gt;Vulnerable| --&gt;RollDamage| --&gt;PlayEffects|none;none;none;[&amp;Weapon] --+Hit!|Your attack hit for [$Damage] [&amp;DamageType] damage! --@alter|_target|@{target|token_id} _bar|1 _amount|-[$Damage] --?"[&amp;SpendAmmo]" -eq "no"|noAmmoSpent --&gt;AmmoSpent| --:noAmmoSpent| --X| --:Miss| --#whisper| --+Miss|Your attack missed! --?"[&amp;SpendAmmo]" -eq "no"|noAmmoSpent --&gt;AmmoSpent| --:noAmmoSpent| --X| --:Fumble|This will roll a fumble table for a "Bad" thing that happened and show it to everyone. You can intrupret how you want to use it. I got mine from <a href="https://saveversus.wordpress.com/2014/09/15/fumble-charts-dd-5th-edition/" rel="nofollow">https://saveversus.wordpress.com/2014/09/15/fumble-charts-dd-5th-edition/</a> --#whisper| --=Fumblet|[T#Fumble-Table] --&gt;PlayEffects|none;none;none;Failure --+|[img]<a href="https://media3.giphy.com/media/duexIlfr9yYwYE23UA/giphy.gif?cid=ecf05e4735w197ln6hoja74l3ikcd7t0w971w0ljtmjp000n&amp;rid=giphy.gif&amp;ct=g[/img]" rel="nofollow">https://media3.giphy.com/media/duexIlfr9yYwYE23UA/giphy.gif?cid=ecf05e4735w197ln6hoja74l3ikcd7t0w971w0ljtmjp000n&amp;rid=giphy.gif&amp;ct=g[/img]</a> --+Fumble|The attack went really bad! --+Bad Stuff| [$Fumblet.tableEntryText] --=FDamage| [&amp;DamageAmount] + [&amp;DamageMod] --=FCrit|[&amp;DamageAmount] + [&amp;DamageMod] + [&amp;DamageAmount] [CRIT] --*Possible Damage| Normal Damage is [$FDamage] and Crit Damage is [$FCrit]. --?"[&amp;SpendAmmo]" -eq "no"|noAmmoSpent --&gt;AmmoSpent| --:noAmmoSpent| --X| --:Crit| --#whisper| --&gt;Vulnerable| --&gt;RollDamage|crit --&gt;PlayEffects|none;none;none;[&amp;Weapon] --+Critical Hit|You deal [$Damage] [%2%] damage CRITICAL HIT! --@alter|_target|@{target|token_id} _bar|1 _amount|-[$Damage] --?"[&amp;SpendAmmo]" -eq "no"|noAmmoSpent --&gt;AmmoSpent| --:noAmmoSpent| --X| --:Vulnerable| --&amp;vuln| --?"[*T:npc_vulnerabilities]" -inc "[&amp;DamageType]"|DoubleD --?"[&amp;Magical]" -inc "yes"|MagVuln --?"[*T:npc_resistances]" -inc "[&amp;DamageType]"|HalfD --?"[*T:npc_immunities]" -inc "[&amp;DamageType]"|immune --&lt;| --:MagVuln| --?"[*T:npc_immunities]" -inc "nonmagical"|notImmune --?"[*T:npc_immunities]" -inc "[&amp;DamageType]"|immune --:notImmune| --?"[*T:npc_resistances]" -inc "nonmagical"|notResistant --?"[*T:npc_resistances]" -inc "[&amp;DamageType]"|HalfD --:notResistant| --&lt;| --:HalfD| --&amp;vuln| \ 2 [Resistant] --&lt;| --:DoubleD| --&amp;vuln| * 2 [Vulnerable] --&lt;| --:immune| --+|@{target|token_name} is immune to [&amp;DamageType] damage. --&amp;vuln| * 0 [Immune] --&lt;| --:RollDamage| --?[%1%] -eq crit|CritDamage --=Damage|[&amp;DamageAmount] + @{selected|global_damage_mod_roll} [GLOBE] +[&amp;DamageMod][&amp;MagWeapDamBonus][&amp;vuln] --&lt;| --:CritDamage| --=Damage|[&amp;DamageAmount] + @{selected|global_damage_mod_roll}[GLOBE] + [&amp;DamageMod] + [&amp;DamageAmount] [CRIT][&amp;MagWeapDamBonus][&amp;vuln] --&lt;| --/This is going to find the ammo used on the character sheet and determine how much is available. --:GetAndCheckAmmoInformation|character_id;resourceName;Ammoname;Ammo --?"[%2%]" -eq "[*[%1%]:class_resource_name]"|_Lib5E_IsResourceClass --?"[%2%]" -eq "[*[%1%]:other_resource_name]"|_Lib5E_IsResourceOther --Rfirst|[%1%];repeating_resource --:_Lib5E_ResourceLoop| --?"[*R:resource_left_name]" -eq "[%2%]"|_Lib5E_IsResourceLeft --?"[*R:resource_right_name]" -eq "[%2%]"|_Lib5E_IsResourceRight --Rnext| --?"[*R:resource_left_name]" -ne "NoRepeatingAttributeLoaded"|_Lib5E_ResourceLoop --&amp;[%3%]|NotFound --&amp;[%4%]|NotFound --$[%4%]|0 --&lt;| --:_Lib5E_IsResourceClass| --&amp;[%3%]|class_resource_name --&amp;[%4%]|class_resource --=[%4%]|[*[%1%]:class_resource] --&lt;| --:_Lib5E_IsResourceOther| --&amp;[%3%]|other_resource --&amp;[%4%]|other_resource --=[%4%]|[*[%1%]:other_resource] --&lt;| --:_Lib5E_IsResourceLeft| --&amp;[%3%]|[*R&gt;resource_left_name] --&amp;[%4%]|[*R&gt;resource_left] --=[%4%]|[*R:resource_left] --&lt;| --:_Lib5E_IsResourceRight| --&amp;[%3%]|[*R&gt;resource_right_name] --&amp;[%4%]|[*R&gt;resource_right] --=[%4%]|[*R:resource_right] --&lt;| --&lt;| --:AmmoAvailable|This will determine if the Ammo needed is available. --?[$Ammo] -eq 0|NoAmmoLeft --=Ammo|[$Ammo] - 1 --&lt;| --:NoAmmoLeft|This will inform the PC that they are out of that ammo they tried to use. --#whisper| --+|[*S:character_name] has no [&amp;ResourceUsed] left. --#emoteText|[*S:character_name] is all out of [&amp;ResourceUsed]. --X|NoSlotsLeftStop --:AmmoSpent|This will reduce the ammo if used. --@setattr|_charid [*S:character_id] _[&amp;Ammo]|[$Ammo] _silent --+|[&amp;ResourceUsed] Left: [$Ammo] --X| --:PlayEffects|Parameters are : source effect; target effect; line effect; sound effect --vtoken|@{selected|token_id} [%1%] --vtoken|@{target|token_id} [%2%] --vbetweentokens|@{selected|token_id} @{target|token_id} [%3%] --@roll20AM|_audio,play,nomenu|[&amp;Weapon] --&lt;| --:Profficient| --&amp;PB| --?[&amp;Prof] -inc "no"|NotProf --&amp;PB|+ + @{pb} [PROF] --:NotProf| --&lt;| --:MagicalWeapon|This will check to see if the weapon is magical and add the correct attributes. --&amp;MagWeapHitBonus| --&amp;MagWeapDamBonus| --?"[&amp;Magical]" -inc "Yes"|YesMagic --&lt;| --:YesMagic| --&amp;MagWeapHitBonus|+ + [&amp;MagicLvl] [Magical Weapon] --&amp;MagWeapDamBonus|+ + [&amp;MagicLvl] [Magical Weapon] --?"[*T:npc_type]" -inc "dragon"|dragon --&lt;| --:dragon| --&amp;MagWeapDamBonus|+ + 3d6 [Dragon Slayer] --&lt;| --:RollResults|This will display the roll results depending on if you have Bardic inspiration or bless activated. This will allow you to mouse over the results and see what happened. --+Attack Roll|You rolled a [$AttackRoll] to hit. --&lt;| }}
I second Ronnie's question/request.&nbsp; I have a bit of a wrestle with players as to which spells are prepared as opposed to known.&nbsp; I would love to have a command line that would check to see if it is prepared - as well as something that would tell me when a player changes their prepared spells.&nbsp;&nbsp;
Michael C. said: I second Ronnie's question/request.&nbsp; I have a bit of a wrestle with players as to which spells are prepared as opposed to known.&nbsp; I would love to have a command line that would check to see if it is prepared - as well as something that would tell me when a player changes their prepared spells.&nbsp;&nbsp; Good news, my fellow scripter, that functionality already exists in ScriptCards :-) This code demonstrates the two ways that I was able to find. Hope it helps :-D !script{{ --/| First method begins: --+Using the First Method:|Is the second 1st-level spell prepped? @{selected|repeating_spell-1_$1_spellprepared} --/| Second method begins: --#sourceToken|@{selected|token_id} &nbsp; &nbsp; --/| Where on the character sheet is the resource located? &nbsp; &nbsp; &nbsp; --/| Just replace "repeating_spell-1" with whatever other &nbsp; &nbsp; &nbsp; --/| field of repeating attributes you wish to target. &nbsp; &nbsp; &nbsp; --/| And then make sure that the count is correct, as well. &nbsp; &nbsp; &nbsp; --/| That is to say, the "Rfirst"-line will load into memory the&nbsp; &nbsp; &nbsp; &nbsp; --/|first thing in the repeating field, and then I simply spam&nbsp; &nbsp; &nbsp; &nbsp; --/| as many "--Rnext|" lines after that as are needed. Basic&nbsp; &nbsp; &nbsp; &nbsp; --/| counting, really. &nbsp; &nbsp; &nbsp; &nbsp; --Rfirst|@{selected|character_id};repeating_spell-1 &nbsp; &nbsp; &nbsp; &nbsp; --Rnext| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --/| And then just replace "spellprepared" with whatever &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --/| other phrase is needed to narrow down the targeting. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&amp;ResValue|[*R:spellprepared] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&amp;ResValueAddress|[*R&gt;spellprepared] --+Using the Second Method:|Is the second 1st-level spell prepped? [&amp;ResValue] }} P.S. The second method is not as easy, but is sometimes necessary, for example if you need to feed the information into another API-script.
Kurt, I think I may have found a bug, unless I am just not understanding something here.&nbsp; When I use .RollText option, it seems to be rerolling and giving different results for the variable.&nbsp;&nbsp; In this case, I want to show the attack roll numbers (in case it is made at advantage, you can hover and see both rolls).&nbsp; However, when I use the .RollText option on the roll, it rerolls it. In this example, both AttackDice and AttackRoll are the same. !script {{ &nbsp; --=AttackDice|2d20kh1 &nbsp; --+AttackDice|[$AttackDice] &nbsp; --=AttackRoll|[$AttackDice] &nbsp; --+AttackRoll|[$AttackRoll] }} However, if I add the .RollText option, it rerolls and the numbers are no longer the same. !script {{ &nbsp; --=AttackDice|2d20kh1 &nbsp; --+AttackDice|[$AttackDice] &nbsp; --=AttackRoll|[$AttackDice.RollText] &nbsp; --+AttackRoll|[$AttackRoll] }} Is this working as designed?&nbsp; Or is this a bug?&nbsp; I came across this trying to show the base attack roll in the full modified attack roll instead of just the end result (and to confirm it actually rolled at advantage).&nbsp;&nbsp; &nbsp; --=AttackRoll|[$AttackDice.RollText] + [&amp;AttackBonus] + [&amp;Prof] [&amp;AttackMod] &nbsp; --+Attack Roll|[$AttackRoll] &nbsp; --?[$AttackDice.Base] -eq 20|Crit &nbsp; --?[$AttackDice.Base] -eq 1|Fumble &nbsp; --?[$AttackRoll.Total] -ge @{target|npc_AC}|&gt;Hit|&gt;Miss But in this case the first number shown in AttackRoll is not the number evaluated for Crit or Fumble.&nbsp;
1634074774
Kurt J.
Pro
API Scripter
Matt M. said: Kurt, I think I may have found a bug, unless I am just not understanding something here.&nbsp; When I use .RollText option, it seems to be rerolling and giving different results for the variable.&nbsp;&nbsp; In this case, I want to show the attack roll numbers (in case it is made at advantage, you can hover and see both rolls).&nbsp; However, when I use the .RollText option on the roll, it rerolls it. In this example, both AttackDice and AttackRoll are the same. !script {{ &nbsp; --=AttackDice|2d20kh1 &nbsp; --+AttackDice|[$AttackDice] &nbsp; --=AttackRoll|[$AttackDice] &nbsp; --+AttackRoll|[$AttackRoll] }} However, if I add the .RollText option, it rerolls and the numbers are no longer the same. !script {{ &nbsp; --=AttackDice|2d20kh1 &nbsp; --+AttackDice|[$AttackDice] &nbsp; --=AttackRoll|[$AttackDice.RollText] &nbsp; --+AttackRoll|[$AttackRoll] }} Is this working as designed?&nbsp; Or is this a bug?&nbsp; I came across this trying to show the base attack roll in the full modified attack roll instead of just the end result (and to confirm it actually rolled at advantage).&nbsp;&nbsp; &nbsp; --=AttackRoll|[$AttackDice.RollText] + [&amp;AttackBonus] + [&amp;Prof] [&amp;AttackMod] &nbsp; --+Attack Roll|[$AttackRoll] &nbsp; --?[$AttackDice.Base] -eq 20|Crit &nbsp; --?[$AttackDice.Base] -eq 1|Fumble &nbsp; --?[$AttackRoll.Total] -ge @{target|npc_AC}|&gt;Hit|&gt;Miss But in this case the first number shown in AttackRoll is not the number evaluated for Crit or Fumble.&nbsp; That behaviour is as expected. the .RollText modifier returns the raw text of the roll that was parsed to produce the results. If it is used inside another --= statement, it will simply be expanded and processed as a new request for a roll: --=AttackRoll|1d20 + 5 + 2 Will roll 1d20+5+2 and store the result in AttackRoll. This statement then: --=AttackRoll2|[$AttackRoll.RollText] is exactly the equivalent of: --=AttackRoll2|1d20 + 5 + 2 Note that this will NOT be done in the case of --+ or --&amp; lines: --+AttackRoll|[$AttackRoll] ([$AttackRoll.RollText]) Will produce something like: AttackRoll 18 (1d20 + 5 + 2) With the 18 formatted with the yellow square around it. In your example above: !script {{ &nbsp; --=AttackDice|2d20kh1 &nbsp; --+AttackDice|[$AttackDice] &nbsp; --=AttackRoll|[$AttackDice.RollText] &nbsp; --+AttackRoll|[$AttackRoll] }} once variable replacement happens, it would expand to look like this (assuming 2d20kh1 the first time resulted in a 17 and the second time a 12): !script {{ &nbsp; --=AttackDice|2d20kh1 &nbsp; --+AttackDice|17 &nbsp; --=AttackRoll|2d20kh1 &nbsp; --+AttackRoll|12 }}
1634075866

Edited 1634075939
Kurt J.
Pro
API Scripter
Ronnie McDurgen said: Michael C. said: I second Ronnie's question/request.&nbsp; I have a bit of a wrestle with players as to which spells are prepared as opposed to known.&nbsp; I would love to have a command line that would check to see if it is prepared - as well as something that would tell me when a player changes their prepared spells.&nbsp;&nbsp; Good news, my fellow scripter, that functionality already exists in ScriptCards :-) This code demonstrates the two ways that I was able to find. Hope it helps :-D !script{{ --/| First method begins: --+Using the First Method:|Is the second 1st-level spell prepped? @{selected|repeating_spell-1_$1_spellprepared} --/| Second method begins: --#sourceToken|@{selected|token_id} &nbsp; &nbsp; --/| Where on the character sheet is the resource located? &nbsp; &nbsp; &nbsp; --/| Just replace "repeating_spell-1" with whatever other &nbsp; &nbsp; &nbsp; --/| field of repeating attributes you wish to target. &nbsp; &nbsp; &nbsp; --/| And then make sure that the count is correct, as well. &nbsp; &nbsp; &nbsp; --/| That is to say, the "Rfirst"-line will load into memory the&nbsp; &nbsp; &nbsp; &nbsp; --/|first thing in the repeating field, and then I simply spam&nbsp; &nbsp; &nbsp; &nbsp; --/| as many "--Rnext|" lines after that as are needed. Basic&nbsp; &nbsp; &nbsp; &nbsp; --/| counting, really. &nbsp; &nbsp; &nbsp; &nbsp; --Rfirst|@{selected|character_id};repeating_spell-1 &nbsp; &nbsp; &nbsp; &nbsp; --Rnext| &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --/| And then just replace "spellprepared" with whatever &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --/| other phrase is needed to narrow down the targeting. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&amp;ResValue|[*R:spellprepared] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; --&amp;ResValueAddress|[*R&gt;spellprepared] --+Using the Second Method:|Is the second 1st-level spell prepped? [&amp;ResValue] }} P.S. The second method is not as easy, but is sometimes necessary, for example if you need to feed the information into another API-script. It is actually much simpler than that :) I have avoided any system-specific features in ScriptCards, and instead tried to make the language robust enough to work with any game as long as you have enough information about the sheet. In the case of 5E spells, here are a couple of simple scripts along the lines of what you are looking for: Quick Spell List: &nbsp;Displays a list of spells known by the player and either "Prepared" or "Not Prepared" next to them: !script {{ --#Title|Spell Book --#sourcetoken|@{selected|token_id} --%loop|1;9 --+Level|[&amp;loop] --rfirst|[*S:character_id];repeating_spell-[&amp;loop] --:DisplayLoop| --?"[*R:spellname]" -eq NoRepeatingAttributeLoaded|% --?[*R:spellprepared] -eq 1|&amp;prepText;Prepared|&amp;prepText;Not Prepared --+[*R:spellname]|[&amp;prepText] --rnext| --^DisplayLoop| --%| }} Spell Prepared : This script checks to see if the character knows the spell and displays the prepared status if so (customize the --rfind line with the spell name and spell level): !script {{ --#Title|Spell Book --#sourcetoken|@{selected|token_id} --rfind|[*S:character_id];Magic Missile;repeating_spell-1;spellname --?"[*R:spellname]" -eq NoRepeatingAttributeLoaded|SpellUnknown --?[*R:spellprepared] -eq 1|&amp;prepText;Prepared|&amp;prepText;Not Prepared --+[*R:spellname]|[&amp;prepText] --X| --:SpellUnknown| --+No Spell|The character does not know that spell }} While --rFirst/--rNext lets you loop through repeating items, --rFind jumps right to the item you want based on the search criteria.
Kurt J. said: Matt M. said: Kurt, I think I may have found a bug, unless I am just not understanding something here.&nbsp; When I use .RollText option, it seems to be rerolling and giving different results for the variable.&nbsp;&nbsp; In this case, I want to show the attack roll numbers (in case it is made at advantage, you can hover and see both rolls).&nbsp; However, when I use the .RollText option on the roll, it rerolls it. In this example, both AttackDice and AttackRoll are the same. !script {{ &nbsp; --=AttackDice|2d20kh1 &nbsp; --+AttackDice|[$AttackDice] &nbsp; --=AttackRoll|[$AttackDice] &nbsp; --+AttackRoll|[$AttackRoll] }} However, if I add the .RollText option, it rerolls and the numbers are no longer the same. !script {{ &nbsp; --=AttackDice|2d20kh1 &nbsp; --+AttackDice|[$AttackDice] &nbsp; --=AttackRoll|[$AttackDice.RollText] &nbsp; --+AttackRoll|[$AttackRoll] }} Is this working as designed?&nbsp; Or is this a bug?&nbsp; I came across this trying to show the base attack roll in the full modified attack roll instead of just the end result (and to confirm it actually rolled at advantage).&nbsp;&nbsp; &nbsp; --=AttackRoll|[$AttackDice.RollText] + [&amp;AttackBonus] + [&amp;Prof] [&amp;AttackMod] &nbsp; --+Attack Roll|[$AttackRoll] &nbsp; --?[$AttackDice.Base] -eq 20|Crit &nbsp; --?[$AttackDice.Base] -eq 1|Fumble &nbsp; --?[$AttackRoll.Total] -ge @{target|npc_AC}|&gt;Hit|&gt;Miss But in this case the first number shown in AttackRoll is not the number evaluated for Crit or Fumble.&nbsp; That behaviour is as expected. the .RollText modifier returns the raw text of the roll that was parsed to produce the results. If it is used inside another --= statement, it will simply be expanded and processed as a new request for a roll: --=AttackRoll|1d20 + 5 + 2 Will roll 1d20+5+2 and store the result in AttackRoll. This statement then: --=AttackRoll2|[$AttackRoll.RollText] is exactly the equivalent of: --=AttackRoll2|1d20 + 5 + 2 Note that this will NOT be done in the case of --+ or --&amp; lines: --+AttackRoll|[$AttackRoll] ([$AttackRoll.RollText]) Will produce something like: AttackRoll 18 (1d20 + 5 + 2) With the 18 formatted with the yellow square around it. In your example above: !script {{ &nbsp; --=AttackDice|2d20kh1 &nbsp; --+AttackDice|[$AttackDice] &nbsp; --=AttackRoll|[$AttackDice.RollText] &nbsp; --+AttackRoll|[$AttackRoll] }} once variable replacement happens, it would expand to look like this (assuming 2d20kh1 the first time resulted in a 17 and the second time a 12): !script {{ &nbsp; --=AttackDice|2d20kh1 &nbsp; --+AttackDice|17 &nbsp; --=AttackRoll|2d20kh1 &nbsp; --+AttackRoll|12 }} Hmm.&nbsp; OK.&nbsp; So, how would I format the AttackDice and AttackRoll variables to show the two rolls when hovering like this instead of just showing 10.&nbsp; Yet still be able to use the AttackDice variable to check whether it was a crit or fumble)? &nbsp; --=AttackDice|2d20kh1&nbsp; &nbsp; --=AttackRoll|[$AttackDice.RollText] + [&amp;AttackBonus] + [&amp;Prof] [&amp;AttackMod] &nbsp; --?[$AttackDice.Base] -eq 20|Crit &nbsp; --?[$AttackDice.Base] -eq 1|Fumble &nbsp; --?[$AttackRoll.Total] -ge @{target|npc_AC}|&gt;Hit|&gt;Miss
In reply to Kurt's last reply to me: Thanks very much, that code you posted will come in very handy :-D
A question for the ScriptCards community: Would anyone here be willing to create color-highlighting for Atom (that is to say, the code editor that GitHub created)? Even if it's just to have the comments appear in a different color than the actual code... even just that would be very nice :-) Link: Here are the instructions for it, if anyone with JavaScript and HTLM skills wants to give it a go :-) <a href="https://flight-manual.atom.io/hacking-atom/sections/creating-a-grammar/" rel="nofollow">https://flight-manual.atom.io/hacking-atom/sections/creating-a-grammar/</a>