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

One switch, many variables. How?

Is it possible for one selection in a character sheet to modify many variables? In particular, I want the "Gender" dropdown in the Pathfinder sheet to control several modifiers... namely: Male - Male, but also He, Him, His, etc. Female - Female, but also She, Her, Hers, etc. Other - Other, but also It, Its, It's, etc. Seems like it should be easy but I'm not HTML literate enough (yet!) to figure it out. -Phnord
You would have to follow this up with an API portion in your script. I am not sure how select works (not that great in HTML) but I think maybe in the <option> tag you can make it set a variable such as 0,1,2 using <option name="attr_gender" value=" your variable here "> gender selection here </option> If the api you would have to do an if() tree to find what the value was set to. Keep in mind you will have to also get some basic info on the token such as its ID then parse that into the name, which I will refer to as who.id in this code (that's another question for later if need be) if (getAttrBtName(who.id, "gender") == 0) { var gendPos = "His"; var gendRef = "Him"; } if (getAttrBtName(who.id, "gender") == 1) { var gendPos = "Hers"; var gendRef = "Her"; } if (getAttrBtName(who.id, "gender") == 3) { var gendPos = "It's"; var gendRef = "It"; }
That is just a quick go through... my daughter is hovering over me wanting pool time... That is the basic jist of it, though I am not quite sure if that is how the select and option works in the HTML, I am taking an educated guess on it.
1401813675
Lithl
Pro
Sheet Author
API Scripter
Michael P. said: If the api you would have to do an if() tree to find what the value was set to. Keep in mind you will have to also get some basic info on the token such as its ID then parse that into the name, which I will refer to as who.id in this code (that's another question for later if need be) if (getAttrBtName(who.id, "gender") == 0) { var gendPos = "His"; var gendRef = "Him"; } if (getAttrBtName(who.id, "gender") == 1) { var gendPos = "Hers"; var gendRef = "Her"; } if (getAttrBtName(who.id, "gender") == 3) { var gendPos = "It's"; var gendRef = "It"; } Switch would be better. =) on('change:attribute', function(obj, prev) { if (prev.name != 'gender') return; var pronoun = findObjs({ type: 'attribute', characterid: obj.get('characterid'), name: 'pronoun' })[0]; if (!pronoun) { var pronounDefault = getAttrByName(obj.get('characterid'), 'pronoun'); pronoun = createObj('attribute', { characterid: obj.get('characterid'), name: 'pronoun', current: pronounDefault }); } switch (obj.get('current')) { default: case 'Male': pronoun.set('current', 'Him'); break; case 'Female': pronoun.set('current', 'Her'); break; case 'N/A': pronoun.set('current', 'It'); break; } }); And you can certainly put "Male" or "Female" in the value attribute of the option element; you don't need to create an integer-string mapping. As to the initial question, you can update multiple variables with a single change... if you can auto-calculate those other variables . You can't do that with strings, unfortunately.
Hmm... if the API is the only way to do this, then I need to find another option. I want / need this to be part of the character sheet. I'm trying as hard as possible to avoid using the API; I want very much for my sheet to be fully functional to everyone, not just those with mentor-level memberships and above. I want this because it would make my marcos more beautiful... instead of trying to keep every output gender neutral, I can set up things like: Bob the fighter swings his mighty sword at his enemy the goblin! He hits it ! He does [15] points of damage to it ! Bob the fighter swings a mighty sword at the goblin. Hit! Bob does [15] points of damage to the goblin. Shirley the cleric swings her mighty warhammer at the goblin! She hits it ! She does [17] points of damage to it ! etc. I was hoping for something like this: <spanclass="sheet-table-data-left"><b>Gender: </b></span> <spanclass="sheet-table-data-left"style="width:15%;"> <selecttitle="gender"> <option>None</option> <select name="attr_gender" value =”None”> <select name="attr_gender1" value =”It”> <select name="attr_gender2" value =”It”> <select name="attr_gender3" value =”Its”> <option>Male</option> <select name="attr_gender" value =”Male”> <select name="attr_gender1" value =”He”> <select name="attr_gender2" value =”Him”> <select name="attr_gender3" value =”His”> <optionvalue="female">Female</option> <select name="attr_gender" value =”Female”> <select name="attr_gender1" value =”She”> <select name="attr_gender2" value =”Her”> <select name="attr_gender1" value =”Hers”> </select> </span> But, ya know, a version of that which works. Failing that, I know that a simple list version can be made for each... something like: Male X He Him His Female She Her Hers Other It It Its Only again, ya know, one that works. Unfortunately that's kind of ugly and... what's the opposite of transparent, here? I'd rather just a simple single dropdown or box to check or something. I know there are limits to what can be done, but really, this shouldn't be one of them, should it? I know the kind of minds that actually enjoy calculating long strings of arcane variables - so much so they do it as a game, for entertainment - can figure this out! Looking forward to any and all ideas. -Phnord PS: Sam, everything I know about HTML I've learned from reverse-engineering your sheet. I coulda sworn I saw something like this in there somewhere? PPS: Sam, don't let my ignorance reflect poorly on you - your sheet rocks, I just can't figure it all out!
1401818513
Sam M.
Pro
Sheet Author
The only thing that's similar to this in my sheet would be a select box that references another attribute, like the select boxes for ability scores or armor check penalty source.
Ah, I see... and in the case of the armor check penalty, it's just a simple multiplication question. Worn = 1, Not-Worn = 0. Multiply the penalty by 0, and you get no penalty. Clever. Unfortunately, gender isn't binary, and isn't a numerical value anyway, so that's not gonna work for this, is it? I'll have to come up with another idea. I'll let y'all know when I find one that works. -Phnord
1401820808
Lithl
Pro
Sheet Author
API Scripter
Correct. If gender were a numeric value, you could do this. Unfortunately, it isn't and you can't. Not without the API.
This is what I ended up doing: Not pretty, but it works. And it's in a 'hidden' section of the sheet to it's fill-and-forget. Minor point, really, but I like my scripts to come out looking nice for everyone, even the female players. -Phnord