We use Cookies to help personalize and improve Roll20. For more information on our use of non-essential Cookies, visit our Privacy Policy here.
Accept
Advertisement Create a free account

[Help] Workaround for selecting a row number with a query

I'm trying to find an easy way to use one macro that lets me select the row number storing a given feature, rather than having one macro for each item. At first I was going to try this !setattr {{ --sel --replace --repeating_gear_-create_name|@{compendium|repeating_gear_$?{Row Number}_name} --repeating_gear_-create_quantity|@{compendium|repeating_gear_$?{Row Number}_quantity} --repeating_gear_-create_weight|@{compendium|repeating_gear_$?{Row Number}_weight} --repeating_gear_-create_cost|@{compendium|repeating_gear_$?{Row Number}_cost} --repeating_gear_-create_slot|@{compendium|repeating_gear_$?{Row Number}_slot} --repeating_gear_-create_special|@{compendium|repeating_gear_$?{Row Number}_special} --repeating_gear_-create_notes|@{compendium|repeating_gear_$?{Row Number}_notes} }} but I remembered that attributes are parsed before queries. It ends up giving me this ...ETC. Is there a way to specify the attribute in a way that let's the query be parsed first? Or a different place to have the query in a way that would have a similar function? The only idea I've had to workaround would be using a drop-down queries, but that would mean not only having several different queries in the same macro, but also having to update all of them any time I add an item to my compendium sheet. Thanks in advance :)
1579039444
GiGs
Pro
Sheet Author
API Scripter
The only way I know of doing this is by using an intermediate custom-built API script. You have a script that you supply values to, and it constructs the chatsetattr string, and outputs that to chat. Such a script would be pretty simple to build. But it would be better to talk through exactly what youre trying to do - since once you start using a script for part of the job, it might be better to dispense with chatsetattr altogether, and do everything in the custom script.
1579043828

Edited 1579045732
Originally I was going to try to make a custom script. The idea was that I would be able to put a table like the following in the GM Notes of an item or feat handout. The GIVE ITEM link would send an API command that, while a token is selected, would pull the info from the table and make a new item in the specified repeating section, filling the fields named in the left column with the text given in the right column. The API command in the link would need to be manually entered as well with the handout's ID. Then keithcurtis pointed out to me that ChatSetAttr can create and fill repeating rows already. This sounded much more simple than what I had planned, but I wanted to avoid having to make a unique macro for each item. So I got the idea to store the custom items in the appropriate repeating sections in a character sheet. I'd call the sheet 'compendium' and have a handful of macros with a command like the one in my initial post—one for feats, one for spells, one for magic items, etc. Ideally the macro would ask what row number the item is stored in, and then use that to determine the attributes to find from the compendium character sheet, parse through the command, and add to the selected character's sheet.
1579105949

Edited 1579106018
I think I've solved it! Short example, in case anyone finds this useful: !setattr {{ --name compendium --replace --repeating_gear_$0_name|`{compendium\|repeating_gear_$?{Row Number}_name} }} Queries the row number, then stores the repeating row I specified as the name for row 0. Could also be stored in a custom attribute, if you find that easier !setattr {{ --sel --replace --repeating_gear_-create_name|@{compendium|repeating_gear_$0_name} }} Pulls the row 0 name, which has been converted to the call for the row name I want. Gonna try using the Delay script next to see if I can combine these into one macro!