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

ScriptCards - Input Query String-to-Roll-Variable Conversion

April 12 (4 years ago)

I do hope that I'm not missing something again, but I've gotten quite stuck and I need a bit of help.

Currently I'm trying to make a macro that I can input a number into via the q; input method without using the dropdown list, as I'd like to be able to use this macro as my pirate campaign scales upwards. In a nutshell, this macro will take that numeric input and then generate a number of Trade Good Crates as loot, using a 1d100 list I've made. I'm not getting past this user-input part as when I attempt to retrieve the number I can only access it as a String and not a Roll Variable, which would be required to make the for loop needed to do what I want. Here's what I've got so far:

--IClick Here to Enter the Number of Goods to Roll For:;Click Here|q;Quantity;Quantity

Currently this outputs the String Variable of whatever I put into the text box. I've tried the following as a means of conversion but it always yields 0:

--=Quantity|stateitem;read;[&Quantity]

My thought was to attempt to force the conversion with the Roll Variable assignment function but again it doesn't seem to work.

I know that I could just expand the Input Query like so, ad infinitum:

--IClick Here to Enter the Number of Goods to Roll For:;Click Here|q;Quantity;Quantity|1|2|3|4|5|6|7|8|9|10

But I would prefer to see the initial idea through to completion instead. Plus, I'd like to see about doing this with other things, like an AoE damage macro that doesn't require the spell to be centered on a token. I know that I could just make a dummy token for the user to target but I currently use large spell effect tokens, and it feels messy having to go back and forth between the two. 

April 12 (4 years ago)

Edited April 12 (4 years ago)
David M.
Pro
API Scripter

Looks like you are mixing up stateitems with Information (--I) commands. Once you have the string variable [&Quantity] from your information command button, you can just directly assign it to a roll variable:

!scriptcards {{
  --IClick Here to Enter the Number of Goods to Roll For:;Click Here|q;Quantity;Quantity
  --=roll|[&Quantity]
  --+roll|[$roll]
}}
April 12 (4 years ago)
Ah, thank you! Always love to see a simple solution!