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

Easy one folks : I'm having a --I statement asking one of my player to select a token that he would like to heal... I store the aimed token_id in a variable named  MonPatient  I can then use Tokenmod to succesfully manipulate bar1 of that token. But I can't figure how to display the charactername of that token in my result window!..... I tried the following : --:Soin mental mineur| --#sourceToken|@{selected|token_id} --#title|Soin mental mineur --#whisper|0 --&Pouvoir|Soin mental mineur --#emoteText|[*S:character_name] utilise [&Pouvoir] --IScriptCards a besoin de savoir quelle personne tu veux soigner;Click pour choisir un patient|t;MonPatient;Patient --+MonPatient|[&MonPatient] --&Desc1a|[*S:character_name] peut soigner une blessure mentale légère.  --&Desc1b|[[&MonPatient]:t-represents] gagne immédiatement 2 points d'Esprit.  --+|[&Desc1a] --+|[&Desc1b] -->LibShaan_Draw|[&MonPatient];1;-2 --X| --:LibShaan_Draw|Parameters are tokenid;bar#;amount --@token-mod|_ignore-selected _ids [%1%] _set bar[%2%]_value|-[%3%] --<| Which results in : MonPatient seems to fetch the right T-id but I just would like to have " Songe de Foudre gagne immédiatement 2 points d'Esprit." instead of  " -MZj5-qWLEpxSDrMC9PF  gagne immédiatement 2 points d'Esprit."...... In the meantime if I could succesfully use the T:represents  (to have it show  Songe de Foudre  which is the character name) what should I add at the end of my emote in order to get the token image of the token_id sotred in  MonPatient ?
1620321887
Kurt J.
Pro
API Scripter
Michael C. said: Kurt J. - not sure if this is part of same problem but I changed the following fireball script line to accommodate a Thunderwave spell (which originates from but does not include caster):     --/|Check the distance between the casting token and the current array token. 15 feet is 3 units     --~dist|distance;@{selected|token_id};[&tokenid]     --?[$dist] -e -?[$dist] -e q 0 -or -gt 3|continue When I changed this it selected all tokens on the page rather than restricting them to targets 1 to 3 spaces away.  Remove the "-eq 0 -or " and it restricts the spell to the selected token and any target tokens within 3 spaces. You would need to re-specify "[$dist]" for the second comparison: --?[$dist] -eq 0 -or [$dist] -gt 3|continue This is because the conditional will be split at the -or into two conditionals: [$dist -eq 0] for the first one and [ -gt 3] for the second. because that second conditional isn't valid (it doesn't know what to compare the 3 to) the conditional will fail and fall through to the next line.
1620322055
Kurt J.
Pro
API Scripter
GM TC said: Michael C. said: @ GM TC - not sure what game you are using? I assume it is not DnD 5e as that game doesn't calculate damage that way.   I was able to shorten and simplify the script considerably with the below.  --=Damage|2 + [$DamageEffortMod] [Damage Effort] - @{target|armor} [Armor] --?[$Damage] -le 0|=Damage;0 [Armor Absorbed Hit]|=Damage;2 + [$DamageEffortMod] [Damage Effort] - @{target|armor} [Armor] You can shorten this further like this: --=Damage|2 + [$DamageEffortMod] [Damage Effort] - @{target|armor} [Armor] --?[$Damage] -le 0|=Damage;0 [Armor Absorbed Hit] This will calculate the damage and just set it to 0 if it is less than/equal to zero. If that isn't the case, Damage won't be changed.
1620323180
Kurt J.
Pro
API Scripter
Rosco James said:         I'm trying to make this work without success  --+|Begin test [&WeaponType] (code marker) --C [&WeaponType]|Melee:>Melee;&WeaponType|Range:>Range --X| --:Melee|%{Weapon|Attack_Header_Melee} --<| --:Range|%{Weapon|Attack_Header_Range} --<| --+|End test [&WeaponType] (code marker) I tried using quotes around comparisons with no luck. I'm not sure what the --X| does, nor how to close the case statement in case that's an issue. I flanked the code with two vars to see if the suspect code even completed - it did not. If I can't get this to work, I'm afraid to spend time are larger case statements. Thanks ahead of time for any help. So this line: --C [&WeaponType]|Melee:>Melee;&WeaponType|Range:>Range Should have the space removed between the --c and the [&WeaponType], but further the line is essentially saying: Look at the value of [&WeaponType] and do something based on the value. if the value is "Melee", call the "Melee" subroutine, passing it the literal text string of "&WeaponType" as the first parameter. If it is "Range", call the Range subroutine without passing any parameters. When the Melee subroutine is called (which it won't be with the space in front of the [&WeaponType] above because " Melee" and "Melee" aren't equal), the following line will be jumped to: --:Melee|%{Weapon|Attack_Header_Melee} But there are a couple of issues here. First, --:Melee defines a label line. The content portion of a label line (after the |) are ignored, so the macro call won't do anything. Then execution will be returned from the subroutine because the next line is --<| (return statement). Macros can't be called by simply including the call into the ScriptCard, though, because the chat server will have already processed it.
1620323469

Edited 1620323503
Kurt J.
Pro
API Scripter
Woombak said: Easy one folks : I'm having a --I statement asking one of my player to select a token that he would like to heal... I store the aimed token_id in a variable named  MonPatient  I can then use Tokenmod to succesfully manipulate bar1 of that token. But I can't figure how to display the charactername of that token in my result window!..... I tried the following : --:Soin mental mineur| --#sourceToken|@{selected|token_id} --#title|Soin mental mineur --#whisper|0 --&Pouvoir|Soin mental mineur --#emoteText|[*S:character_name] utilise [&Pouvoir] --IScriptCards a besoin de savoir quelle personne tu veux soigner;Click pour choisir un patient|t;MonPatient;Patient --+MonPatient|[&MonPatient] --&Desc1a|[*S:character_name] peut soigner une blessure mentale légère.  --&Desc1b|[[&MonPatient]:t-represents] gagne immédiatement 2 points d'Esprit.  --+|[&Desc1a] --+|[&Desc1b] -->LibShaan_Draw|[&MonPatient];1;-2 --X| --:LibShaan_Draw|Parameters are tokenid;bar#;amount --@token-mod|_ignore-selected _ids [%1%] _set bar[%2%]_value|-[%3%] --<| Which results in : MonPatient seems to fetch the right T-id but I just would like to have " Songe de Foudre gagne immédiatement 2 points d'Esprit." instead of  " -MZj5-qWLEpxSDrMC9PF  gagne immédiatement 2 points d'Esprit."...... In the meantime if I could succesfully use the T:represents  (to have it show  Songe de Foudre  which is the character name) what should I add at the end of my emote in order to get the token image of the token_id sotred in  MonPatient ? Token IDs are just strings that all happen to start with "-". You can use the [*token-id:attribute] syntax to retrieve associated values from them like this: [*[&MonPatient]:character_name] This references the token associated with the given ID and looks for the associated attribute, so this line --&Desc1b|[[&MonPatient]:t-represents] gagne immédiatement 2 points d'Esprit.  could be changed to --&Desc1b|[*[&MonPatient]:character_name] gagne immédiatement 2 points d'Esprit.  And that should output your desired result.
Kurt J. said: Version 1.2.2a with Bug Fixes Thanks to Dellatosa and GM Goss for finding bugs in the parameter code. As far as I can tell, I have them all squashed on the latest GIST release (famous last words, I know!) :) For the curious, I messed up parameter numbering, so everything was shifted by 1 in the case of conditionals. I also had a bug that was leaving the separators (;) characters at the end of the parameters. I've tried 1.2.2 with the Fireball script and with several test script for conditionals with parameters as well as case statements. Please let me know if anything isn't working as intended. Thanks a lot Kurt ! It works fine for me.
@Kurt J. - Got it.  Conditionals are restated with each comparison.  Good to know!  Thanks.
Kurt J. said: Woombak said: Easy one folks : I'm having a --I statement asking one of my player to select a token that he would like to heal... I store the aimed token_id in a variable named  MonPatient  I can then use Tokenmod to succesfully manipulate bar1 of that token. But I can't figure how to display the charactername of that token in my result window!..... I tried the following : --:Soin mental mineur| --#sourceToken|@{selected|token_id} --#title|Soin mental mineur --#whisper|0 --&Pouvoir|Soin mental mineur --#emoteText|[*S:character_name] utilise [&Pouvoir] --IScriptCards a besoin de savoir quelle personne tu veux soigner;Click pour choisir un patient|t;MonPatient;Patient --+MonPatient|[&MonPatient] --&Desc1a|[*S:character_name] peut soigner une blessure mentale légère.  --&Desc1b|[[&MonPatient]:t-represents] gagne immédiatement 2 points d'Esprit.  --+|[&Desc1a] --+|[&Desc1b] -->LibShaan_Draw|[&MonPatient];1;-2 --X| --:LibShaan_Draw|Parameters are tokenid;bar#;amount --@token-mod|_ignore-selected _ids [%1%] _set bar[%2%]_value|-[%3%] --<| Which results in : MonPatient seems to fetch the right T-id but I just would like to have " Songe de Foudre gagne immédiatement 2 points d'Esprit." instead of  " -MZj5-qWLEpxSDrMC9PF  gagne immédiatement 2 points d'Esprit."...... In the meantime if I could succesfully use the T:represents  (to have it show  Songe de Foudre  which is the character name) what should I add at the end of my emote in order to get the token image of the token_id sotred in  MonPatient ? Token IDs are just strings that all happen to start with "-". You can use the [*token-id:attribute] syntax to retrieve associated values from them like this: [*[&MonPatient]:character_name] This references the token associated with the given ID and looks for the associated attribute, so this line --&Desc1b|[[&MonPatient]:t-represents] gagne immédiatement 2 points d'Esprit.  could be changed to --&Desc1b|[*[&MonPatient]:character_name] gagne immédiatement 2 points d'Esprit.  And that should output your desired result. Thanks Kurt ! That solved the first issue with the character name. What about the icon of the token_id stored in MonPatient being showned in the emote ? When I change the following : --#emoteText|[*S:character_name] utilise [&Pouvoir] By : --#emoteText|[*S:character_name] utilise [&Pouvoir] pour soigner [*[&MonPatient]:character_name] I just get the following: Instead of the icon of the target being healed.... What am I doing wrong please ?
1620338881
Kurt J.
Pro
API Scripter
Woombak said: Kurt J. said: Woombak said: Easy one folks : I'm having a --I statement asking one of my player to select a token that he would like to heal... I store the aimed token_id in a variable named  MonPatient  I can then use Tokenmod to succesfully manipulate bar1 of that token. But I can't figure how to display the charactername of that token in my result window!..... I tried the following : --:Soin mental mineur| --#sourceToken|@{selected|token_id} --#title|Soin mental mineur --#whisper|0 --&Pouvoir|Soin mental mineur --#emoteText|[*S:character_name] utilise [&Pouvoir] --IScriptCards a besoin de savoir quelle personne tu veux soigner;Click pour choisir un patient|t;MonPatient;Patient --+MonPatient|[&MonPatient] --&Desc1a|[*S:character_name] peut soigner une blessure mentale légère.  --&Desc1b|[[&MonPatient]:t-represents] gagne immédiatement 2 points d'Esprit.  --+|[&Desc1a] --+|[&Desc1b] -->LibShaan_Draw|[&MonPatient];1;-2 --X| --:LibShaan_Draw|Parameters are tokenid;bar#;amount --@token-mod|_ignore-selected _ids [%1%] _set bar[%2%]_value|-[%3%] --<| Which results in : MonPatient seems to fetch the right T-id but I just would like to have " Songe de Foudre gagne immédiatement 2 points d'Esprit." instead of  " -MZj5-qWLEpxSDrMC9PF  gagne immédiatement 2 points d'Esprit."...... In the meantime if I could succesfully use the T:represents  (to have it show  Songe de Foudre  which is the character name) what should I add at the end of my emote in order to get the token image of the token_id sotred in  MonPatient ? Token IDs are just strings that all happen to start with "-". You can use the [*token-id:attribute] syntax to retrieve associated values from them like this: [*[&MonPatient]:character_name] This references the token associated with the given ID and looks for the associated attribute, so this line --&Desc1b|[[&MonPatient]:t-represents] gagne immédiatement 2 points d'Esprit.  could be changed to --&Desc1b|[*[&MonPatient]:character_name] gagne immédiatement 2 points d'Esprit.  And that should output your desired result. Thanks Kurt ! That solved the first issue with the character name. What about the icon of the token_id stored in MonPatient being showned in the emote ? When I change the following : --#emoteText|[*S:character_name] utilise [&Pouvoir] By : --#emoteText|[*S:character_name] utilise [&Pouvoir] pour soigner [*[&MonPatient]:character_name] I just get the following: Instead of the icon of the target being healed.... What am I doing wrong please ? The icon shown on the left side of the emote is the icon for whatever is stored in sourcetoken when the card finishes processing. Somewhere before the end of the card, just set --#sourcetoken|[&MonPatient]. Alternatively, if you want both tokens, set the targettoken to the person being healed with --#targettoken|[&MonPatient]. The icon for the target token will show up on the right hand side of the emote.
Kurt J. / David M. - I wanted to revisit a previous problem.  I find if I leave something alone for awhile and come back to it I can see the issue sometimes.  In this case, no such luck. Kurt J.  said: Michael C.  said: I am sorry to pester again but I can't figure this out.  I'm sure it's some stupid syntax issue. Working on a Long Rest script with a counter.  My  title section does contain    --#sourceToken|@{selected|token_id}  The problem entry is:   --:Counter|     --=SlotLevel|1   --:NextLevel|     --?[*S:lvl[$SlotLevel]_slots_total] -eq 0|AdjustSlots;[$Level]     --=SlotLevel|[$SlotLevel] + 1     --?[$SlotLevel] -gt 9|EndMacro   --^NextLevel| The problem is that the macro keeps telling me that     [*S:lvl[$SlotLevel]_slots_total]   is undefined.  Any help would be appreciated... I can look at the code to be certain, but I think roll variables are processed at different times when building a line than strings. Strings always go first, so if you replace SlotLevel with a string variable (--&SlotLevel|1 and [&SlotLevel]) it will likely parse out correctly. I believe RollVars get processed after [*:] references. I tried Gabryel's suggestion to put the numeric variable in quotes (to no avail) and Kurt's suggestion to use a string vs. numeric variable:  --:Counter|     -- & SlotLevel|1   --:NextLevel|     --?[*S:lvl[ & SlotLevel]_slots_total] -eq 0|AdjustSlots;[$Level]     --=SlotLevel|[$SlotLevel] + 1     --?[$SlotLevel] -gt 9|EndMacro   --^NextLevel| (also to no avail).  The construction logic seems flawless as, which David pointed out, when one uses --+| on the same instruction it prints the slot total even though the macro operation says it's undefined. Add to that, a script that Kurt made for checking available slots is virtually identical yet works:   --:GetAndCheckSlotInformation|     --=SlotLevel|[$SpellLevel]     --=SlotsTotal|[*S:lvl[$SlotLevel]_slots_total]     --=SlotsExpended|[*S:lvl[$SlotLevel]_slots_expended]     --?[$SlotsExpended.Total] -ge [$SlotsTotal.Total]|NoSlotsLeft I am kerfuffled.
1620393317

Edited 1620393458
David M.
Pro
API Scripter
Michael, it looks like it is a parsing order of operations issue. To get around it, I think you could assign  [*S:lvl[$SlotLevel]_slots_total] to a roll variable first, then use the roll variable for your conditional. This example seems to work for me (note I made up some stuff to make it a self-contained scriptcard). Also, it looks like you are trying to pass an argument into an AdjustSlots procedure, but were using gosub branch label syntax, so I modified to ">AdjustSlots" !script {{ --#sourceToken|@{selected|token_id} --=SlotLevel|1 --:NextLevel| --=numSlots|[*S:lvl[$SlotLevel]_slots_total] -->DisplayNumSlots|[$SlotLevel];[$numSlots] --?[$numSlots] -eq 0| >AdjustSlots ;[$SlotLevel] --=SlotLevel|[$SlotLevel] + 1 --?[$SlotLevel] -gt 9|EndMacro --^NextLevel| --:EndMacro| --X| --:AdjustSlots| --+Slot adjustment code for level [%1%]| --<| --:DisplayNumSlots| --+Current level [%1%] slots|[%2%] --<| }}
1620403928
Kurt J.
Pro
API Scripter
Some (most) token attributes aren't available with the @{} notation on the chat server. Not sure why, but if you were to just type in @{target|door|aura1_radius} and hit enter you would probably just see the same text as output. You can retrieve these properties from inside a scriptcard using the [*tokenid:t-attribute] notation: --=DisarmRoll|1d20 + [*@{target|door|token_id}:t-aura1_radius]
Kurt - Do you know if the fields on the Character object are exposed within scriptcard?  Specifically, the character.controlledby  and character.bio field.  I believe that some of the other character fields like GMNotes are a little tricky due to the way they are stored and the need to retrieve asynchronously.  
David M. - Well, slap me silly and call me "red" - that did work.  (Of course, I should have known better about the missing the ">" but...sigh...did I mention I'm old?)  ;-)
Will a roll query show regardless of where it is in the code?  I want to ask the player if they would like to disarm a trap, but only if they notice it.  The roll query is popping up regardless.
1620442377
David M.
Pro
API Scripter
Brien: Yes, a ?{prompt|value...} query gets processed by the chat parser before the result is sent to the script. 
Hi, all: Using ScriptCards, is there a way to test for a token bar's Attribute reference? I want to be able to: if bar2 attribute is npc_ac then TargetAC = if bar3 attribute is npc_ac then TargetAC =     Some creatures use bar 2 for npc_ac while others use bar 3. I know I can get the data from the character sheet, but I'm manipulating the token in this case. Actually, I've seen some creature's tokens that don't even make a reference, but that's for another day.  In any case, I have varied plans for the other bars, if it's possible to test.     Thanks for the help.
1620494639

Edited 1620494905
Trying to call the API Script !find-token ( link to !find-token ) from ScriptCards(version 1.2.2a) but it crash the sandbox when I do.   This works: !find-token --Kharg This does not: !scriptcard {{ --@find-token|_Kharg }} and throws this error message: For reference, the error message generated was:  TypeError: Cannot read property 'get' of undefined TypeError: Cannot read property 'get' of undefined at apiscript.js:22369:57 at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:154:1), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1663: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) at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:111:461 I've added debug/log code to the Find-Token script, but it never outputs, suggesting that it is never really called.  Any ideas? 
1620502559
David M.
Pro
API Scripter
@Will: it is being called but erroring out on this line of find-token: const pname = getObj('player', msg.playerid).get('_displayname') The issue is that msg.playerid is 'API' when called from scriptcards, so getObj('player', msg.playerid) is undefined. Can't get the displayname of undefined. Any workarounds I can think of solely within the find-tokens script would likely lose some functionality (like "player-safe" features so they can't find npc tokens, etc.) I'm sure Scriptcards is getting playerid, but I don't believe it is currently exposed to the macro writer. If that were possible, you could modify find-token to accept playerid as a parameter and proceed as normal. One option might be timmaugh's Plugger meta-script . I haven't used it yet, but if you search the page linked for "who called" it looks like there is a way to modify the find-token scriptlet to test for a plugger-generated "msg.eval" property and grab a playerid. I'm afraid it's just in the idea phase for me at the moment, so here's me pressing the Tim button ! From the Plugger documentation: Accept a Message A plugin for Plugger should accept a message object, just as any function that answers a chat event (i.e., handleInput). In fact, your script can also answer a chat event if you like (more on that under Who Called?). The message object will be identical to a message that would be received from a user – it will have properties of  who ,  playerid ,  content , etc.
1620510497

Edited 1620510538
@David:  Thank you for for pointing me in the right direction.  You were correct that msg.playerid is 'API' when called from SC.  As the current version of this will only be for GM use, I ended up writing a subroutine to find the GM playerid for the campaign and then using it for when I call sendping.   I got this working for now, but will also look into Plugger.  
Kurt J. said: Woombak said: Kurt J. said: Woombak said: Easy one folks : I'm having a --I statement asking one of my player to select a token that he would like to heal... I store the aimed token_id in a variable named  MonPatient  I can then use Tokenmod to succesfully manipulate bar1 of that token. But I can't figure how to display the charactername of that token in my result window!..... I tried the following : --:Soin mental mineur| --#sourceToken|@{selected|token_id} --#title|Soin mental mineur --#whisper|0 --&Pouvoir|Soin mental mineur --#emoteText|[*S:character_name] utilise [&Pouvoir] --IScriptCards a besoin de savoir quelle personne tu veux soigner;Click pour choisir un patient|t;MonPatient;Patient --+MonPatient|[&MonPatient] --&Desc1a|[*S:character_name] peut soigner une blessure mentale légère.  --&Desc1b|[[&MonPatient]:t-represents] gagne immédiatement 2 points d'Esprit.  --+|[&Desc1a] --+|[&Desc1b] -->LibShaan_Draw|[&MonPatient];1;-2 --X| --:LibShaan_Draw|Parameters are tokenid;bar#;amount --@token-mod|_ignore-selected _ids [%1%] _set bar[%2%]_value|-[%3%] --<| Which results in : MonPatient seems to fetch the right T-id but I just would like to have " Songe de Foudre gagne immédiatement 2 points d'Esprit." instead of  " -MZj5-qWLEpxSDrMC9PF  gagne immédiatement 2 points d'Esprit."...... In the meantime if I could succesfully use the T:represents  (to have it show  Songe de Foudre  which is the character name) what should I add at the end of my emote in order to get the token image of the token_id sotred in  MonPatient ? Token IDs are just strings that all happen to start with "-". You can use the [*token-id:attribute] syntax to retrieve associated values from them like this: [*[&MonPatient]:character_name] This references the token associated with the given ID and looks for the associated attribute, so this line --&Desc1b|[[&MonPatient]:t-represents] gagne immédiatement 2 points d'Esprit.  could be changed to --&Desc1b|[*[&MonPatient]:character_name] gagne immédiatement 2 points d'Esprit.  And that should output your desired result. Thanks Kurt ! That solved the first issue with the character name. What about the icon of the token_id stored in MonPatient being showned in the emote ? When I change the following : --#emoteText|[*S:character_name] utilise [&Pouvoir] By : --#emoteText|[*S:character_name] utilise [&Pouvoir] pour soigner [*[&MonPatient]:character_name] I just get the following: Instead of the icon of the target being healed.... What am I doing wrong please ? The icon shown on the left side of the emote is the icon for whatever is stored in sourcetoken when the card finishes processing. Somewhere before the end of the card, just set --#sourcetoken|[&MonPatient]. Alternatively, if you want both tokens, set the targettoken to the person being healed with --#targettoken|[&MonPatient]. The icon for the target token will show up on the right hand side of the emote. Thanks a lot Kurt ! If you ever come to France i'll buy you a few beers....^^ (or wine)
1620516609
David M.
Pro
API Scripter
Will M. said: @David:  Thank you for for pointing me in the right direction.  You were correct that msg.playerid is 'API' when called from SC.  As the current version of this will only be for GM use, I ended up writing a subroutine to find the GM playerid for the campaign and then using it for when I call sendping.   I got this working for now, but will also look into Plugger.   Yeah, going gm-only pretty much all I could think of without going down the potential meta-script route. Glad you got something working!
1620520237
timmaugh
Pro
API Scripter
Will M. said: @David:  Thank you for for pointing me in the right direction.  You were correct that msg.playerid is 'API' when called from SC.  As the current version of this will only be for GM use, I ended up writing a subroutine to find the GM playerid for the campaign and then using it for when I call sendping.   I got this working for now, but will also look into Plugger.    David was right that Plugger can do something like this for you, but you might also get some mileage out of SelectManager. SM can be configured to not only give back the selected tokens to an API message, but either/and/or of the playerid and who properties. It tracks all of those, but only "ships" preconfigured to hand back the selected tokens. Send this line through your chat to configure SelectManager to give the playerid back (so your script can find it): !smconfig +playerid That should make your API-generated messages now haver the original player who sent the call. Note that SM doesn't ship with this turned on because there are a couple of campaign-level scripts that fire based on other events than a user chat message. Some of these scripts rely on being able to differentiate whether the call came from the API or a player, and so they can respond with different behavior. In this case, configuring the auto-hand-back of the playerid might not be wise.
1620566909
Kurt J.
Pro
API Scripter
Will M. said: Kurt - Do you know if the fields on the Character object are exposed within scriptcard?  Specifically, the character.controlledby  and character.bio field.  I believe that some of the other character fields like GMNotes are a little tricky due to the way they are stored and the need to retrieve asynchronously.   They aren't available at the moment (as you say they are object properties as opposed to attributes). I can easily add everything except notes/gmnotes/bio since all three of those require async retrieval.
1620567563

Edited 1620567578
Kurt J.
Pro
API Scripter
David M. said: @Will: it is being called but erroring out on this line of find-token: const pname = getObj('player', msg.playerid).get('_displayname') The issue is that msg.playerid is 'API' when called from scriptcards, so getObj('player', msg.playerid) is undefined. Can't get the displayname of undefined. Any workarounds I can think of solely within the find-tokens script would likely lose some functionality (like "player-safe" features so they can't find npc tokens, etc.) I'm sure Scriptcards is getting playerid, but I don't believe it is currently exposed to the macro writer. If that were possible, you could modify find-token to accept playerid as a parameter and proceed as normal. One option might be timmaugh's Plugger meta-script . I haven't used it yet, but if you search the page linked for "who called" it looks like there is a way to modify the find-token scriptlet to test for a plugger-generated "msg.eval" property and grab a playerid. I'm afraid it's just in the idea phase for me at the moment, so here's me pressing the Tim button ! From the Plugger documentation: Accept a Message A plugin for Plugger should accept a message object, just as any function that answers a chat event (i.e., handleInput). In fact, your script can also answer a chat event if you like (more on that under Who Called?). The message object will be identical to a message that would be received from a user – it will have properties of  who ,  playerid ,  content , etc. Hmmm... I don't think it is documented anywhere (oops) but if ScriptCards can find a player associated with the macro, it creates the following string variables: &SendingPlayerID - Contains the object ID of the player that sent the macro &SendingPlayerName - Contains the display name of the player &SendingPlayerColor - Contains the color code associated with the player &SendingPlayerSpeakingAs - The contents of the "Speaking As" dropdown window &SendingPlayerIsGM - Contains 1 if the player is a GM, and 0 if the player is NOT a GM
1620569167
David M.
Pro
API Scripter
Ah, cool! So it sounds like complete solutions for Will would be one of the following: Edit the !find-tokens script to optionally accept a playerid as a parameter, and pass that playerid to the script when called from scriptcards Toggle the SelectManager globalConfig "+playerid" flag (though could affect other scripts that check for msg.playerid==='API') Figure out the Plugger syntax
1620575479

Edited 1620575737
Thanks David and Kurt, your advice as always has been great!  I've gone down the route of re-writing the !find-tokens script (helps me develop my JS skills for future projects).  That said, I've been intrigued by SelectManager for a while and plan to dive into the meta script for some of my more advanced ideas.   I'm about 80% done on my NPC Layer tool.  The SC Reentry logic has been a HUGE functionality boost.  That combined with option to #hidecard|1 and #whisper|gm allows be to create very nice menu systems without polluting the chat area.  Finally, !token-mod is an amazing all-around tool I keep going back to. Description of NPC Layer Tool     Lists all the NPCs on the current page.      The bolded letter indicates the layer the NPC is on (O-objects, G-gmlayer, M-map, L-walls).  Actions     Clicking on the NPC name, pings and moves focus to that NPC (!find-token*).      Clicking on one of the letters, moves the token to the associated layer (!token-mod).      I'm also considering adding other objects like secret doors and traps.
1620575531
timmaugh
Pro
API Scripter
Yes, sorry... I should have included that bit about the Plugger syntax. I'll try to keep the footprint of the meta stuff in this thread to a minimum, but just so it's all in one place should anyone want to know how to do it... Plugger can call scripts (like ScriptCards can), where it sends the command through the chat parser. Doing that creates an entirely new message with the playerid = 'API', so it doesn't help you on its own. However, Plugger also allows scripts to register as "plugins" so that instead of sending a new message to the chat parser, it simply hands off to the registered function the message object as it stands (with the playerid, inlinerolls, content, etc.). Scripts that register as plugins also gain the opportunity to return something to the command line if they want. That's where the "who called?" question comes into play. If your plugin can detect that it was called from Plugger, it might want to return something to the command line. Obviously, if you don't return anything, a zero-length string is returned, and by the time ScriptCards receives the macro line, it has no idea all of this went on. To register find-token as a plug-in, you'll want this somewhere in that script: on('ready', () => {     try {         Plugger.RegisterRule(handleInput);     } catch (error) {         log(error);     } }); Where "handleInput" is whatever function handles the chat event. Using a generic name like "handleInput" can lead to name collisions if you register a few scripts to Plugger and they all use the "handleInput" name for their chat handler. In that case, I suggest a renaming wrapper function: const findtokenHandleInput (m) = handleInput;(m); ...and then registering that wrapper in the try/catch example just above, or exposing the chat handler from find-token, then registering the fully qualified name: Plugger.RegisterRule(findtoken.handleInput) However you register it, to call it, take the command line as you would send it through chat and use parentheses to wrap around the arguments. Put all of that in {&eval} ... {& /eval} tags: {&eval}find-token(--Kharg){& /eval} That will run the find-token script as if the command line were "!find-token --Kharg", but it will do it with the inlinerolls, who, playerid, etc., already caught and processed from when the ScriptCards macro was called. If you DON'T need ScriptCards to do anything based on the result of calling find-token, then you can put it anywhere in the ScriptCards macro and make sure it returns nothing (which most scripts do -- they return nothing from their handleInput function). If it DOES return something already and you don't want it to, just bury it in ScriptCards syntax that won't go anywhere... like assign it to a variable you'll never use. If you WANT it to return something and it does not currently (like the token's location, let's say), then you can add a couple of lines to the bottom of the handleInput function in find-token. if(msg.eval) {     return... } And add whatever you want it to return. As long as that is text, number, boolean, or bigint, the results returned from a plugin are put into the macro line in place of the entire {& eval}...{& /eval} structure, leaving that new content there for when ScriptCards parses the line. OK, so maybe not a huge success keeping the meta footprint on the ScriptCards thread to a minimum, but that's all the info you should need to turn find-token into a Plugger plugin that can run in your ScriptCards macro. In deference to Kurt, if you have any questions, hit me up on the Plugger thread and I'll answer them there!
Strangest thing ever.       Here is a set of variables being assigned. Everything works  EXCEPT FOR the: --=AttackerStrBonus | @{selected|strength_bonus} . I cannot get the variable AttackerStrBonu s assigned to the selected field value. All the other variables assign. Below I test the existence of a value along with one that does assign (as all others do). I've rewritten it, renamed it, shuffled the list of variables, copied to a text file and back, rebooted; everything I could think of. It just won't assign. I checked the api console for errors - nada. --:Assign Variables|  --=AttackerAtkBonus | @{selected|attack_bonus}   --=AttackerStrBonus | @{selected|strength_bonus}  --=AttackerDexBonus | @{selected|dexterity_bonus}  --=AttackerConBonus | @{selected|constitution_bonus}  --=AttackerIntBonus | @{selected|intelligence_bonus}  --=AttackerWisBonus | @{selected|wisdom_bonus}  --=AttackerChaBonus | @{selected|charisma_bonus} --:Display results|  --+|AttackerAtkBonus | [$AttackerAtkBonus] returns a value as do the others   --+|AttackerStrBonus | [$AttackerStrBonus] will not return any value - zip  --+|AttackerStrBonus | @{selected|strength_bonus} returns its value of 5 Looking for a clue if you've got one. Thanks ahead of time
1620645114

Edited 1620645271
David M.
Pro
API Scripter
@Rosco, The last line is the only one that works for me when copying what you posted (the one not using any variables). The issue is the space after each variable names. When I removed those, it worked for me. EDIT - Leaving the space in there and adding a space in the variable reference (e.g. [$AttackerStrBonus ]) also works, but of course you wouldn't want that.
Little help please. Try to create a saving throw card. See code below. Type is what saving throw example strength etc Bonus part is not working where I am try to insert the name aka strenght into the code to pull the correct mod @{Selected|strenght_save_bonus} Most likely a order of operation issue but I can't figure it out.  !scriptcard {{ --#title|SavingThrows --#emoteText|@{selected|token_name} --#sourceToken|@{selected|token_id} --#leftsub|[*S:character_name] --#rightsub|Save type:[&Type] --#titleFontColor|#FFFFFF --#titleCardBackground|#932729 --#evenRowBackground|#B6AB91 --#evenRowFontColor|#000000 --#oddRowBackground|#CEC7B6 --#oddRowFontColor|#000000 --#emoteBackground|#FFFFFF --#tableBorderRadius|8px --:|Type --&Type|?{Saving Throw Type?|Strenght,strenght|Dexterity,Dexterity|Constition,Constition|Intelligence,Intelligence|Wisdom,Wisdom|Charisma,Charisma} --+Type|[&Type] --:|Bonus --&BonusType|@{selected|[&Type]_save_bonus} --+|Bonus| [&BonusType] --:|Advantage, Disadvantage, Normal --&RollType|?{Advantage or Disadvantage?|Normal,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1} --:|Roll --=Save|[&RollType] + [&BonusType] --+Saving Throw is|[$Save] }} Also I added powercards API to my new game and my scriptcards stop working can we not run both? 
1620655070

Edited 1620656725
David M.
Pro
API Scripter
Looks like a typo? Strength is spelled "strenght" :) Also might be case-sensitive. All the other attributes are capitalized. EDIT - More importantly, the @{selected....} part gets parsed before scriptcards starts to run. You will need to populate several variables, each with @{selected|strength_save_bonus}, etc so it gets parsed into scriptcards properly. Then, use a query to refer to the appropriate variable. EDIT 2 - Try this. !scriptcard {{ --#title|SavingThrows --#emoteText|@{selected|token_name} --#sourceToken|@{selected|token_id} --#leftsub|[*S:character_name] --#rightsub|Save type:[&Type] --#titleFontColor|#FFFFFF --#titleCardBackground|#932729 --#evenRowBackground|#B6AB91 --#evenRowFontColor|#000000 --#oddRowBackground|#CEC7B6 --#oddRowFontColor|#000000 --#emoteBackground|#FFFFFF --#tableBorderRadius|8px --:Initial variable population| --=strength_save_bonus|@{selected|strength_save_bonus} --=dexterity_save_bonus|@{selected|strength_save_bonus} --=constitution_save_bonus|@{selected|strength_save_bonus} --=intelligence_save_bonus|@{selected|strength_save_bonus} --=wisdom_save_bonus|@{selected|strength_save_bonus} --=charisma_save_bonus|@{selected|strength_save_bonus} --:Type| --&Type|?{Saving Throw Type?|Strength,strength|Dexterity,dexterity|Constition,constition|Intelligence,intelligence|Wisdom,wisdom|Charisma,charisma} --+Type|[&Type] --:Bonus| --=BonusType|[$[&Type]_save_bonus} --+Bonus| [$BonusType] --:Advantage, Disadvantage, Normal| --&RollType|?{Advantage or Disadvantage?|Normal,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1} --:Roll| --=Save|[&RollType] + [$BonusType][Bonus] --+Saving Throw is|[$Save] }}
@David M, Removing the space flanking the bar solved the issue. Thank you for your quick response. You guys are gold. Assignment: --=AttackerStrBonus|@{selected|strength_bonus}  Display: --+|AttackerStrBonus   |  [$AttackerStrBonus] The reason for the spaces is to make the code easier to line-up, follow, and maintain. -- In the beginning, the gods of code had to account for every excessive space, every unneeded digit in order to operate in an environment with so little memory and storage space. It saved space, but created impossible code to maintain or even understand six months later. Example code requirement:  If the pipe is longer than 25 feet, then adjust the water pressure p>f :a(p) [minimum spaces/digits, no notes] -- In middle-earth times, as memory and storage space grew, better visibility and maintenance allowed for easier code to understand and maintain: if $pipe > $feet gosub adj(Pipe)  [minimal spaces and digits, no notes] But still, space was a premium so keep blank spaces to a minimum. [still no notes] In modern times, the code might roughly look like: if($PipeLength > $CodeLength) { AdjustWaterPressure($PipeLength) }  // Note: See associated function $PipeCircumference() -- It seems anachronistic, certainly inconsistent, absolutely non-intuitive that an assignment statement like --=X|Y   disallows a space when the display, --+X  |  Y , does not.   But then, I'm not a god of code. (Yeah, I know I skipped the age of compilers, but you get my point). David M. said: @Rosco, The last line is the only one that works for me when copying what you posted (the one not using any variables). The issue is the space after each variable names. When I removed those, it worked for me. EDIT - Leaving the space in there and adding a space in the variable reference (e.g. [$AttackerStrBonus ]) also works, but of course you wouldn't want that.
1620664659

Edited 1620664754
David M.
Pro
API Scripter
Kurt, perhaps a .trim() could be added when parsing the variable names to allow these spaces for macro readability and to be consistent with the direct output (--+) behavior? e.g.  --&stringVar | some val        //currently the variable name is "stringVar " with a space, requiring the reference [&stringVar ]
1620664997
Kurt J.
Pro
API Scripter
David M. said: Kurt, perhaps a .trim() could be added when parsing the variable names to allow these spaces for macro readability and to be consistent with the direct output (--+) behavior? e.g.  --&stringVar | some val        //currently the variable name is "stringVar " with a space, requiring the reference [&stringVar ] Already in the code for the next release. I just need to do some testing to make sure it doesn't break anything :)
1620684891

Edited 1620685648
Hi, Community. I've dropped powercard templates and replacement to look at this bootstrap project. Which is amesome by the way Kurt ! I do appreciate so much the distance function between token, since i'm playing D&D 3.5 (and so, a pre-requisite to compute malus to attack roll depending on target distance). So, D&D3.5, Diana P. sheet and scriptcards. I'm wondering what is wrong here... Some of the sheet attributes are really clumsy and obfuscated expressions. Take Armorclass attribute for instance, in the chat server : @{selected|armorclass} -> (10+((1 (10) +1 (0) +0 0 +0 0 +0 0 +0 0))+(1 (ceil(((ceil((2 -20 (100-99 1))/10000000000) 20 - floor((2 -20 (100-99 1)-1)/10000000000) 2 )-floor(abs(9/(0.1))))/10000000000) floor(abs(9/(0.1))) - floor(((ceil((2 -20 (100-99 1))/10000000000) 20 - floor((2 -20 (100-99 1)-1)/10000000000) 2 )-floor(abs(9/(0.1)))-1)/10000000000) (ceil((2 -20 (100-99 1))/10000000000) 20 - floor((2 -20 (100-99 1)-1)/10000000000) 2 )) +0 (0 (ceil(((ceil((0 -20 (100-99 1))/10000000000) 20 - floor((0 -20 (100-99 1)-1)/10000000000) 0 )-floor(abs(9/(0.1))))/10000000000) floor(abs(9/(0.1))) - floor(((ceil((0 -20 (100-99 1))/10000000000) 20 - floor((0 -20 (100-99 1)-1)/10000000000) 0 )-floor(abs(9/(0.1)))-1)/10000000000) (ceil((0 -20 (100-99 1))/10000000000) 20 - floor((0 -20 (100-99 1)-1)/10000000000) 0 )) + (1-0) 0) +0 (0 (ceil(((ceil((0 -20 (100-99 1))/10000000000) 20 - floor((0 -20 (100-99 1)-1)/10000000000) 0 )-floor(abs(9/(0.1))))/10000000000) floor(abs(9/(0.1))) - floor(((ceil((0 -20 (100-99 1))/10000000000) 20 - floor((0 -20 (100-99 1)-1)/10000000000) 0 )-floor(abs(9/(0.1)))-1)/10000000000) (ceil((0 -20 (100-99 1))/10000000000) 20 - floor((0 -20 (100-99 1)-1)/10000000000) 0 )) + (1-0) 0) +0 (0 (ceil(((ceil((0 -20 (100-99 1))/10000000000) 20 - floor((0 -20 (100-99 1)-1)/10000000000) 0 )-floor(abs(9/(0.1))))/10000000000) floor(abs(9/(0.1))) - floor(((ceil((0 -20 (100-99 1))/10000000000) 20 - floor((0 -20 (100-99 1)-1)/10000000000) 0 )-floor(abs(9/(0.1)))-1)/10000000000) (ceil((0 -20 (100-99 1))/10000000000) 20 - floor((0 -20 (100-99 1)-1)/10000000000) 0 )) + (1-0) 0))+0+(0 0 +0 0 +0 0 +0 0)+(0 0 +0 0 +0 0 +0 0)+(0 0 +0 0 +0 0 +0 0)+(0 1 0 1 +1 1 1 +0 1 0 +0 1 0 +0 1 0 +0 1*0)) Arf, so much floor and ceil and stuff. If we roll the attribute in the chatsrv... it is nicely computed : [[@{selected|armorclass}]] -> 23 So in powercards, this was no trouble... !power {{   --tokenid|@{selected|token_id}   --name|powercard rocks   --hroll|[[ [$ac] 1d0+@{selected|armorclass} ]]   --display_result:| [^ac] armor class value }} 23AC ? Damned good AC. But what with the internal roll parser in scriptcards ?? !scriptcard {{   --#sourcetoken|@{selected|token_id}   --#title|scriptcards is the future, but...   --=AC| @{selected|armorclass}   --+AC_result:| [$AC] }} I would expect 23 as in powercard (targetting the same token, fetching the same attribute), but instead the result is 0.  Here is the console output... ["tokenid|-M_MCFYZSbpNQZiFAGZ4","name|powercard rocks","hroll|[[ [$ac] (10+((1*(10) +1*(0) +0*0 +0*0 +0*0 +0*0))+(1*(ceil(((ceil((2 -20*(100-99*1))/10000000000)*20 - floor((2 -20*(100-99*1)-1)/10000000000)*2 )-floor(abs(9/(0.1))))/10000000000)*floor(abs(9/(0.1))) - floor(((ceil((2 -20*(100-99*1))/10000000000)*20 - floor((2 -20*(100-99*1)-1)/10000000000)*2 )-floor(abs(9/(0.1)))-1)/10000000000)*(ceil((2 -20*(100-99*1))/10000000000)*20 - floor((2 -20*(100-99*1)-1)/10000000000)*2 )) +0*(0*(ceil(((ceil((0 -20*(100-99*1))/10000000000)*20 - floor((0 -20*(100-99*1)-1)/10000000000)*0 )-floor(abs(9/(0.1))))/10000000000)*floor(abs(9/(0.1))) - floor(((ceil((0 -20*(100-99*1))/10000000000)*20 - floor((0 -20*(100-99*1)-1)/10000000000)*0 )-floor(abs(9/(0.1)))-1)/10000000000)*(ceil((0 -20*(100-99*1))/10000000000)*20 - floor((0 -20*(100-99*1)-1)/10000000000)*0 )) + (1-0)*0) +0*(0*(ceil(((ceil((0 -20*(100-99*1))/10000000000)*20 - floor((0 -20*(100-99*1)-1)/10000000000)*0 )-floor(abs(9/(0.1))))/10000000000)*floor(abs(9/(0.1))) - floor(((ceil((0 -20*(100-99*1))/10000000000)*20 - floor((0 -20*(100-99*1)-1)/10000000000)*0 )-floor(abs(9/(0.1)))-1)/10000000000)*(ceil((0 -20*(100-99*1))/10000000000)*20 - floor((0 -20*(100-99*1)-1)/10000000000)*0 )) + (1-0)*0) +0*(0*(ceil(((ceil((0 -20*(100-99*1))/10000000000)*20 - floor((0 -20*(100-99*1)-1)/10000000000)*0 )-floor(abs(9/(0.1))))/10000000000)*floor(abs(9/(0.1))) - floor(((ceil((0 -20*(100-99*1))/10000000000)*20 - floor((0 -20*(100-99*1)-1)/10000000000)*0 )-floor(abs(9/(0.1)))-1)/10000000000)*(ceil((0 -20*(100-99*1))/10000000000)*20 - floor((0 -20*(100-99*1)-1)/10000000000)*0 )) + (1-0)*0))+0+(0*0 +0*0 +0*0 +0*0)+(0*0 +0*0 +0*0 +0*0)+(0*0 +0*0 +0*0 +0*0)+(0*1*0*1 +1*1*1 +0*1*0 +0*1*0 +0*1*0 +0*1*0)) ]]","display_result:| [^ac] armor class value "] Is this due to the parenthesis that are added in the formula of those attributes ? I may remember Kurt commenting the internal roll engine with something like -> left to right, no parenthesis, ... Anyway, lots and lots of 3.5 sheet attributes are like this one (flatac, armorclassdexmod, encumbrance, touchac, armorclass, and so on...) Are there any way to work around with those attributes and scriptcards ? Are we 3.5 players doomed ?? (note, using token bar2, which is configured to armorclass would work. But, like i said, it's not one attribute which is a problem, but almost all the sheet attributes).
1620692391
Kurt J.
Pro
API Scripter
ScriptCards version 1.2.3 Now Available Mostly a request-filling release this time around. Here are the changes (as always, available on the GIST ) (Will M) : It is now possible to retrieve object properties from characters (as opposed to just attributes). Things like "controlledby" are now available. Unfortunately, notes, gmnotes, and bio are not available because of the way they have to be retrieved by the API. (Rosco James/David M.) : Tag portions of a line are now trimmed, meaning trailing spaces should no longer cause them to be included at the end of variable names. Spaces inside variable names should still be fine. Trimming was already happening on the content side of a statement. (Lionel T.) : ScriptCards will now replace inline rolls with their total results, so it should be possible to use a syntax like: --=AC|[[ @{selected|armorclass} ]] --+AC|[$AC] but note that ONLY the total result will be used by ScriptCards. It will not break the roll down into components like to normal roll parser does. This does allow quite a bit more flexibility for totally insane sheet calculations, however :) I still recommend using the internal roll parser for most things, but at least this will let you set variables for things like 3.5 AC. New Functions : Added three new string functions: tolowercase, touppercase, and totitlecase. Each just takes the string to process as the only additional parameter and returns the result to the string variable named in the tag portion of the statement. "tolowercase" and "touppercase" are fairly obvious. "totitlecase" capitalizes the first letter of each word in the string (note that it doesn't account for things like not capitalizing "a" or "of", etc.) Behavior Change : setting the sourcetoken or targettoken to a non-existent token or something that doesn't represent a character will now clear the internal cached character object as well. This would be useful it you wanted to set a source/target for use with [*S:] or [*T:] notation but didn't want to display tokens in the emote section. Simply setting them to nothing (--#sourcetoken|) before the end of the script will remove the references.
What wizardry is this ? Kurt ! You evil lich ! Never sleeps, huh ? As far as i checked, 1.2.3 rocks solid with the inline rolls subs. Back on my 3.5 lib ! Also, Total result is fine by me ! Once again, great job !
HI folks! A simple one! How do you ignore a charater when you parse ? Being french we regurlarly use the ' sign. I have it in one spell and it seems to f....everything up! I removed it to be sure and it works perfectly! But when I remove it the spell title doesn't mean that much anymore.... I would like the parser to treat that bloody ' as a normal typo. Thanks in advance !
1620731701

Edited 1620731727
David M.
Pro
API Scripter
@Woombak, would the "replace" string function work for you? Here's how you use it. The first example is generic but I think might be easier to read. The second replaces the ' character with an empty string. !script {{ --#title|Replace Example --&Text|Hello World! --+Old Text|[&Text] --~Text|stringfuncs;replace;World;There;[&Text] --+New Text|[&Text] }} !script {{ --#title|Remove Single Character Example --&Text|Drizzt Do'Urden --+Old Text|[&Text] --~Text|stringfuncs;replace;';;[&Text] --+New Text|[&Text] }}
Having troubles with testing for strings. One of my conditional branches looks for a match between a damage type and NPC resistance.  (Unashamedly "borrowed" from Kurt's excellent fireball spell.)     --?[$AttackRoll.Total] -ge [$TargetAC.Total] -and [*T:npc_resistances] -inc [&DamageType]|>DamageResist;[&WeaponDmg] Also   --?[$AttackRoll.Total] -ge [$TargetAC.Total] -and "[*T:npc_resistances]" -inc "[&DamageType]"|>DamageResist;[&WeaponDmg] I have printed the contents of each variable  prior to the conditional branch.  In each case [*T:npc_resistances] will contain e.g. bludgeoning and [&WeaponDmg] will also. I'm pretty sure I am just not calling the procedure correctly but am out of guesses as to why.  Help?
1620768403

Edited 1620768421
David M.
Pro
API Scripter
Michael, what behavior are you seeing? Are you not making it into your DamageResist function (e.g. the conditional is not being met), or is it entering all the time? Interestingly, when I mock up a hardcoded scriptcard to test your conditional ->  if the npc_resistances attribute is blank, then it is still meeting the conditional criteria!  For some reason, it thinks that "" (empty string) includes "bludgeoning". Is this a bug or did I mess something up? As it is, it looks like it needs another check to ensure npc_resistances is not an empty string. !script {{ --#targetToken|@{target|token_id} --=AttackRoll|15 --=TargetAC|10 --&WeaponDmg|5 --&DamageType|bludgeoning --+DamageType|[&DamageType] --+npc_resistances|[*T:npc_resistances] --?[$AttackRoll.Total] -ge [$TargetAC.Total] -and [*T:npc_resistances] -inc [&DamageType]|>DamageResist;[&WeaponDmg] --X| --:DamageResist| --+Conditional met| value of npc_resistances includes DamageType (bludgeoning) --+Entered DamageResist procedure| with parameter value: [%1%] --<| }}
Is there a comment card available? I'd like to be able to document my script. thx much.
1620782948
David M.
Pro
API Scripter
I usually add comments with branch labels, e.g. --:SOME COMMENT|more details
1620807428
Duncan R.
Pro
Sheet Author
Also, way back in the thread when I ask a similar question Kurt said the following. New Convention : The "/" line type (--/) is being reserved for commenting out lines in scripts and will not be used as a statement identifier in the future. Line still need to follow the vertical bar rule, but you can change something like --+Hello|World! to --/+Hello|World and ScriptCards will ignore the line during processing.
thx much!
I'm using an old version of Scriptcards (1.0.9) but I do want to update to the latest. Will the cleanup and new features break the scriptcards I have? What should I be troubleshooting when I make the move?