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

Can you use a ? prompt as part of a attribute

I have spell slots named attr_spell_slots_l1, attr_spell_slots_l2, .... thru 9    Is there away to use the ? prompt for the cast level to create an attribute? {{spellLvl=?{Level?|1,1|2,2|3,3|4,4|5,5|6,6|7,7|8,8|9,9}}} {{@{spell_slots_l?{Level?}}}}  so i can access the attribute based on the prompt level the user selected.
1630064715

Edited 1630064761
GiGs
Pro
Sheet Author
API Scripter
No, this is not possible, due to roll20's order of operations. All attribute values are grabbed before prompts are processed, so that is looking for an attribute literally named spell_slots_l?{Level?} which obviously does not exist. The only way to do this via macro is to include more in the query, which in principle would look like {{spellLvl=?{Level?| 1,1}} {{@{spell_slots_1}| 2,2}} {{@{spell_slots_2}| 3,3}} {{@{spell_slots_3} }}&nbsp; I only did the first 3 to save typing. Notice how you can enter a linebreak after a | for easier reading. Unfortunately, then you have a new problem: roll20 queries see any } that aren't part of attribute calls as an instruction to end the query. The ones here for example in bold: 1,1 }} {{@{spell_slots_1}| To solve that you need to use HTML entities, which can be used to represent a character. To replace } you use &amp;#125; So the above code becomes: {{spellLvl=?{Level?| 1,1 &amp;#125; &amp;#125; {{@{spell_slots_1}| 2,2 &amp;#125; &amp;#125; {{@{spell_slots_2}| 3, 3&amp;#125; &amp;#125; {{@{spell_slots_3} }}&nbsp; You can read more about this here: <a href="https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries" rel="nofollow">https://wiki.roll20.net/Macros#Advanced_Usage_for_Roll_Queries</a> Note: Roll20 is testing code that will eliminate the need for HTML entities in these situations - that's something to look forward to.
1630065578
David M.
Pro
API Scripter
GiGs said: Note: Roll20 is testing code that will eliminate the need for HTML entities in these situations - that's something to look forward to.
1630068020
Andreas J.
Forum Champion
Sheet Author
Translator
No, this is not possible, due to roll20's order of operations. And here is about that: <a href="https://wiki.roll20.net/Order_of_Operations" rel="nofollow">https://wiki.roll20.net/Order_of_Operations</a>
1630076982

Edited 1630077009
timmaugh
Pro
API Scripter
Rouse said: I have spell slots named attr_spell_slots_l1, attr_spell_slots_l2, .... thru 9&nbsp;&nbsp;&nbsp; Is there away to use the ? prompt for the cast level to create an attribute? {{spellLvl=?{Level?|1,1|2,2|3,3|4,4|5,5|6,6|7,7|8,8|9,9}}} {{@{spell_slots_l?{Level?}}}}&nbsp; so i can access the attribute based on the prompt level the user selected. This is where Fetch comes in handy. Because it happens after all Roll20 parsing but *before* the destination script's command line, you can use a roll query in its construction: {{spellLvl=?{Level?|1,1|2,2|3,3|4,4|5,5|6,6|7,7|8,8|9,9}}} {{@(&lt;character name&gt;.spell_slots_l?{Level?})}} (Replace&nbsp; &lt;character name&gt; &nbsp;with the name of the character in question.) Note, if you are using this (as you apparently are) in a message NOT intended for the api (you look to be using a roll template), you want to have ZeroFrame installed, too, and start/end the whole thing like this: ! ... {&amp;simple} Where the ellipsis is where the roll template with Fetch construction would go. The above starts out the message as an API call, to let the metascripts do their thing, then releases it as a normal chat message so you see the output. So, an example with the default template: !&amp;{template:default}{{spellLvl=?{Level?|1,1|2,2|3,3|4,4|5,5|6,6|7,7|8,8|9,9}}} {{@(&lt;character name&gt;.spell_slots_l?{Level?})}}{&amp;simple} Required Scripts: Fetch , ZeroFrame
Thanks guys!&nbsp; I didnt think so but it was 3am and my brain was about out of it lol.&nbsp; timmaugh said: This is where Fetch comes in handy. Because it happens after all Roll20 parsing but *before* the destination script's command line, you can use a roll query in its construction: {{spellLvl=?{Level?|1,1|2,2|3,3|4,4|5,5|6,6|7,7|8,8|9,9}}} {{@(&lt;character name&gt;.spell_slots_l?{Level?})}} (Replace&nbsp; &lt;character name&gt; &nbsp;with the name of the character in question.) Note, if you are using this (as you apparently are) in a message NOT intended for the api (you look to be using a roll template), you want to have ZeroFrame installed, too, and start/end the whole thing like this: ! ... {&amp;simple} Where the ellipsis is where the roll template with Fetch construction would go. The above starts out the message as an API call, to let the metascripts do their thing, then releases it as a normal chat message so you see the output. So, an example with the default template: !&amp;{template:default}{{spellLvl=?{Level?|1,1|2,2|3,3|4,4|5,5|6,6|7,7|8,8|9,9}}} {{@(&lt;character name&gt;.spell_slots_l?{Level?})}}{&amp;simple} Required Scripts: Fetch , ZeroFrame I will check this out thanks!