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 I make a macro select a repeating item from query?

1686384966

Edited 1686386246
Cereal Nommer
Pro
Sheet Author
@{selected|repeating_inventory_$?{Item Number|1}_itemname} ^ I tried this, but it throws errors and seems to misunderstand the query. @{selected|repeating_inventory_$?{Item Number|1}_itemname} ^ If I copy the results and paste them into the chat it gives me what I want. I'm attempting to make an output a little more complex, but if I can get this part sorted out the rest falls into place. I'm attempting to make an output a little more complex, but if I can get this part sorted out the rest falls into place. Is there any way to escape things so I can just input the item index in a query and get back the item's name? Update: Attempted the Prefix Trick to no avail. @{prefix}selected|repeating_inventory_$?{Item Number|1}_itemname} //where @{prefix} = @{ //output seems identical to first attempt. Update 2: Found workaround: /w Cereal [Post to Chat](`@{selected|repeating_inventory_$?{Item Number|1}_itemname}) // Put your own name in to avoid cluttering up chat for gm. If there's a better way to do this, please advise.
Use case: /w Cereal %NEWLINE%***[Post Item ?{Item Number|1} to Chat](`?{To whom...|/w gm}&{template:npcaction} {{name=Notes}} {{rname=@{selected|repeating_inventory_$?{Item Number|1}_itemname}}} {{description=@{selected|repeating_inventory_$?{Item Number|1}_itemcontent}}})***%NEWLINE%%NEWLINE%1 =  List of Various Requests%NEWLINE%2 = Ledger of Credits and Debits%NEWLINE%3 = Q&A session notes%NEWLINE%6 = Gate Notes%NEWLINE%7 = Location Notes%NEWLINE%24 = My Spellbook As the party note taker, you can keep notes on parchment or books in your inventory and display the contents of an individual item to the gm or another party member, or the whole group by leaving "To whom..." blank, in a convenient chat message. Or show someone your spellbook, magic item, etc... if you maintain good descriptions in your inventory. Use the reminder text at the end to keep track of item indices.
1686392209
GiGs
Pro
Sheet Author
API Scripter
Your workaround (assuming it works) is the best way to do this. The Roll20 order of operations makes constructing attribute calls from their parts impossible without some variation of the prefix trick.
Unfortunately you won’t be able to create a query that has an attribute inside of it, because all attribute calls are processed before  queries. So once Roll20 processes the query to get the repeating number, it doesn’t go back to check if the result of the query is a valid attribute that should then get called.  Your approach to create a clickable button is the only way to do this that I’m aware of.  Is being able to show the information from an item in inventory something that you use often? It should be possible to include that on my  D&D 5E Macro Mule  if that’s something you’re interested in. Possibly either as a clickable link from the inventory list, or as a tooltip that you can hover over. 
1686439552
timmaugh
Forum Champion
API Scripter
If scripts are available, Fetch can do this. If you need to output the result to chat, you'd likely also need ZeroFrame. For instance: !The name of ?{Item Number|1} is *(selected.inventory.$?{Item Number}.itemname){&simple}