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 .
×

Tokenmod appears to edit field erroneously

Hi all, I'm working on a macro for a game of Black Star (aka Star Wars with the VIN number scraped off) and I'm using custom character sheets.   The sheets hold information for the Character (obviously), their Droid if they have one and their Ship if they have one.   I'd like to have a rollable-table token with the 3 images, and a Token Action macro so the players can select the appropriate image and stats for the action at hand.   I'm having a few issues, but focusing on one thing at a time, I noticed that when I reset the bar values the number set will be carried over to the "old" variable.   For example, for the Character bar2 represents their force power, if any.  The stat is listed as will or currWill.   My test character as no force power, so the value is blank.   For Ships, bar2 represents the ship's shield strength, listed as rideShields or rideMaxShields.   When I toggle from Character to Ship, the character's will value gets set to the ship's rideShield's value.   My expected behavior is that the bar displays the selected value, and nothing is modified.   The tokenmod is as follows :  !token-mod {{   --set   ?{Choose Token     |Character, currentside#1 bar1#0 bar2_max#0 bar2_link#currwill bar3_link#currresolve bar3_max#7 name#Character     |Droid, currentside#2 bar1#0 bar2_max#0 bar2_link#currwill bar3_link#currresolve bar3_max#7 name#Droid     |Starship, currentside#3 bar1_max#5 bar1_link#rideHealth   bar2_max#5 bar2_link#rideShields bar3_link#currresolve bar3_max#7 name#Ship   } }} Any help would be appreciated.   
I'm not super super familiar with changing the linking with token mod, but maybe the problem lies in trying to change the link and values in the same command. So perhaps just calling token mod set twice, once to change the links and then again to change the values?
Aikepah is correct - this is an ordering issue.  If you're just trying to toggle between Character, Droid, and Starship, you shouldn't need to reset the max values each time you change the token. Changing what the bar is linked to will update the bar with whatever value is held in the linked attribute. So this should do what you're looking for. When you select 'Character' it will unlink bar1, and link bar2 to 'currwill' and bar3 to 'currresolve' with whatever values they already had for current and max.  !token-mod {{   --set   ?{Choose Token     |Character,currentside#1 bar1_link# bar2_link#currwill bar3_link#currresolve name#Character     |Droid,currentside#2 bar1_link# bar2_link#currwill bar3_link#currresolve name#Droid     |Starship,currentside#3 bar1_link#rideHealth bar2_link#rideShields bar3_link#currresolve name#Ship   } }}
Unfortunately it still seems to be dragging the values around.    For Character and Droid, the values of bars 1 and 2 should be 0 using the test character.   For the Ship stats, bars 1 and 2 should be 3 and 2 respectively.   Switching between the 3 token sides if I start as the Character or Droid, it still moves the value of 0 to the Ship's shields. If I reset it manually and then flip to Character or droid from Ship the 2 gets carried to the Will value of the sheet.     Any time I go to the ship and back to the other 2 selections, the value of Bar1 remains 3 ... that one makes sense as I am not replacing it with any other value, so it keeps the value of 3.  Somehow the max value of bar2 becomes 5???? I'm using Jarren's code above so the 5 should not be in there anywhere, I'm not sure where it is picking THAT up.  :D  
1768584292

Edited 1768584354
One thing to check before diving deeper - do you have multiple attributes on the character that have the same name? E.g. if you have 'currresolve' listed more than once, it can cause issues when linking (the sheet may be linking to a different 'currresolve' attribute than you are expecting). And this shouldn't be a problem either, but just to confirm: do you have more than one character  with the same name? Check your Journal Archive as well. It's an outside possibility that you're linked to a different character than you're expecting.
Good questions, but no.   I verified with a code search on the HTML for the sheets.   This is all there is :                              <div class='sheet-row' style='padding: 0px;'>                                 MAX RES <input type='number' class='sheet-skills' name='attr_resolve'>                             </div>                             <div class='sheet-row' style='padding: 0px;'>                                 MAX WILL <input type='number' class='sheet-skills' name='attr_will'>                             </div>                             <div class='sheet-row' style='padding: 0px;'>                                 CONFLICT <input type='number' class='sheet-skills' name='attr_conflict'>                             </div>                         </div>                         <div class='sheet-col' style='margin-right: 10px;'>                             <div class='sheet-row' style='padding: 0px;'>                                 CURR RES <input type='number' class='sheet-skills' name='attr_currresolve'>                             </div>                             <div class='sheet-row' style='padding: 0px;'>                                 CURR WILL <input type='number' class='sheet-skills' name='attr_currwill'>                             </div>                             <div class='sheet-row' style='padding: 0px;'>                                 DARKNESS <input type='number' class='sheet-skills' name='attr_darkness'>                             </div>
You need to look at the Attributes and Abilities tab, not the HTML.  
No, still not doubled up, but I did find where those values set to "5" were coming from.  
Good to know! In case someone else encounters this issue in the future, would you mind elaborating where those values were coming from?