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

How to track number of items in a repeating Fieldset?

Topic says it all.  I need to be able to track the number of items in a repeating fieldset so that I can compare that value with a maximum value.
1512938061
vÍnce
Pro
Sheet Author
Are you wanting to add up the total number of repeating rows found within a given fieldset? ie total attacks, spells, items, etc.  I'm thinking you would need an API script to do that...  Use case?
Vince said: Are you wanting to add up the total number of repeating rows found within a given fieldset? ie total attacks, spells, items, etc.  I'm thinking you would need an API script to do that...  Use case? Well... the Pathfinder sheet seems to have no problem doing that.  I'm just wondering how it does.  Yes, I want to track the number of items in a given Fieldset.
1512940170
vÍnce
Pro
Sheet Author
The PF sheet uses a css counter to increment row numbers starting with "0" as new rows are added.  There isn't an attribute that's holding a value that you can reference. ;-(
1512940476

Edited 1512940485
Jakob
Sheet Author
API Scripter
You can use getSectionIDs: getSectionIDs('repeating_foo', idArray => { log(idArray.length); // logs number of repeating rows within repeating_foo });
Vince said: The PF sheet uses a css counter to increment row numbers starting with "0" as new rows are added.  There isn't an attribute that's holding a value that you can reference. ;-( Wait... then how does the Pathfinder sheet track that number then?  It shows up in the number of feats.
Jakob said: You can use getSectionIDs: getSectionIDs('repeating_foo', idArray => { log(idArray.length); // logs number of repeating rows within repeating_foo }); Could you possibly explain this in more detail, please?  I'm extremely new to programming.  I only know how to make simple setups for a sheet.
1512941613

Edited 1512941698
vÍnce
Pro
Sheet Author
I'm not sure I follow.  It doesn't sound like you want the total number of rows/items within a fieldset...  Do you want total number of items within a given row?  ie # left|max  More specifically the values of "@{repeating_ability_$X_used}" and "@{repeating_ability_$X_used|max}" substitute the rowID for $X. You can use a macro like; Left: @{selected|repeating_ability_-kilsw28i1l3qbzm6ipi_used} Max: @{selected|repeating_ability_-kilsw28i1l3qbzm6ipi_used|max} Since these are repeating items, you cannot link a token's bars to them. BTW: The Pathfinder Companion Script will track resources. ie uses, ammo, quantity, etc. automatically.
1512942525

Edited 1512942544
Hmm.  I'm just trying to track the number of items in a fieldset because of a homebrew system that allows you to add new feats/abilities by spending points.  We want to be able to track the number of feats/abilities you are allowed based on the number of points you've spent to get those feats/abilities.  That code might just work.
Vince said: I'm not sure I follow.  It doesn't sound like you want the total number of rows/items within a fieldset...  Do you want total number of items within a given row?  ie # left|max  More specifically the values of "@{repeating_ability_$X_used}" and "@{repeating_ability_$X_used|max}" substitute the rowID for $X. You can use a macro like; Left: @{selected|repeating_ability_-kilsw28i1l3qbzm6ipi_used} Max: @{selected|repeating_ability_-kilsw28i1l3qbzm6ipi_used|max} Since these are repeating items, you cannot link a token's bars to them. BTW: The Pathfinder Companion Script will track resources. ie uses, ammo, quantity, etc. automatically. Basically for every new item you add to a Fieldset the value should increase by one.  For every item you remove, the value should decrease by one.  It's just a simple counter to track the number of feats you have automatically.  If this doesn't work I can simply implement a manual counter.
1512943666

Edited 1512944131
vÍnce
Pro
Sheet Author
As Jakob pointed out, you would need to use  sheet workers (javascript) to count the existing repeating rows and compare that to another attribute value.
Vince said: As Jakob pointed out, you would need to use sheet workers (javascript) to count the existing repeating rows and compare that to another attribute value. Manual counter it is then.