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

[Request] update ability macros to include the id's of repeating rows

1450630900

Edited 1450631198
vÍnce
Pro
Sheet Author
Is it possible write a script that can review a sheet's ability macros to learn the id's of repeating items and rewrite the macro substituting their appropriate id? Problem: Currently, many sheets have ability macros that use the old repeating row naming schema "repeating_foo_X_..."  where X is the row number.  This will no longer work since the new naming schema requires including " $ " in front of the row number or use the row's id.  The " $ " still seems "generic" in nature and with the Devs eluding to the ability to re-order/arrange repeating rows in the future wouldn't it be better to use a rows id?
1450634627
Lithl
Pro
Sheet Author
API Scripter
If you're worried about future-proof against re-ordering repeating items, I think you're out of luck. I'm fairly confident that findObjs will return things in the order they were created.
1450667667
The Aaron
Pro
API Scripter
I think Vince is talking about the Repeating Row ID, not the Attribute ID. So, something that could work is adding a hidden field to the Repeating Row named index, then using sheet workers to fill in the row number.  Based on my testing, the getSectionIDs() function returns the rows in the correct order.  You could then find all of the repeating attributes named index and use them to create a map between Row ID and Row Index, then grab all the repeating attributes, build a map form repeating_<foo>_<index>_<bar> to repeating_<foo>_<id>_<bar>, then do a string replace in each of the macro and ability action properties. Honestly, it wouldn't be too hard with that hidden index field.
1450676716
chris b.
Pro
Sheet Author
API Scripter
sheetworkers can't see ability macros, correct? only attributes? if that is true: we might have to use the API to rewrite the ability macros.  At least it finally looks like we can select fields out of repeating sections, for some reason it was not working for us before. We can add hidden fields to the repeating sections, as Aaron suggests, and store the row ID in there, that way the API can easily access the id of a row to generate a string to search and replace in macros. Which may be easier for people with hundreds of monsters to update. The hidden field could be called @{Row_ID} or something, and the sheetworker could update it on creation of a new row. in the sheet:opened event on an old sheet it would just loop through all the repeating sections and set those hidden fields.
1450682004
The Aaron
Pro
API Scripter
Actually, what you'd need to store is the row index number (1,2,3,...). The API can see the row IDs in the names of the repeating attributes, but it doesn't know which one is which by index. 
1450698010
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Brian said: If you're worried about future-proof against re-ordering repeating items, I think you're out of luck. I'm fairly confident that findObjs will return things in the order they were created. (Side topic:  Then the first player found by findObjs would always be the campaign creator.... just saying. Always thought that would be useful i.e. a "permission" system.)