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

[Help] Encountering an error when I try to get ScriptCards to call on SmartAoE

1669670121

Edited 1669670144
Hi! I'm trying to make a macro for Banishment that can place multiple SmartAoE tokens when the spell is upcast. Instead of having the player click the macro multiple times to produce several tokens in case they upcast, I wanted to use a branch within ScriptCards to determine how many SmartAoE tokens should be created - depending on spell level. I've tried running the called SmartAoE script on its own, and it works as intended. But when I call it from ScriptCards, it produces the error "SmartAoE: You must either select a token or pass the tokenID via --selectedID". In an attempt to fix the error and find something that works, I've tried replacing "@{selected|token_id}" within _selectedID| with [*S:token_id], [*S:character_id], the players token ID string, and  the players character ID string.  I've also tried putting all the commands within --@smartaoe on the same line, with a space between the end of each command and the start of the next one. None of them have solved the issue. Can anyone point out that I'm either doing something wrong, or if what I'm trying is even possible? Here's the source code: !scriptcards {{ +++dnd5elib+++ --/| Queries --/|Query Spell Slot --=Cast|?{Cast at what level?|4|5|6|7|8|9} --/|Lookup Spell Level --C[$Cast.Raw]|4:&Level;4th Level|5:&Level;5th Level|6:&Level;6th Level|7:&Level;7th Level|8:&Level;8th Level|9:&Level;9th Level --/|Lookup Mana Cost --C[$Cast.Raw]|4:=Mana;6|5:=Mana;7|6:=Mana;9|7:=Mana;10|8:=Mana;11|9:=Mana;13 --/|Number of Targets --C[$Cast.Raw]|4:=Targets;1|5:=Targets;2|6:=Targets;3|7:=Targets;4|8:=Targets;5|9:=Targets;6 --/| Spell name, title card design, and other necessary variables --#title|Banishment --#titlecardbackground|PlayerColor --#rightsub|The spell was cast at [&Level] --#sourceToken|@{selected|token_id} --#emoteState|hide --=Count|1 --/| Mana cost --/|@modbattr| _silent _charid CharacterID _other_resource|-[$Mana] !!! --/| Outcome | req. updates: damage die, damage mod --+|[j]You spent [$Mana] spell points on the spell.[/j] --+|[j]Charisma DC [*S:spell_save_dc] saving throw.[/j] --+|[j]You targeted [$Targets] creature(s).[/j] --:TargetLoop| -->TargetSelect| --=Count|[$Count] + 1 --?[$Count] -le [$Targets]|TargetLoop --X| --:TargetSelect| --@smartaoe| _title|Banishment _titlecardbackground|#555555 _oddrowbackground|#d0e4f5 _evenrowbackground|#eeeeee _selectedID|@{selected|token_id} _aoeColor|#55555575 _aoeOutlineColor|#00000000 _aoeType|square, float _radius|3ft _controlTokName|AoEControlToken _controlTokSize|1 _origin|nearest, face _minGridArea|0.55 _forceIntersection|0 _instant|1 _fx|burn-magic _dc|99 _saveFormula|5eCHA _conditionFail|5488146::Inspired _autoApply|yes --<| }} Thanks in advance! Jakob B. From
1669672322
timmaugh
Pro
API Scripter
Do you have SelectManager installed? What you're running into is the implementation of scripts-calling-scripts. The API -- Minor tangent... Roll20 wants to get away from "API", and offer "Mod Script" as a different usage... but API was used for more than just the scripts, themselves. It was also used to refer to the mod deck (installed scripts), the kind of messages sent to scripts (bangsy messages), and the general notion of the "system user of scripts". It's this last usage that you're dealing with. I'll call it the Moderator. Look, it's "Moderator" or "Aunt Mod". No? Ok, Moderator it is. =D Think of the Moderator as a player at your game if you have scripts enabled. The Moderator gets all of the bangsy messages. But if the Moderator, itself, sends a bangsy message, certain things are lost. The Moderator-as-player-at-the-table metaphor works except for the fact that there's no ability for the Moderator to interact with the VTT -- so there aren't any selected tokens. Also, the "who" and "playerid" properties of the message have been replaced, removing player-meaningful information and replacing with 'API'. (So much for getting away from 'API'). So your SmartAoE macro will work when you call it because you have selected tokens. When you have ScriptCards call the same SmartAoE command, however,  you're having the Moderator issue a message, and it has no selected tokens. SelectManager bridges that by tracking the tokens selected the last time you issued a command (the ScriptCards macro), and restoring them to the Moderator-initiated message (to SmartAoE) when that one comes around. Along with playerid and who, if you want them to be restored. You can, of course, feed selected token ids to the SmartAoE command line, as you mentioned, but SelectManager means you don't have to reconfigure the macro for various potential tokens... and it also comes the closest to standard "make it work based on what I have selected on the VTT" gameplay that you're used to.
I was not aware of those 'limitations' to the API, but it makes sense with your metaphor. Thanks for taking the time to explain it! Installing SelectManager did the trick, but now I'm getting a new error message that I've never seen before. It says "SmartAoE: When SmartAoE is called by another script, it must pass both the selected token ID and the playerID". I know how to get token and character IDs, but I have no clue how to find a player ID. A quick google search found a few lines of code by The Aaron, but they're 7 years old and don't seem to do the trick. Any idea how to find a playerID?
1669684119

Edited 1669684143
timmaugh
Pro
API Scripter
Now that you have SelectManager installed, run: !smconfig +playerid That will tell SelectManager to "restore" the playerid in addition to the selected tokens. (It's just a configuration setting, so you only have to do it once)
1669720872

Edited 1669720983
Kurt J.
Pro
API Scripter
Jakob F. said: I was not aware of those 'limitations' to the API, but it makes sense with your metaphor. Thanks for taking the time to explain it! Installing SelectManager did the trick, but now I'm getting a new error message that I've never seen before. It says "SmartAoE: When SmartAoE is called by another script, it must pass both the selected token ID and the playerID". I know how to get token and character IDs, but I have no clue how to find a player ID. A quick google search found a few lines of code by The Aaron, but they're 7 years old and don't seem to do the trick. Any idea how to find a playerID? When ScriptCards starts an execution, it creates several string variables (see the Wiki here ). Among these are [&SendingPlayerID] , which will have the ID of the player who triggered the execution, as well as an array called SC_SelectedTokens which will contain the token IDs of anything that was selected when the script ran. [@SC_SelectedTokens(0)] will contain the first selected token id, or will return "undefined array" if nothing was selected. You could use these variables to pass along information to SmartAOE. As a side note, [*S:token-id] will always return nothing, since this isn't the way to retrieve the token's ID. All [*...] constructs use the actual names of the object properties, and in the case of IDs, the names are just "id". Since "id" would be ambiguous as to referring to the character ID or the token ID, all token properties begin with t-, so [*S:t-id] retrieves the token ID while [*S:id] retrieves the character ID. The "t-" applies to all token properties, even if they don't have name clashes with character properties to make it clear that you are referencing a token property.
1669725886
David M.
Pro
API Scripter
The following seems to work for me. Uses the SelectManager mod, changes your direct SmartAoE call to a forselected call, and also removes the --selectedID keyword. Finally, your custom statusmarker seems to be addressed in the wrong order (it should be name::number and you have it reversed) --@forselected|smartaoe _title|Banishment _titlecardbackground|#555555 _oddrowbackground|#d0e4f5 _evenrowbackground|#eeeeee _aoeColor|#55555575 _aoeOutlineColor|#00000000 _aoeType|square, float _radius|3ft _controlTokName|AoEControlToken _controlTokSize|1 _origin|nearest, face _minGridArea|0.55 _forceIntersection|0 _instant|1 _fx|burn-magic _noSave|1 _saveFormula|5eCHA _conditionFail|Inspired::5488146 _autoApply|yes The error message you were getting is because of the presence of the --selectedID command without a corresponding playerID. That was put in there in case someone wanted to fire off SmartAoE from within another script (where you could easily get the playerID from the object model).  Scriptcards is a different situation, and SelectManager plays nicely with it. So try the following after installing SelectManager. !scriptcards {{ +++dnd5elib+++ --/| Queries --/|Query Spell Slot --=Cast|?{Cast at what level?|4|5|6|7|8|9} --/|Lookup Spell Level --C[$Cast.Raw]|4:&Level;4th Level|5:&Level;5th Level|6:&Level;6th Level|7:&Level;7th Level|8:&Level;8th Level|9:&Level;9th Level --/|Lookup Mana Cost --C[$Cast.Raw]|4:=Mana;6|5:=Mana;7|6:=Mana;9|7:=Mana;10|8:=Mana;11|9:=Mana;13 --/|Number of Targets --C[$Cast.Raw]|4:=Targets;1|5:=Targets;2|6:=Targets;3|7:=Targets;4|8:=Targets;5|9:=Targets;6 --/| Spell name, title card design, and other necessary variables --#title|Banishment --#titlecardbackground|PlayerColor --#rightsub|The spell was cast at [&Level] --#sourceToken|@{selected|token_id} --#emoteState|hide --=Count|1 --/| Mana cost --/|@modbattr| _silent _charid CharacterID _other_resource|-[$Mana] !!! --/| Outcome | req. updates: damage die, damage mod --+|[j]You spent [$Mana] spell points on the spell.[/j] --+|[j]Charisma DC [*S:spell_save_dc] saving throw.[/j] --+|[j]You targeted [$Targets] creature(s).[/j] --:TargetLoop| -->TargetSelect| --=Count|[$Count] + 1 --?[$Count] -le [$Targets]|TargetLoop --X| --:TargetSelect| --@forselected|smartaoe _title|Banishment _titlecardbackground|#555555 _oddrowbackground|#d0e4f5 _evenrowbackground|#eeeeee _aoeColor|#55555575 _aoeOutlineColor|#00000000 _aoeType|square, float _radius|3ft _controlTokName|AoEControlToken _controlTokSize|1 _origin|nearest, face _minGridArea|0.55 _forceIntersection|0 _instant|1 _fx|burn-magic _noSave|1 _saveFormula|5eCHA _conditionFail|Concentration::1510097 _autoApply|yes --<| }}
Sorry for the slow reply. Had a 38 hour day yesterday, so by the time I was able to sit down and look at the thread I was far too tired to understand any of what was written by you guys. I've run the config line so SelectManager is fully set up. Thanks timmaugh! I feel like I'm beginning to get a solid novice level grasp of how the scripts work, but there's definitely more to learn on that front. I've gone back through previous macros where I've used either [*S:token_id] or [*S:character_id] and updated them to the correct properties. Thanks for pointing it out and teaching me about the backend of scripting Kurt J! The forselected call did the trick and makes everything run smoothly! I also fixed my statusmarker ordering as you so diligently noticed. Thanks for getting me over the finish line David M!