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] [ScriptCards] Having queries in branches to the user

Hi, I've been working on a macro for one of my players who just picked up Bigby's Hand (D&amp;D 5e), but I've run into a bit of a nuisance with queries that I hope someone can help me with. I initially wanted to make a one-button macro to handle all of the four attack types that Bigby's Hand can make, so the player doesn't need to have multiple buttons for the one spell. After writing it out, I realized that when I run it, all "?{}"&nbsp; queries &nbsp;from every branch &nbsp;spams the player. I looked into using "--i", but don't want the players chat to get filled with buttons that they need to click to finish the ability. I tried messing around with "--i" to skip the button step, but couldn't find a way to do it. After giving up on that idea, I tried using "--^" to skip the irrelevant code. My attempt looked like this: --/| Queries --/|Query Type --=Type|?{Attack effect?|Clenched Fist,1|Forceful Hand,2|Grasping Hand,3|Interposing Hand,4} --/|Lookup Attack Name --C[$Type.Raw]|1:&amp;AttackName;Clenched Fist|2:&amp;AttackName;Forceful Hand|3:&amp;AttackName;Grasping Hand|4:&amp;AttackName;Interposing Hand --/| Outcome --?[$Type.Total] -eq 1|SkipToClenched --?[$Type.Total] -eq 2|SkipToForceful --?[$Type.Total] -eq 3|SkipToGrasping --?[$Type.Total] -eq 4|SkipToInterposing --X| --:SkipToClenched| --^Clenched| --:SkipToForceful| --^Forceful| --:SkipToGrasping| --^Grasping| --:SkipToInterposing| --^Interposing| I figured that it'd check which attack was chosen, then it'd entirely skip the code with the irrelevant queries, but alas, it seems the queries are generated on the "stack" (so to speak) as soon as the macro is run. I must admit that at this point I've entirely run out of solutions, and I hope someone here can point me in the right direction or, if not that, at least confirm that it isn't possible.&nbsp;&nbsp; Current code below: !scriptcards {{ +++dnd5elib+++ --/| Queries --/|Query Type --=Type|?{Attack effect?|Clenched Fist,1|Forceful Hand,2|Grasping Hand,3|Interposing Hand,4} --/|Lookup Attack Name --C[$Type.Raw]|1:&amp;AttackName;Clenched Fist|2:&amp;AttackName;Forceful Hand|3:&amp;AttackName;Grasping Hand|4:&amp;AttackName;Interposing Hand --/| Design and necessary variables --#title|[&amp;AttackName] --#titlecardbackground|#6aa84f --#rightsub|@{target|token_name} was targeted by Bigby's Hand --#oddrowbackground|#1c211b --#oddrowfontcolor|#ffffff --#evenrowbackground|#353535 --#evenrowfontcolor|#ffffff --#tableshadow|0px 0px 0px 0px #aaa; --#tableborder|1px solid #000000; --#tableborderradius|0px --#sourceToken|-Mw-2yNlJIP__ulp8uwd --#targetToken|@{target|token_id} --#emoteState|hide --=TargetAC|@{target|npc_ac} --?[$TargetAC.Total] -gt 0|DoneWithAC --=TargetAC|@{target|ac} --:DoneWithAC| --/| Outcome --?[$Type.Total] -eq 1|SkipToClenched --?[$Type.Total] -eq 2|SkipToForceful --?[$Type.Total] -eq 3|SkipToGrasping --?[$Type.Total] -eq 4|SkipToInterposing --X| --:SkipToClenched| --^Clenched| --:SkipToForceful| --^Forceful| --:SkipToGrasping| --^Grasping| --:SkipToInterposing| --^Interposing| --:Clenched| --=Atk|?{Advantage/Disadvantage|Normal,1d20|Advantage,2d20kh1|Disadvantage,2d20kl1} + [*S:spell_attack_bonus] --&gt;Lib5E_CheckDamageModifiers|ResistType;force --+|You rolled a [$Atk.Total] to hit. --?[$Atk.Base] -ge 20|Crit --?[$Atk.Total] -ge [$TargetAC.Total]|Hit --?[$Atk.Total] -lt [$TargetAC]|Miss --X| --:Crit| --=Dmg|4d8 [&amp;ResistType] --=Crit|1d4 + 1 --+|You dealt [$Dmg] force damage! --+|You rolled [$Crit] on the Critical Die, click [Critical Hit Table](<a href="http://journal.roll20.net/handout/-MvR3Qq1blWaYvV6m_iL" rel="nofollow">http://journal.roll20.net/handout/-MvR3Qq1blWaYvV6m_iL</a>) to see your options. --@token-mod| _ids @{target|token_id} _set bar3_value|-[$Dmg] --X| --:Hit| --=Dmg|4d8 [&amp;ResistType] --+|You dealt [$Dmg] force damage. --@token-mod| _ids @{target|token_id} _set bar3_value|-[$Dmg] --X| --:Miss| --+|Your attack missed. --X| --:Forceful| --=ForcefulHandCheck|?{Is the target Medium or smaller?|Yes,2d20kh1|No,1d20} + 8 --=Mod|[*S:spell_attack_bonus] - [*S:pb] --=Distance|[$Mod] * 5 + 5 --+|You rolled [$ForcefulHandCheck] on the hand's Athletics check. --+|If you succeed on the contest, you can push @{target|token_name} up to [$Distance] ft. --=TargetCheck|1d20 + [*T:athletics_bonus] --*|The target rolled [$TargetCheck] for Athletics. --X| --:Grasping| --=GraspingEffect|?{Is the target already grappled by the hand?|Yes,1|No,2} --&gt;Lib5E_CheckDamageModifiers|ResistType;mbludgeoning --?[$GraspingEffect.Total] -eq 1|GraspingCrush --?[$GraspingEffect.Total] -eq 2|GraspingGrapple --X| --:GraspingCrush| --=Mod|[*S:spell_attack_bonus] - [*S:pb] --=Dmg|2d6 + [$Mod] [&amp;ResistType] --+|You dealt [$Dmg] bludgeoning damage. --@token-mod| _ids @{target|token_id} _set bar3_value|-[$Dmg] --X| --:GraspingGrapple| --=GraspingHandCheck|?{Is the target Medium or smaller?|Yes,2d20kh1|No,1d20} + 8 --+|You rolled [$GraspingHandCheck] on the hand's Athletics check. --+|If you succeed on the contest, you grapple @{target|token_name}. --=TargetStrengthAttribute|[*T:strength_mod] --=TargetDexterityAttribute|[*T:dexterity_mod] --?[$TargetStrengthAttribute.Total] -ge [$TargetDexterityAttribute]|TargetAthletics --?[$TargetDexterityAttribute.Total] -gt [$TargetStrengthAttribute]|TargetAcrobatics --X| --:TargetAthletics| --=TargetCheck|1d20 + [*T:athletics_bonus] --*|The target rolled [$TargetCheck] for Athletics. --X| --:TargetAcrobatics| --=TargetCheck|1d20 + [*T:acrobatics_bonus] --*|The target rolled [$TargetCheck] for Acrobatics. --X| --:Interposing| --+|The hand interposes itself between you and the target until you the hand a different command. The hand moves to stay between you and the target, providing you with half cover against the target. The target can't move through the hand's space unless it's strength score is 27 or higher. If it is, the hand's space is difficult terrain for the target. --X| }} Thanks in advance, - Jakob "Wheatley" From
1683164909
Andrew R.
Pro
Sheet Author
The “?{}” queries are run before ScriptCards even sees the script. That’s why they are always asked no matter what. If you want input from the user to change based on control flow you must use the “—i” command.&nbsp;
That's what I was afraid of. Do you know any way that prompts the queries from "--i" without the need to click the button in the chat? I'm essentially looking for a way that will, for all intents and purposes, make it seem like "?{}" to the player.
1683179251

Edited 1683179589
There is a trick to making it work.&nbsp; You have to kind of fool Roll20 into not generating the Query until you want it to.&nbsp; Look at my bless spell and see how I build a target list as part of executing a [rbutton] call.&nbsp; It's the BUILD_TARGETS function.&nbsp; I build the query and bury it in a variable called BlessTargets, which doesn't show itself to Roll20 until you make the reentry call to actually select targets. Will !script {{ --/|Script Name : Bless --/|Version : 0.1 --/|Requires SC : --/|Author : Will M. --/|Description : Implements Bless on 3+ targets --/| --/|Spell Description: You bless up to three creatures of your choice within range. --/| Whenever a target makes an attack roll or a saving throw before --/| the spell ends, the target can roll a d4 and add the number rolled --/| to the attack roll or saving throw. --/| At Higher Levels. When you cast this spell using a spell slot of --/| 2nd level or higher, you can target one additional creature for each --/| slot level above 1st. --/| Select each character impacted --/| For each character impacted - Update their Global Attack and Save Mods --/| Add a status marker to show the effect --/| Send a message to that person to let them know they are blessed --/| Add a turnorder counter --/| Add a Concentration Marker --:TOP| --#title|BLESS --#timezone|America/Chicago --#overridetemplate|dnd5e --#sourceToken|@{selected|token_id} --#whisper|self --#debug|1 --#emoteText|@{selected|token_name} Casts Bless --&gt;SETUP_GLOBAL_VARS| --&amp;BlessedSM|Blessed::4082922 --&amp;ConcentrationSM|Concentrating::4082926 --+Bless Description:| --+| [b][i]Casting Time:[/i][/b] 1 Action --+| [b][i]Duration:[/i][/b] 1 Minute --+| [b][i]Range:[/i][/b] 30 ft. --+| [b][i]Components:[/i][/b] V, S, M (holy water) --+|You bless up to [b]three creatures[/b] of your choice within range. Whenever a target makes an [b][i]attack roll[/i][/b] or a [b][i]saving throw[/i][/b] before the spell ends, the target can roll a [b]d4[/b] and add the number rolled to the attack roll or saving throw. --+|[b]At Higher Levels.[/b] When you cast this spell using a spell slot of 2nd level or higher, you can target one additional creature for each slot level above 1st. --+|[hr] --/| Get Slot Level and Check for space --&gt;GET_SPELL_SLOT|SlotLevel --&gt;BUILD_TARGETS|[&amp;SlotLevel];BlessTargets --=TargetCount|[&amp;SlotLevel]+2 --+|[c][rbutton]Select [$TargetCount.Raw] Characters to Bless::BLESS;[&amp;SlotLevel]\[&amp;BlessTargets][/rbutton][/c] --:EXIT| --x| --:GET_SPELL_SLOT| --/| Select Level to determine number of creatures impacted --&amp;SL|?{Spell Slot Level Used?|1|2|3|4|5|6|7|8|9} --=SlotsExpended|[*S:lvl[&amp;SL]_slots_expended] --&amp;[%1%]|[&amp;SL] --?[$SlotsExpended.Total] -eq 0|NOSLOTSLEFT --&gt;DEDUCT_SPELL_SLOT| --&lt;| --:NOSLOTSLEFT| --&amp;[%1%]|0 --+|[*S:character_name] has no level [&amp;SL] spell slots available. --#emoteText|[*S:character_name] tries to cast a spell but farts in instead. --X|NoSlotsLeftStop --:DEDUCT_SPELL_SLOT| --=SlotsExpended|[*S:lvl[&amp;SL]_slots_expended] - 1 --/@setattr|_charid [*S:character_id] _lvl[$SlotLevel]_slots_expended|[$SlotsExpended] _silent --!a:[*S:character_id]|lvl[&amp;SL]_slots_expended:[$SlotsExpended] --+|Level [&amp;SL] Slots Left: [$SlotsExpended] --&lt;| --:BLESS| --#whisper| --~Arg|string;split;\;[&amp;reentryval] --=iCnt|[&amp;Arg1]+3 --%i|2;[$iCnt.Raw];1 --&amp;TokenId|[&amp;Arg[&amp;i]] --&amp;TokenIds|+ [&amp;Arg[&amp;i]] --&amp;CharIds|+ [*[&amp;TokenId]:character_id] --?[&amp;i] -ne [$iCnt.Raw]|&amp;CharIds;+, --+|[b][c][*[&amp;TokenId]:t-name][/c][/b] --&amp;Blessed|+ [*[&amp;TokenId]:t-name], --vtoken|[&amp;TokenId] nova-holy --&gt;TURN_GSM_ON|[*[&amp;TokenId]:character_id];Bless --&gt;TURN_GAM_ON|[*[&amp;TokenId]:character_id];Bless --%| --+|[b][i][c]Have been Blessed[/c][/i][/b] --@token-mod|_set statusmarkers|[&amp;BlessedSM] _ids [&amp;TokenIds] _ignore-selected --@token-mod|_set statusmarkers|[&amp;ConcentrationSM] _ids [*S:t-id] _ignore-selected --~|turnorder;addcustom;&gt;&gt;[*S:t-name] Concentrating;1;+1 --e[*S:t-name]|/em Is Concentrating --&gt;LOG|Concentration Started; [*S:t-name] (For casting Bless on [&amp;Blessed]) --+|[hr] --+For the next minute, or until the spell ends:| --+| Whenever a you make an [b][i]attack roll[/i][/b] or a [b][i]saving throw[/i][/b], the you can roll a [b]d4[/b] and add the number rolled to the attack roll or saving throw. --+Note:|[i]You'll need to manually uncheck the [b]Global Attack[/b] and [b]Global Save[/b] Modifiers for [b]Bless[/b] from your character sheet or the Actions macro[/i] --X| --:BUILD_TARGETS|Count;rtnTargetString --=iCnt|[%1%]+2 --=i|0 --&amp;TS| --/*iCnt|[$iCnt] --%i|1;[$iCnt.raw];1 --&amp;TS|+[&amp;TB]target|[&amp;i]|token_id} --?[&amp;i] -lt [$iCnt.Raw]|&amp;TS;+\ --/*[&amp;i]|[&amp;TS] --%| --&amp;[%2%]|[&amp;TS] --&lt;| --:TURN_GSM_ON|CharacterId, GSM Name --Rfind|[%1%];[%2%];repeating_savemod;global_save_name --?"[*R:global_save_name]" -eq "NoRepeatingAttributeLoaded"|EXIT_GSM --!a:[%1%]|[*R&gt;global_save_active_flag]:1 --:EXIT_GSM| --&lt;| --:TURN_GAM_ON|CharacterId, GAM Name --Rfind|[%1%];[%2%];repeating_tohitmod;global_attack_name --/rdump| --/\GAM1|GAM1 [*[%1%]:name] [*R:global_attack_name] --/\GAM2|[%1%] [*R:global_attack_name] [*R:global_attack_roll] [*R:global_attack_active_flag] [*R&gt;global_attack_active_flag] --?"[*R:global_attack_name]" -eq "NoRepeatingAttributeLoaded"|EXIT_GAM --!a:[%1%]|[*R&gt;global_attack_active_flag]:1 --:EXIT_GAM| --&lt;| --:LOG|Subject, Note --~DT|system;date;getdatetime --@note-log|[&amp;DT]: [%1%]; [%2%] --&lt;| --:SETUP_GLOBAL_VARS| --&amp;QB|? --&amp;QB|+{ --&amp;QE|} --&amp;AB|@ --&amp;AB|+{ --&amp;TB|&amp; --&amp;TB|+# --&amp;TB|+64 --&amp;TB|+; --&amp;TB|+{ --&amp;BED|&amp; --&amp;BED|+# --&amp;BED|+128719; --&amp;CLOCK|&amp; --&amp;CLOCK|+# --&amp;CLOCK|+128336; --&amp;SPACE|X X --&amp;SPACE|[&amp;SPACE(1,1)] --&amp;spc|&amp;nbsp; --&amp;obrac|[ --&amp;cbrac|] --&amp;vbar|| --&amp;DASH|- --&amp;DDASH|[&amp;DASH][&amp;DASH] --&lt;| }}
1683179607
Andrew R.
Pro
Sheet Author
Jakob F. said: Do you know any way that prompts the queries from "--i" without the need to click the button in the chat?&nbsp; I don't think there is. You could ask in the main ScriptCards thread, where it has been explained IIRC&nbsp;
Andrew R. said: Jakob F. said: Do you know any way that prompts the queries from "--i" without the need to click the button in the chat?&nbsp; I don't think there is. You could ask in the main ScriptCards thread, where it has been explained IIRC&nbsp; You can't, its a limitation of Roll20.&nbsp; However - check the Bless code I posted above.&nbsp; It demonstrates a method for achieving what you are wanting to do.&nbsp;&nbsp;
1683201921
David M.
Pro
API Scripter
A similar approach to Will's above would be&nbsp; creating a reentrant scriptcard chat menu with rbuttons, each representing the different Bigby effects. Build the query strings and pass them into the rbutton as parameters so the query doesn't run until that particular rbutton is clicked (and only the relevant query will fire). Example snippet for the grasping effect (air coding, untested). Note: y ou might need other parameters like target string, etc. depending on how you want to set it up. &nbsp; --&amp;QB|? --&amp;QB|+{ --&amp;QE|} &nbsp; --&amp;graspQuery| [&amp;QB] Is the target already grappled by the hand?|Yes,1|No,2 [&amp;QE] &nbsp; --+|[rbutton]Grasp::GraspAttack;[&amp; graspQuery ][/rbutton] Build the other queries as needed and print all the rbuttons on a single line.&nbsp; Then parse the reentrant parameters as normal.
Thanks for the help guys! Greatly appreciate it.