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

Multiple values for character sheet

1525457700
Leon X.
Plus
Sheet Author
Hello! I need some help for a character sheet I'm making. I was wondering if in HTML/Roll20 there is a way to Is there a way to have multiple values/attributes come out of one <select? Sorry I'm a bit of a newbie at html so any help is appreciated. The only reason I ask is that I need 6 different outputs from one <select. Its fine if there is no way, it'll just be annoying for players, and me both to have six diffrent <select's Once again thanks!
1525459021

Edited 1525459767
Scott C.
Forum Champion
Sheet Author
API Scripter
Compendium Curator
Can you give a bit more detail on what you're trying for? EDIT: The way I'd probably recommend doing this is set the other attributes based on the select's answer with sheetworkers.
1525467082
Finderski
Plus
Sheet Author
Compendium Curator
Or use checkboxes instead of a select. 
1525474723

Edited 1525474785
Leon X.
Plus
Sheet Author
(Thank you both for such a quick response I was expecting to wait for days) So it is for a pen and paper version of "Fire Emblem". Basically, there are 8 different elements (Fire, Ice, Wind, Thunder, Earth, Light, Dark, and Anima) and they each give bonuses to four of the following; Attack, Defense, Hit, Avo, Crit and Crit Avo. If you are next to them you gain a bonus according to their affinity. If it's hard to visualize  here.
1525475483

Edited 1525475541
GiGs
Pro
Sheet Author
API Scripter
That table looks ridiculously complex for an rpg, and the writer clearly hasn't done a good job of translating the essence of the game from its (computer game?) roots to an rpg.  Video games can make use of bonuses like +0.5%, but they are meaningless in a tabletop rpg.  That criticism aside, the problem with implementing this is its dependence on another token.  I see three ways to attempt it: Use sheetworkers. First, have a dropdown to choose the fire/etc, and then in play when the token is beside another, a second dropdown to select the relavent subtype. The sheet worker would react to those changes and apply relevant bonuses. Use Autocalc fields  to implement the bonuses, again based on the two dropdowns. Use a Script:  instead of building this into the character sheet, have an API script which calculates the modifiers and applies them to attributes on the character sheet (or build the attack rolls directly into the script). The advantage of the script approach is that taking account of whether tokens are next to each other, etc., can all be automated with zero input from players and GM. However you do it though, it's going to be very fiddly to set up for almost no measurable effect since most of the bonuses are so tiny. I don't envy you the work!
1525477323
Leon X.
Plus
Sheet Author
The different support levels are easy enough that's just a multiplier of 0, 1, 2, 3, or 4 depending on what level. You can ignore that. I just want to know if there is a way to get multiple outputs if I put in fire in one place. I'm sorry G. G. but I really have little experience. If you have an api example or something that would help because that stuff goes over my head ^^;
1525494513

Edited 1525494689
GiGs
Pro
Sheet Author
API Scripter
The easiest way is the sheetworker approach, though it'll look very confusing at first. At the very bottom of the html sheet, add the following:  <script type="text/worker"> </script> Any scripts you add, like the one I'm about to suggest go between that script block. If your sheet already has a script block like this, don't create a new one, add any scripts inside the same block. So, for a sheetworker to work, it needs several things: First it needs a block like this: on("change:myattribute", function() { }); This tells roll20: on a change to this attribute, perform this function. So we need to fill in the function. One of the complications of working with roll20, is that the script engine doesnt know the attribute values automatically, It may detect that an attribute has changed , but it doesnt know what the attribute value is , so we need to set that up. on("change:myattribute", function() {     getAttrs(["MyAttribute"], function(values) {         let myStat = values.MyAttribute;     }); }); Now things look a bit more complicated, but if you use sheet workers a lot, this basic framework will start to look very familiar. getAttrs is a function that creates the named attribute as an object. Then the let myStat statement extracts the value of that object in a form you can actually use. You don't need to worry about why it works like this, just follow this pattern and it works. If you're eagle-eyed, you may notice the on(change) line and the others are not using the same case. I wanted to point out that event calls (like the on(change) must always use lower case, even if the attribute name is not in lower case. But for the rest of the function ,you use the case of the attribute as defined in the character sheet. You can avoid having to worry about this, by always making your attribute names lower case! So, imagine you have a dropdown attribute named affinity , which has the entries "Fire", "Water", etc. When the user changes the affinity, you want several stats to be updated, lets call them hitmod , damagemod , critmod .  on("change:affinity", function () { getAttrs(["affinity"], function (values) { //initialize variables let affinity = values.affinity; let critmod = 0; let hitmod = 0; let damagemod = 0; // depending on affinity value, change other stats values. switch (affinity) { case "Fire": critmod = 1; hitmod = 1; damagemod = 1; break; case "Earth": critmod = 2; hitmod = 2; damagemod = 2; break; case "Ice": critmod = 3; hitmod = 3; damagemod = 3; break; case "Wind": critmod = 4; hitmod = 4; damagemod = 4; break; } }); }); There's a lot going on in this, but to explain the new elements: since you want to have several stats affected, you need to create a new variable to hold each one's value. Then the switch statement allows you to modify the various stats, based on the value of the affinity. It basically says, "When affinity is Wind, do this", etc. When affinity is Wind, everything between the Case "Wind" and the break statement is carried out. (break tells the script to leave the switch block). Note that I havent looked at the table to get those values, you should be able to enter the correct values yourself. You should be able to add the extra blocks, too, for the other affinities. So at this point you have code which will detect when the affinity attribute changes, and set up variables for the stats you want altered. You now need to save them to the character sheet. This is the final step - see the setAttrs block in the following on("change:affinity", function () { getAttrs(["affinity"], function (values) { let affinity = values.affinity; let critmod = 0, hitmod = 0, damagemod = 0; switch (affinity) { case "Fire": critmod = 1; hitmod = 1; damagemod = 1; break; case "Earth": critmod = 2; hitmod = 2; damagemod = 2; break; case "ice": critmod = 3; hitmod = 3; damagemod = 3; break; case "Wind": critmod = 4; hitmod = 4; damagemod = 4; break; } setAttrs({ "critMod": critmod, "damageMod": damagemod, "hitMod": hitmod }) }); }); I've made a couple of assumptions here: first, your character sheet has three attributes: hitMod, damageMod, and critMod. setAttrs saves the variables we created earlier into those stats. Note: in the setAttrs function, each line must end with a comma, except the last one which must not. Now, when you make an attack macro, you can use those stats in then normal way (e.g. @{attackMod}), can use autocalc fields to add them to attributes on the sheet, or add extra sheet workers to use them in various ways. Hopefully this gets you started.
1525495890

Edited 1525495967
GiGs
Pro
Sheet Author
API Scripter
To add to the previous post, you'll also need to incorporate a support level modifier. Here's what that code might look like. Any lines that start with // are comments and can be safely deleted. They are ignored by the script, but are instructional for you. <script type="text/worker"> on("change:affinity change:support", function () { // when you have multiple stats to monitor, you just chain them together, as shown above: between quotes, and spaces between them. getAttrs(["affinity","support"], function (values) { // if you need to grab multiple stats, you need to put each stat in its own quotes, and separate with a comma. All stats go between the square brackets. let affinity = values.affinity; let support = values.support let critmod = 0; let hitmod = 0; let damagemod = 0; let multiplier = 1; switch (affinity) { case "Fire": critmod = 1; hitmod = 1; damagemod = 1; break; case "Earth": critmod = 2; hitmod = 2; damagemod = 2; break; case "ice": critmod = 3; hitmod = 3; damagemod = 3; break; case "Wind": critmod = 4; hitmod = 4; damagemod = 4; break; } // the if else if structure below should be pretty easy to understand. The triple equals is weird, but is important: // don't use a single "=" when checking if things are equal, only use it when assigning a value. // I used values of A, B, C, etc here - but substitute whatever your sheet actually uses. if(support === "A") multiplier = 1; else if(support === "B") multiplier = 2; else if(support === "C") multiplier = 3; else if(support === "D") multiplier = 4; hitmod = hitmod * multiplier; damagemod = damagemod * multiplier; critmod = critmod * multiplier; setAttrs({ "critMod": critmod, "attackMod": attackmod, "hitMod": hitmod }) }); }); </script> And there you have it. There should be enough to go on there to set up your sheet worker. There are much more streamlined and elegant ways you could write this code, but they will be much harder for a newbie to understand. i tried to keep it as straightforward as possible.
1525536927
Leon X.
Plus
Sheet Author
Thank you all for helping so much!
1525539817

Edited 1525618741
Leon X.
Plus
Sheet Author
So because I am going to have to make 24 instances of this I rewrote it to have a 1 after everything, so written out it is this; <script type="text/worker"> on("change:affinity1", function () { getAttrs(["affinity1"], function (values) { //initialize variables let affinity1 = values.affinity1; let damagesupportmod1 = 0; let defensesupportmod1 = 0; let hitsupportmod1 = 0; let critsupportmod1 = 0; let avosupportmod1 = 0; let critavosupportmod1 = 0; // depending on affinity value, change other stats values. switch (affinity1) { case "Fire1": damagesupportmod1 = 0.5; defensesupportmod1 = 0; hitsupportmod1 = 2.5; avosupportmod1 = 2.5; critsupportmod1 = 2.5; critavosupportmod1 = 0; break; case "Ice1": damagesupportmod1 = 0; defensesupportmod1 = 0.5; hitsupportmod1 = 2.5; avosupportmod1 = 2.5; critsupportmod1 = 0; critavosupportmod1 = 2.5; break; case "Wind1": damagesupportmod1 = 0.5; defensesupportmod1 = 0; hitsupportmod1 = 2.5; avosupportmod1 = 0; critsupportmod1 = 2.5; critavosupportmod1 = 2.5; break; case "Thunder1": damagesupportmod1 = 0; defensesupportmod1 = 0.5; hitsupportmod1 = 2.5; avosupportmod1 = 0; critsupportmod1 = 2.5; critavosupportmod1 = 2.5; break; case "Earth1": damagesupportmod1 = 0; defensesupportmod1 = 0.5; hitsupportmod1 = 0; avosupportmod1 = 2.5; critsupportmod1 = 2.5; critavosupportmod1 = 2.5; break; case "Dark1": damagesupportmod1 = 0; defensesupportmod1 = 0; hitsupportmod1 = 0.5; avosupportmod1 = 2.5; critsupportmod1 = 2.5; critavosupportmod1 = 2.5; break; case "Light1": damagesupportmod1 = 0.5; defensesupportmod1 = 0.5; hitsupportmod1 = 2.5; avosupportmod1 = 0; critsupportmod1 = 2.5; critavosupportmod1 = 0; break; case "Anima1": damagesupportmod1 = 0.5; defensesupportmod1 = 0.5; hitsupportmod1 = 0; avosupportmod1 = 2.5; critsupportmod1 = 0; critavosupportmod1 = 2.5; break; } setAttrs({ "damagesupportmod1": damagesupportmod1, "defensesupportmod1": defensesupportmod1, "hitsupportmod1": hitsupportmod1, "avosupportmod1": avosupportmod1, "critsupportmod1": critsupportmod1, "critavosupportmod1": critavosupportmod1 } }); }); </script> Then I made the affinity choice            </div> </div> </div> <div/> <select name="attr_affinity1" size="1"> <option name="attr_Fire1">Fire</option> <option name="attr_Ice1">Ice</option> <option name="attr_Wind1">Wind</option> <option name="attr_Thunder1">Thunder</option> <option name="attr_Earth1">Earth</option> <option name="attr_Dark1">Dark</option> <option name="attr_Light1">Light</option> <option name="attr_Anima1">Anima</option> </div> Then I have the formula... {{The foe takes= [[@{strength}+@{might1} + ?{Weapon Triangle|None, 0|Advantage, 1| Disadvantage, -1} + (@{damagesupportmod1}*@{supportrank1}*@{supportnext1})]] dmg}} Sorry I dunno how to do the grey. I dunno how to do a lot of things... What am I doing wrong @.@ Last thingy I promise, thanks again for all the help.