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

Is it possible to get the attribute name of a field in a repeated section from a roll macro inside the section?

May 14 (10 years ago)
If I have a fieldset with input A and button roll. Is it possible to get the name of the variable of "attr_A" during the button roll? For example the !ammo script requires the name of the variable and I would like to change the field of the same fieldset entry.

And for the same reason: Is it possible to acquire the character_id which is required by !ammo form within a roll inside a charactersheet?
May 14 (10 years ago)
The Aaron
Pro
API Scripter
For the character id, you can just use @{character_id}. The second is a bit harder and something I need to dig into more. =/
May 14 (10 years ago)
Aaron, once again: You are the best :) (I am guessing you will be hearing that quite often as long as I am working on my character sheet for shadowrun 5 :)
May 14 (10 years ago)
The Aaron
Pro
API Scripter
=D No one gets tired of hearing that, so carry on! =D

Kevin said:

If I have a fieldset with input A and button roll. Is it possible to get the name of the variable of "attr_A" during the button roll? For example the !ammo script requires the name of the variable and I would like to change the field of the same fieldset entry.

And for the same reason: Is it possible to acquire the character_id which is required by !ammo form within a roll inside a charactersheet?

If you mean, change a field inside a roll button to include Character ID. Technically you could? You would need to edit the sheet itself though.
May 14 (10 years ago)
I am working on my own sheet, so this would not be the problem. What I exactly mean is
I have a field inside of a fieldset for each weapon: @{weaponammo} and i have a button inside the same fieldset where I would like to do something like @{weaponammo} = @{weaponammo}-1. For a character variable outside of the fieldset I can use the ammo tracker, but the question is: is there a way to get either the number of the current fieldset when a roll is clicked, such that i can reconstruct the fieldname or is there a way to transform @{weaponammo} into the name of the variable, which i could pass to !ammo again.
May 14 (10 years ago)

Edited May 14 (10 years ago)
I am trying to understand what you want it to do first.

So you want it to track ammo through the character sheet correct?

So Ranged Ammo from Line one does -1 arrow when use is clicked or?

I mean you could just put something like !ammo @{weaponammorow}-1 <br> (Can't remember the linebreak command off the top of my head) /roll [[1d5]] etc
May 14 (10 years ago)

Edited May 14 (10 years ago)
I cant because fieldset variables are number 0-n and !ammo does not take @{weaponammorow} but the actual name of the variable. This is why i need the global name of the variable not the one local one which you can acess reading it :) Therefore a global variable attr_weaponammo is accessible but not a fieldset variable.
May 15 (10 years ago)

Edited May 15 (10 years ago)
The Aaron
Pro
API Scripter
The names of repeating group attribute names are predictable.

If the group is named repeating_foo, and you have an field named attr_bar in it, the attribute for the first instance would be repeating_foo_0_bar.

That name should be usable with Ammo.
May 15 (10 years ago)

Edited May 15 (10 years ago)
Yeah but how does button foo_n know which attr_bar_n it has to modify. That is the caveat, isn't it? They both don't know their indices, don't they?
May 15 (10 years ago)
The Aaron
Pro
API Scripter
Ah, right, good point. Interesting. I'll have to ponder that one.