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 there a way to to make an attribute name not be static...

I'm trying to see if there is a way to setup my code in a way that make an attribute name with what ever the user selects from a drop down list. I was hoping to use this in place of a generic one size fit all attribute. For example- In place of fightingspecialty being an attribute I would like to add a drop down of all the specialties such as (Longblades, Spear, etc..) the user can pick from and replace fightingspecialty with what the user picked from the drop down list. I say replace because I don't want fightingspecialty to even pop up.
1515006439
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
This is not possible and indeed, if you will consider it more deeply, is not desired. The point of attributes is that you can reference them safe in the knowledge that they will be the same for any given character. If each character could have their fightingspecialty attribute be a different name, then you could not create macros that would work for all characters (which is really the point of the html/css character sheets). What benefit are you looking for that a dynamic name would help with? Maybe there is another way to attack it.
1515015796

Edited 1515016007
[Deleted]
Sheet Author
API Scripter
It is possible and it is even possible to handle it being different for the sake of calling back to it. You can call the attribute "fighting-longblades" "fighting-spear" and pipe whatever is picked from that option to a secondary box that you act upon for dice rolls. The 2 Sheets I have worked on do this many times throughout their character sheet. Look at the Genesys RPG or the Star Wars: FFG API-Compatible character sheets for multiple examples of this. Code snippet illustrating my code; <td><input type="text" name="attr_customskillname1" /></td> <td>     <select name="attr_charcustomskillname1">         <option value="@{brawn}" data-i18n="brawn">Brawn</option>         <option value="@{agility}" data-i18n="agility">Agility</option>         <option value="@{intellect}" data-i18n="intellect">Intellect</option>         <option value="@{cunning}" data-i18n="cunning">Cunning</option>         <option value="@{willpower}" data-i18n="willpower">Willpower</option>         <option value="@{presence}" data-i18n="presence">Presence</option>      </select> </td>
1515016746
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Aye, that is a work around, but you still don't have a dynamically named attribute. The name of attr_customskillname1 does not change, just its value.
1515017613
[Deleted]
Sheet Author
API Scripter
Sim181 said: I'm trying to see if there is a way to setup my code in a way that make an attribute name with what ever the user selects from a drop down list. I was hoping to use this in place of a generic one size fit all attribute. Scott C. said: Aye, that is a work around, but you still don't have a dynamically named attribute. The name of attr_customskillname1 does not change, just its value. It accomplishes the original goal, ignoring that the "wording of the request" was different than the actual goal that was intended. If you want to be more "exactly accomplishing what is in the text" that is also not that hard, but would require an API script and just pipe the <select name=""> through the javascript to allow for "attr_" + "@{x} + @{y} It is not impossible and indeed my code does this in the API as well. function buildReplacementObject(title, src, size) {     return { matcher: new RegExp("\\$" + title.toUpperCase() + "\\$", "g"), replacer: '<img src="' + src + '" title="' + title + '" height="' + size + '" width="' + size + '"/>' }; }
Scott C. said: This is not possible and indeed, if you will consider it more deeply, is not desired. The point of attributes is that you can reference them safe in the knowledge that they will be the same for any given character. If each character could have their fightingspecialty attribute be a different name, then you could not create macros that would work for all characters (which is really the point of the html/css character sheets). What benefit are you looking for that a dynamic name would help with? Maybe there is another way to attack it. Well one of the reasons I am trying to do it and it makes it desirable to me is because I use text inputs at the moment and have 72 "special" attributes. between I think 19 skills. So to make it easier I wanted to do a drop down so all the user has to do is click on the special attribute and move on. While text works great it causes a mess of extra attributes for the name they input plus the attribute for the skill in the attributes tab. While hiding attributes is the easy way to do it for me code wise, it would be a hassle for them making macros because at that point I'm retyping stuff the sheet has already. Would be user friendly and look better just to have the attribute match the name on the drop down list. That and I could not figure out how to do it and know there has to be a way lol. I may never use it though. GM Knowledge Rhino said: I'm trying to see if there is a way to setup my code in a way that make an attribute name with what ever the user selects from a drop down list. I was hoping to use this in place of a generic one size fit all attribute. Scott C. said: Aye, that is a work around, but you still don't have a dynamically named attribute. The name of attr_customskillname1 does not change, just its value. It accomplishes the original goal, ignoring that the "wording of the request" was different than the actual goal that was intended. If you want to be more "exactly accomplishing what is in the text" that is also not that hard, but would require an API script and just pipe the <select name=""> through the javascript to allow for "attr_" + "@{x} + @{y} It is not impossible and indeed my code does this in the API as well. function buildReplacementObject(title, src, size) {     return { matcher: new RegExp("\\$" + title.toUpperCase() + "\\$", "g"), replacer: '<img src="' + src + '" title="' + title + '" height="' + size + '" width="' + size + '"/>' }; } So it can be done, I lack the java know how to really accomplish this yet but it sets me on the right track. I might have to enlist the help of someone with more skill than me at this to accomplish the task but at least I can point them in the right direction.. Thanks!!
1515047905
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Should note that Knowledge Rhino's example of true dynamic attribute names requires API scripts to function, it can't be done with sheetworkers internal to the sheet. I stand by what I said, doing dynamic attribute names is not possible in character sheets alone. There are some workarounds depending on what you are trying to do, such as the drop down method Knowledge Rhino showed. If I'm understanding your goal though, the drop down method should work for you just fine.
Scott C. said: Should note that Knowledge Rhino's example of true dynamic attribute names requires API scripts to function, it can't be done with sheetworkers internal to the sheet. I stand by what I said, doing dynamic attribute names is not possible in character sheets alone. There are some workarounds depending on what you are trying to do, such as the drop down method Knowledge Rhino showed. If I'm understanding your goal though, the drop down method should work for you just fine. Yea, I realize that. While not what I was hoping it gives me something to play with. Not really a huge fan of having to use the API to make the sheet work and may never use it. Its just another tool in the toolbox That I can use if I ever need to. As far as user interface goes with what I have the drop down is the perfect way at the moment. Still figuring out whats possible for me to accomplish with sheets and roll 20 lol. 
1515055955
GiGs
Pro
Sheet Author
API Scripter
If you have 72 special attributes to choose from, a dropdown list will not be a very good experience for your players - scrolling through more than 5 or 6 items, several times a session, gets really old fast.
1515080500
[Deleted]
Sheet Author
API Scripter
GG, if you use <optgroup>, you can segment off the options within the select to make it more palatable, but there is no real way of making a 72 object list looking "pretty".
1515082989

Edited 1515083001
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Ah, the way I was reading it is that there are 72 split between the 19 different skills. Yeah, if it's 72 options for each skill, that's not really gonna work. I'd look into using your text entry method, but using regex in your sheetworkers to control what attributes are used for the total.
Scott C. said: Ah, the way I was reading it is that there are 72 split between the 19 different skills. Yeah, if it's 72 options for each skill, that's not really gonna work. I'd look into using your text entry method, but using regex in your sheetworkers to control what attributes are used for the total. Your right, they are split between 19 skills. Some skills have 2 or 3, while others have like 8.
1515178237
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Yeah, so I think a dropdown is your best option.
1515189391
Lithl
Pro
Sheet Author
API Scripter
Scott C. said: Should note that Knowledge Rhino's example of true dynamic attribute names requires API scripts to function, it can't be done with sheetworkers internal to the sheet. Sheet workers can create attributes that aren't in the sheet's HTML, so it should work fine.