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

Macro/API to copy from repeating section to main section

I want to create a repeating section of weapons that includes two macro buttons (each repeat) to copy its attributes to either to weapon one or weapon two on the main page (similar with armour and ammo) so they can be swapped out easily. I would appreciate some guidance if this is at all possible?
This seems likely with the API, but if you can provide some additional details such as the character sheet used and maybe some screenshots of the different sections, it would help (me at least) understand what you want to do.
1507814023
The Aaron
Pro
API Scripter
It can probably be handled with Sheet Workers.  The buttons would effectively be toggles, when the toggle changes, you'd grab all the fields in the same row and update the attributes for the "main section" appropriately.
1507815859
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
As Aaron said, certainly doable, but why do you want this functionality? It seems like it's unnecessary attribute bloat.
1507816283
The Aaron
Pro
API Scripter
In the case of an equip left and right hand, I could see this being useful.
1507817308
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, I suppose that would be a decent way to handle TWF.
I will post some screen shots tonight but some of the reasons are 1) the characters will likely have access to armouries allowing them to swap out weapons relitavely easily. 2) as said by others Dual weilding 3) for social interactions knowing if the crew have left their ship loaded for discression or intimidation. (They can indicate they are carrying more but it gives a quick indication) 4) Allowing just a few items on the main tab. 5) for armour swapping out all 10 fields at once so hit loacations and damage reduction can be handled by better automation. (Again reinforced coat vs powered combat armour)
This Tab I want to copy a selected item to this one... there is obviously more formatting and layout to do yet (and correctly labelling buttons etc.)
1507891456
Jakob
Sheet Author
API Scripter
This can certainly be done with sheet workers, as The Aaron suggests. The important part here is to make the "buttons" for copying things effectively checkboxes that you change to look like buttons via CSS. So if you have a checkbox in the repeating ranged weapon section such as <input type="checkbox" name="attr_copy_to_1" class="sheet-fake-button"> you can then grab all the attributes from the row on the corresponding change event and write them into the non-repeating attributes for page 1. on('change:repeating_rangedweapon:copy_to_1', function () { getAttrs(['repeating_rangedweapon_damage', 'repeating_rangedweapon_range' /* and so on */], values => { setAttrs({ rangedweapon1_damage: v.repeating_rangedweapon_damage, rangedweapon1_range: v.repeating_rangedweapon_range, /* and so on */ }); }); });
Thanks I will give it a go today and let you know how it goes.
Thank you all, Jakob in particular, it took a few attempts (minor spelling glitches) but it now works smoothly and am happy with the result, just need to do some CSS to hide the checkbox and make it look pretty.