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

Token bar default to attribute

Greetings, all! I'd like token bars to default to a character's attribute. I can get it to default to a specific number, or text, but not the actual attribute name. I'm hoping there's a generic syntax I can use for this to use attributes as token defaults. I'm using the GURPS character sheet as a free user. In the example, I want Bar 3 to always represent the attribute "hit_points". But when I put a new token out and link it bar 3 is the text "hit_points" rather than the attribute. I can manually select that as the attribute, but my goal is to have that attribute selected automatically for all tokens, in particular, ones linked to characters. Can this be done? Thanks!  
1613769436
GiGs
Pro
Sheet Author
API Scripter
In the Attribute drop down, select the hit_points attribute.
Scroll further down to 'BAR 3 LINK :'  and change that to 'hit_points', not the fields themselves.
1613794171

Edited 1613794212
Jarren K. said: Scroll further down to 'BAR 3 LINK :'  and change that to 'hit_points', not the fields themselves. That sounds like exactly what I want! But I don't see it on the Gurps character sheet. Is that on all of them or might it just be unavailable for this sheet's settings?
Philip W. said: That sounds like exactly what I want! But I don't see it on the Gurps character sheet. Is that on all of them or might it just be unavailable for this sheet's settings? I just made a quick test Gurps game, and I don't see it either, so I guess it's character sheet or game specific.
1613798426
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
If this is the "GURPS" sheet, the attribute is called "hit_points":
I agree! "hit_points" is the default bat attribute I want. I can manually set that as the bar value, but can that be the default? Seems like Jarren K. doesn't see it for the Gurps sheet. keithcurtis said: If this is the "GURPS" sheet, the attribute is called "hit_points":
1613828725
The Aaron
Roll20 Production Team
API Scripter
When you say "set it as default" are you talking about: Setting it as the bar's linked value for that token whenever you pull it out of the journal: totally possible, you need to set the token to be the default token for that character after you have configured the token appropriately.  Setting the game so that any token created will have that bar linked to the hit_points attribute of a character: not possible short of an API script (pro subscriber perk) that manages it.  Something else?
The Aaron said: Setting the game so that any token created will have that bar linked to the hit_points attribute of a character: not possible short of an API script (pro subscriber perk) that manages it.  Yes that's what I want and thanks for clarifying! I want all new tokens' bars linked to the hit_points attribute rather than manually selecting it from the drop down menu for each new token. I'm pretty new to this; If I had the pro subscription, how difficult would that normally be to setup that API script?
1613831605
The Aaron
Roll20 Production Team
API Scripter
Not too difficult, it would look something like this (but note that it would have to happen when you set what character a graphic represents—if you drug in a shrubbery, it wouldn't know who to link to, for example): on('ready',()=>{ const HPBar = 1; const setLink = (token,barnum,attrname) => { let cid = token.get('represents') || ''; if('' !== cid) { let attr = findObjs({type: 'attribute', characterid: cid, name: attrname}, {caseInsensitive: true})[0]; if(attr) { token.set({ [`bar${barnum}_link`]: attr.id, [`bar${barnum}_value`]: attr.get('current'), [`bar${barnum}_max`]: attr.get('max') }); } else { token.set(`bar${barnum}_link`,`sheetattr_${attrname}`); } } }; on('change:graphic',(obj,prev)=>{ let cid = obj.get('represents'); if(cid && cid !== prev.represents){ setLink(obj,HPBar,'hit_points'); } }); });
1613844697

Edited 1613844711
It looks like you've provided a nice API solution Aaron, but I'm not sure if Philip W. has a Pro subscription for his game or not. Just to clarify, on the Campaign Settings page for a game with D&D 5E by Roll20 selected as the character sheet for the game, you see these options: Down at the bottom is a setting for BAR 3 LINK: to be set to whatever the DM wants as default. But when I create a game with GURPS as the character sheet, here's what the default settings look like: There's no option to set a default for the "BAR 3 LINK:" like there is with the D&D 5E by Roll20 sheet.  So I don't know if there's any option to set the bar link defaults for non-API users playing GURPS.
1613849825
GiGs
Pro
Sheet Author
API Scripter
IIRC those defaults only apply to characters dragged in from a compendium, and GURPS doesnt have a compendium, so that page might not do anything at all.
1613851171
The Aaron
Roll20 Production Team
API Scripter
Jarren K. said: It looks like you've provided a nice API solution Aaron, but I'm not sure if Philip W. has a Pro subscription for his game or not. Yeah, he'd asked how hard it was... Philip W. said: If I had the pro subscription, how difficult would that normally be to setup that API script? So I figured, what the heck...  =D
Yeah, he'd asked how hard it was... Philip W. said: If I had the pro subscription, how difficult would that normally be to setup that API script? So I figured, what the heck...  =D That wasn't there before!  Umm... I must have traveled through time... or something... or maybe reading is just hard sometimes.  :)  Hopefully this still helps anyone else who has the same problem in the future but doesn't want to go Pro.
Wow I really appreciate all the responses, everyone! I guess for a less popular system like GURPS there just aren't as many features or tools (or compendiums). The Aaron said: Not too difficult, it would look something like this (but note that it would have to happen when you set what character a graphic represents—if you drug in a shrubbery, it wouldn't know who to link to, for example): on('ready',()=>{ const HPBar = 1; const setLink = (token,barnum,attrname) => { let cid = token.get('represents') || ''; if('' !== cid) { let attr = findObjs({type: 'attribute', characterid: cid, name: attrname}, {caseInsensitive: true})[0]; if(attr) { token.set({ [`bar${barnum}_link`]: attr.id, [`bar${barnum}_value`]: attr.get('current'), [`bar${barnum}_max`]: attr.get('max') }); } else { token.set(`bar${barnum}_link`,`sheetattr_${attrname}`); } } }; on('change:graphic',(obj,prev)=>{ let cid = obj.get('represents'); if(cid && cid !== prev.represents){ setLink(obj,HPBar,'hit_points'); } }); }); What's not too difficult is copying and pasting what you've already done for me hahaha. Me writing it myself is another story. Really appreciate the support!