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

[Question] Repeating Section ID in Character Sheet

1527862325

Edited 1527862384
Davemania
KS Backer
Sheet Author
API Scripter
So I'm trying to do a silly thing maybe. There are some rolls whose results I would like for GM eyes only. I have accomplished this by using the API, but I was trying to take a crack at it with the character sheet not having to make any API calls. The way it would work is that the Player hits their button, which puts an ability button in chat for the GM to press, which whispers the templated roll to himself as a poor mans gmroll. <input type="text" name="attr_DSskillname" value="Adventuring Detect Secret" readonly> <input type="number" name="attr_DSskillvalue" value="18"> <button type="roll" value="[@{name} Detect Secret](~@{character_id}|GMDSSkill)" name="roll_DSSkill"></button> <button class="sheet-hide-it" type="roll" value="/w gm &{template:acks_template} {{name=@{DSskillname}}} {{skillroll=[[1d20+(?{Modifier|0})]]}} {{target=[[@{DSskillvalue}]]}}" name="roll_GMDSSkill"></button> But now I want to put it in a repeating section. When I do that, the Ability Button reference to roll_GMSkill name is no longer valid. I believe this is because at runtime there is an ID connected to that roll name. <fieldset class="repeating_gmskills"> <input type="text" name="attr_GMskillname" class="sheet-bottom-line sheet-skillname" placeholder="Skill Name">     <input type="number" name="attr_GMskillvalue" class="sheet-skillvalue" value="18">     <button type="roll" value="[@{name} @{GMskillname}](~@{character_id}|GMSkill)" name="roll_Skill"></button>     <button class="sheet-hide-it" type="roll" value="/w gm &{template:acks_template} {{name=@{GMskillname}}} {{skillroll=[[(1d20+?{Modifier|0})]]}} {{target=[[@{gmskillvalue}]]}}" name="roll_GMSkill"></button> </fieldset> My question is, can the Repeating Section ID be referenced inside the fieldset? Here I saw $0 used in place of the ID, but there isn't really any context. I tried changing GMSkill to $0GMSkill inside the Ability Button, but that did not work. Anyone know if this is possible, and how to do it?
1527862695
Davemania
KS Backer
Sheet Author
API Scripter
Ugh, well posting about it made me realize that the $0 example I was talking about included the full fieldset class name. Changing the ability button to <button type="roll" value="[@{name} @{GMskillname}](~@{character_id}|repeating_gmskills_$0_GMSkill)" name="roll_Skill"></button> made it work like a charm!
1527863628
Finderski
Pro
Sheet Author
Compendium Curator
Be aware, that $0 only references the first row in that fields; so, if you're hard coding that, then it will always be the first row that gets rolled for this. You should be able to use the row ID in the ability command button. To accomplish that, I'd probably use a sheet worker to create the button value when a new row is created, because the sheet worker can get the row ID for you (I believe).
1528005063

Edited 1528313486
Davemania
KS Backer
Sheet Author
API Scripter
Finderski- Thanks for pointing that out! Obviously, that was only good for the first repeating roll button. I didn't see the event for when a new row is created in the documentation, but here is where I got: I think I am still missing something after I used a sheetworker to set a hidden repeating attribute which in turn is the value of the repeating button. I can see the attribute fill in on the character sheet, and I know that the buttons are tied to those values, but clicking the buttons does... nothing. No errors generated or anything, just nothing. If I drag the button to the macro bar and press it, it generates an empty line in chat. If I dump the value that is being generated from the attribute into an ability button on the sheet and execute it, it works! Hopefully someone has some insight into this... Here are the bits for the repeating section and the sheetworker: <fieldset class="repeating_gmskills">     <input type="text" name="attr_gmskillname" class="sheet-bottom-line sheet-skillname" placeholder="Action Name">     <input type="number" name="attr_gmskillvalue" class="sheet-skillvalue" value="18">     <input type="hidden" name="attr_gmskillRollvalue">     <button type="roll" value="@{gmskillRollvalue}" name="roll_GMSkill"></button>     <button class="sheet-hide-it" type="roll" value="/w gm &{template:acks_template} {{name=@{gmskillname}}} {{skillthrow=[[(1d20+?{Modifier|0})]]}} {{target=[[@{gmskillvalue}]]}}" name="roll_gmGMThrow"></button> </fieldset> //Update GMSkill buttons roll values sometimes I guess on("change:repeating_gmskills:gmskillname", function() {     getSectionIDs("gmskills", function(idArray) { var rollvalues = {};         for(var i=0; i < idArray.length; i++) { rollvalues["gmskills_" + idArray[i] + "_gmskillRollvalue"] =  "[@{character_name} @{repeating_gmskills_" + idArray[i] + "_gmskillname}](~@{character_id}|repeating_gmskills_" + idArray[i] + "_gmGMThrow)";         } setAttrs(rollvalues);     }); });