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

Using a sheetworker to fill data from a dropdown

Hi, There's a lot of great info from GiGs and others about sheetworkers. I've followed what I could, and I'm clearly not doing it right. What I'm trying to do is say, if you choose a given vehicle, the stats on that vehicle fill themselves in for you. Here's the code for the vehicle section repeater- <div class="sheet-vehicles"> <h1 class="sheet-section">Vehicles</h1> <table width="100%"> </table> <fieldset class="repeating_vehicles"> <table width="100%"> <tbody> <tr> <th width="20%">Description</th> <th width="7%">Quick</th> <th width="7%">Weight</th> <th width="10%">Armor</th> <th width="13%">SP</th> <th width="15%">Range</th> <th width="20%">Speed</th> <th width="7%">Acc</th> </tr> <tr> <td><input type="text" name="attr_VehicleName"></td> <td><input type="text" name="attr_VehicleQuick" min="0"></td> <td><input type="text" name="attr_VehicleWeight" min="0"></td> <td><input type="text" name="attr_VehicleArmor" min="0"></td> <td><input type="text" name="attr_VehicleSP"></td> <td> <select name="attr_VehicleRange"> <option selected></option> <option>Touching</option> <option>Close</option> <option>Medium</option> <option>Far</option> <option>Extreme</option> <option>Out Of Range</option> </select> </td> <td> <select name="attr_VehicleSpeed"> <option selected></option> <option>Safe</option> <option>Risky</option> <option>Dangerous</option> <option>Life Threatening</option> <option>Crazy</option> <option>Plaid</option> </select> </td> <td><input type="text" name="attr_VehicleAcc" min="0"></td> </tr> <tr> <th>Class</th> <th>Safe</th> <th>Risky</th> <th>Dangerous</th> <th>Life Threatening</th> <th>Crazy</th> <th>Plaid</th> </tr> <tr> <td> <select name="attr_VehicleType"> <option selected></option> <option value="1">Skateboard</option> <option value="2">Bicycle</option> <option value="3">Moped</option> <option value="4">Motorcycle</option> <option value="5">Hog</option> <option value="6">Compact Car</option> <option value="7">Medium Car</option> <option value="8">Large SUV</option> <option value="9">Van</option> <option value="10">Small Truck</option> <option value="11">Truck</option> <option value="12">Bus</option> </select> </td> <td><input type="text" name="attr_VehicleSpeedSafe"></td> <td><input type="text" name="attr_VehicleSpeedRisky"></td> <td><input type="text" name="attr_VehicleSpeedDangerous"></td> <td><input type="text" name="attr_VehicleSpeedLifeThreatening"></td> <td><input type="text" name="attr_VehicleSpeedCrazy"></td> <td><input type="text" name="attr_VehicleSpeedPlaid"></td> <th>kph</th> </tr> </tbody> </table> </fieldset> </div> And here's the sheetworker bit- <script type="text/worker"> on("change:repeating_vehicles:vehicletype sheet:opened", function() { //when the VehicleType dropdown changes getAttrs(["repeating_vehicles:VehicleType"], function(values) { //read the value of the selected entry in the VehicleType dropdown const vehicles = { Skateboard: {quick: 7, safe: 5, risky: 10, dangerous: 20, life_threatening: 30, crazy: 40, plaid: 50, tons: 0.0001, SP: 1, armor: 0}, Bicycle: {quick: 6, safe: 15, risky: 25, dangerous: 40, life_threatening: 50, crazy: 70, plaid: 80, tons: 0.001, SP: 2, armor: 0}, Moped: {quick: 4, safe: 20, risky: 40, dangerous: 50, life_threatening: 70, crazy: 100, plaid: 1200, tons: 0.03, SP: 5, armor: 1}, Motorcycle: {quick: 10, safe: 30, risky: 50, dangerous: 75, life_threatening: 100, crazy: 130, plaid: 50, tons: 0.5, SP: , armor: 1}, Hog: {quick: 7, safe: 30, risky: 60, dangerous: 80, life_threatening: 110, crazy: 150, plaid: 180, tons: 0.7, SP: 8, armor: 1}, Compact car: {quick: 4, safe: 30, risky: 50, dangerous: 70, life_threatening: 90, crazy: 120, plaid: 140, tons: 1.3, SP: 13, armor: 3}, Medium Car: {quick: 6, safe: 30, risky: 50, dangerous: 80, life_threatening: 100, crazy: 130, plaid: 150, tons: 1.5, SP: 15, armor: 3}, Large SUV: {quick: 6, safe: 20, risky: 50, dangerous: 70, life_threatening: 90, crazy: 120, plaid: 150, tons: 2.4, SP: 24, armor: 4}, Van: {quick: 5, safe: 30, risky: 50, dangerous: 70, life_threatening: 100, crazy: 120, plaid: 140, tons: 6, SP: 30, armor: 3}, Small Truck: {quick: 4, safe: 30, risky: 50, dangerous: 80, life_threatening: 100, crazy: 110, plaid: 120, tons: 12, SP: 40, armor: 2}, Truck: {quick: 3, safe: 30, risky: 50, dangerous: 80, life_threatening: 100, crazy: 110, plaid: 120, tons: 25, SP: 60, armor: 4}, Bus: {quick: 3, safe: 30, risky: 50, dangerous: 80, life_threatening: 100, crazy: 110, plaid: 120, tons: 17, SP: 50, armor: 4} }; let VehicleTypeValue = values.VehicleType||0; //make a temp variable called "VehicleTypeValue" and store the value of VehicleType in it. If not selected, 0 setAttrs({ "repeating_vehicles:attr_VehicleSpeedSafe": VehicleType.safe //pass VehicleTypeValue into VehicleSpeedSafe }); )}; )}; </script> Any idea why the Safe speed is not showing up in the field if I choose a vehicle?
1586685147

Edited 1586685782
GiGs
Pro
Sheet Author
API Scripter
You have the attribute name as  attr_VehicleSpeedSafe The attr_part is not part pf the name, its a prefix used by roll20 to identify the the type of name it is. Names can start with attr_, roll_, and act_, and roll20 treats each of them differently. Only the part after that is the actual attribute name, so this should be  "repeating_vehicles_VehicleSpeedSafe": VehicleType.safe Note the use of the underscore instead of the colon here. You only use the colon on change lines. But that's not quite correct either, because it doesnt call the value from the vehicles data. So it should be "repeating_vehicles_VehicleSpeedSafe": vehicles[VehicleType].safe Note that the end of this post changes this to a simpler format. Likewise the colon in the getAttrs line should be changed too: getAttrs(["repeating_vehicles_VehicleType"], function(values) This line is also a problem: let VehicleTypeValue = values.VehicleType||0; The ||0 at the end is for attributes which are supposed to be numbers. But there's nothignto test here., so the ||0 will never happen. So you should drop that here, and then check if the vihicle name is the list later. let VehicleTypeValue = values.VehicleType; First in your vehicle list add a 'none' item to handle what gets printed to the sheet when the vehicle is none. Something like const vehicles = { none: {quick: 0, safe: 0, risky: 0, dangerous: 0, life_threatening: 0, crazy: 0, plaid: 0, tons: 0, SP: 0, armor: 0}, Then create a variable to hold the current vehicle, like const thisVehicle = vehicles[vehicleType] || vehicles['none']; This uses the vehicle name you've entered, tries to get the vehicle from the list of vehicles, and if not found, uses the 'none' vehicle. When names are in select, players can only pick from the existing list, but they can also delete the vehicle, so you have to account for what happens when nothing is in the both. Hence the none entry above. These changes mean the setattrs would now be      setAttrs({ "repeating_vehicles_VehicleSpeedSafe": thisVehicle.safe //pass VehicleTypeValue into VehicleSpeedSafe });
1586689033

Edited 1586689709
Hey. I think I've followed your steps, but it's still not working. Might it be that instead of text fields in the repeater, fields into which the worker is placing those values be some other type? Beyond that, I'm stuck. Here's the new version of the worker- <script type="text/worker"> on("change:repeating_vehicles:vehicletype sheet:opened", function() { //when the VehicleType dropdown changes getAttrs(["repeating_vehicles_VehicleType"], function(values) { //read the value of the selected entry in the VehicleType dropdown const thisVehicle = vehicles[vehicleType] || vehicles['none']; const vehicles = { none: {quick: 0, safe: 0, risky: 0, dangerous: 0, lifethreatening: 0, crazy: 0, plaid: 0, tons: 0, SP: 0, armor: 0}, Skateboard: {quick: 7, safe: 5, risky: 10, dangerous: 20, lifethreatening: 30, crazy: 40, plaid: 50, tons: 0.0001, SP: 1, armor: 0}, Bicycle: {quick: 6, safe: 15, risky: 25, dangerous: 40, lifethreatening: 50, crazy: 70, plaid: 80, tons: 0.001, SP: 2, armor: 0}, Moped: {quick: 4, safe: 20, risky: 40, dangerous: 50, lifethreatening: 70, crazy: 100, plaid: 1200, tons: 0.03, SP: 5, armor: 1}, Motorcycle: {quick: 10, safe: 30, risky: 50, dangerous: 75, lifethreatening: 100, crazy: 130, plaid: 50, tons: 0.5, SP: , armor: 1}, Hog: {quick: 7, safe: 30, risky: 60, dangerous: 80, lifethreatening: 110, crazy: 150, plaid: 180, tons: 0.7, SP: 8, armor: 1}, Compact car: {quick: 4, safe: 30, risky: 50, dangerous: 70, lifethreatening: 90, crazy: 120, plaid: 140, tons: 1.3, SP: 13, armor: 3}, Medium Car: {quick: 6, safe: 30, risky: 50, dangerous: 80, lifethreatening: 100, crazy: 130, plaid: 150, tons: 1.5, SP: 15, armor: 3}, Large SUV: {quick: 6, safe: 20, risky: 50, dangerous: 70, lifethreatening: 90, crazy: 120, plaid: 150, tons: 2.4, SP: 24, armor: 4}, Van: {quick: 5, safe: 30, risky: 50, dangerous: 70, lifethreatening: 100, crazy: 120, plaid: 140, tons: 6, SP: 30, armor: 3}, Small Truck: {quick: 4, safe: 30, risky: 50, dangerous: 80, lifethreatening: 100, crazy: 110, plaid: 120, tons: 12, SP: 40, armor: 2}, Truck: {quick: 3, safe: 30, risky: 50, dangerous: 80, lifethreatening: 100, crazy: 110, plaid: 120, tons: 25, SP: 60, armor: 4}, Bus: {quick: 3, safe: 30, risky: 50, dangerous: 80, lifethreatening: 100, crazy: 110, plaid: 120, tons: 17, SP: 50, armor: 4} }; let VehicleTypeValue = values.VehicleType; //make a temp variable called "VehicleTypeValue" and store the value of VehicleType in it. If not selected, 0 setAttrs({ "repeating_vehicles_VehicleQuick": thisVehicle.quick, //pass VehicleTypeValue into VehicleSpeedSafe "repeating_vehicles_VehicleSpeedSafe": thisVehicle.safe, "repeating_vehicles_VehicleSpeedRisky": thisVehicle.risky, "repeating_vehicles_VehicleSpeedDangerous": thisVehicle.dangerous, "repeating_vehicles_VehicleSpeedLifeThreatening": thisVehicle.lifethreatening, "repeating_vehicles_VehicleSpeedCrazy": thisVehicle.crazy, "repeating_vehicles_VehicleSpeedPlaid": thisVehicle.plaid, "repeating_vehicles_VehicleWeight": thisVehicle.tons, "repeating_vehicles_VehicleSp": thisVehicle.sp, "repeating_vehicles_VehicleArmor": thisVehicle.armor }); )}; )}; </script>
I think you need the repeating section ID and use all-lowercase to get / set the attr value: getAttrs([`repeating_vehicles_${sectionId}_vehicletype`], function(values) { let VehicleTypeValue = values[`repeating_vehicles_${sectionId}_vehicletype`] setAttrs({ `repeating_vehicles_${sectionId}_vehiclequick`: thisVehicle.quick, }); ref:&nbsp; <a href="https://wiki.roll20.net/Building_Character_Sheets#Repeating_Sections" rel="nofollow">https://wiki.roll20.net/Building_Character_Sheets#Repeating_Sections</a> &nbsp;and&nbsp; <a href="https://wiki.roll20.net/Sheet_Worker_Scripts#Events" rel="nofollow">https://wiki.roll20.net/Sheet_Worker_Scripts#Events</a> I think you should be able to get the section id from the eventInfo of the `on` callback. It seems like this line should be after &nbsp;the `let VehicleTypeValue` line: const thisVehicle = vehicles[VehicleTypeValue] || vehicles['none'];
1586694069

Edited 1586694312
GiGs
Pro
Sheet Author
API Scripter
Primal Zed, This getAttrs([`repeating_vehicles_${sectionId}_vehicletype`], function(values) { isn't necessary on this kind of worker. If you are responding to events within a&nbsp; repeating section, and only changing things on the same row of the sheet worker, you can use the shorthand posted above. Roll20 inserts the id behind the scenes. Tuck, you've got the order of statements a little bit wrong, and misnamed variable. You have this line const thisVehicle = vehicles[vehicleType] || vehicles['none']; but it needs a variable vehicleType, which isnt set anywhere in the worker.&nbsp; Try this code:&nbsp; on("change:repeating_vehicles:vehicletype sheet:opened", function() { //when the VehicleType dropdown changes getAttrs(["repeating_vehicles_VehicleType"], function(values) { //read the value of the selected entry in the VehicleType dropdown const vehicles = { none: {quick: 0, safe: 0, risky: 0, dangerous: 0, lifethreatening: 0, crazy: 0, plaid: 0, tons: 0, SP: 0, armor: 0}, Skateboard: {quick: 7, safe: 5, risky: 10, dangerous: 20, lifethreatening: 30, crazy: 40, plaid: 50, tons: 0.0001, SP: 1, armor: 0}, Bicycle: {quick: 6, safe: 15, risky: 25, dangerous: 40, lifethreatening: 50, crazy: 70, plaid: 80, tons: 0.001, SP: 2, armor: 0}, Moped: {quick: 4, safe: 20, risky: 40, dangerous: 50, lifethreatening: 70, crazy: 100, plaid: 1200, tons: 0.03, SP: 5, armor: 1}, Motorcycle: {quick: 10, safe: 30, risky: 50, dangerous: 75, lifethreatening: 100, crazy: 130, plaid: 50, tons: 0.5, SP: , armor: 1}, Hog: {quick: 7, safe: 30, risky: 60, dangerous: 80, lifethreatening: 110, crazy: 150, plaid: 180, tons: 0.7, SP: 8, armor: 1}, Compact car: {quick: 4, safe: 30, risky: 50, dangerous: 70, lifethreatening: 90, crazy: 120, plaid: 140, tons: 1.3, SP: 13, armor: 3}, Medium Car: {quick: 6, safe: 30, risky: 50, dangerous: 80, lifethreatening: 100, crazy: 130, plaid: 150, tons: 1.5, SP: 15, armor: 3}, Large SUV: {quick: 6, safe: 20, risky: 50, dangerous: 70, lifethreatening: 90, crazy: 120, plaid: 150, tons: 2.4, SP: 24, armor: 4}, Van: {quick: 5, safe: 30, risky: 50, dangerous: 70, lifethreatening: 100, crazy: 120, plaid: 140, tons: 6, SP: 30, armor: 3}, Small Truck: {quick: 4, safe: 30, risky: 50, dangerous: 80, lifethreatening: 100, crazy: 110, plaid: 120, tons: 12, SP: 40, armor: 2}, Truck: {quick: 3, safe: 30, risky: 50, dangerous: 80, lifethreatening: 100, crazy: 110, plaid: 120, tons: 25, SP: 60, armor: 4}, Bus: {quick: 3, safe: 30, risky: 50, dangerous: 80, lifethreatening: 100, crazy: 110, plaid: 120, tons: 17, SP: 50, armor: 4} }; const VehicleType = values.VehicleType; //make a temp variable called "VehicleTypeValue" and store the value of VehicleType in it. If not selected, 0 &nbsp;&nbsp;&nbsp;&nbsp;const thisVehicle = vehicles[VehicleType] || vehicles['none']; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAttrs({ "repeating_vehicles_VehicleQuick": thisVehicle.quick, //pass VehicleTypeValue into VehicleSpeedSafe "repeating_vehicles_VehicleSpeedSafe": thisVehicle.safe, "repeating_vehicles_VehicleSpeedRisky": thisVehicle.risky, "repeating_vehicles_VehicleSpeedDangerous": thisVehicle.dangerous, "repeating_vehicles_VehicleSpeedLifeThreatening": thisVehicle.lifethreatening, "repeating_vehicles_VehicleSpeedCrazy": thisVehicle.crazy, "repeating_vehicles_VehicleSpeedPlaid": thisVehicle.plaid, "repeating_vehicles_VehicleWeight": thisVehicle.tons, "repeating_vehicles_VehicleSp": thisVehicle.sp, "repeating_vehicles_VehicleArmor": thisVehicle.armor }); )}; )};
1586694172

Edited 1586694323
GiGs
Pro
Sheet Author
API Scripter
You could also combine these two lines &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const VehicleType = values.VehicleType; //make a temp variable called "VehicleTypeValue" and store the value of VehicleType in it. If not selected, 0 &nbsp;&nbsp;&nbsp;&nbsp;const thisVehicle = vehicles[VehicleType] || vehicles['none']; to &nbsp;&nbsp;&nbsp;&nbsp;const thisVehicle = vehicles[values.VehicleType] || vehicles['none'];
Wow, that's much more clear. :) I see what you mean about that missing variable. Thanks for that. I've pasted that in, and checked for spelling errors, missing commas and attr names that might not match. All seems in order, yet nothing continues to happen.
1586720284

Edited 1586720466
GiGs
Pro
Sheet Author
API Scripter
In your vehicles data variable, you have spaces in the names, like&nbsp; Compact&nbsp;car:&nbsp;{quick:&nbsp;4,&nbsp;safe:&nbsp;30,&nbsp;risky:&nbsp;50,&nbsp;dangerous:&nbsp;70,&nbsp;lifethreatening:&nbsp;90,&nbsp;crazy:&nbsp;120,&nbsp;plaid:&nbsp;140,&nbsp;tons:&nbsp;1.3,&nbsp;SP:&nbsp;13,&nbsp;armor:&nbsp;3},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Spaces in names cause the script to break. You need to enclose them in quotes, like&nbsp; "Compact&nbsp;car":&nbsp;{quick:&nbsp;4,&nbsp;safe:&nbsp;30,&nbsp;risky:&nbsp;50,&nbsp;dangerous:&nbsp;70,&nbsp;lifethreatening:&nbsp;90,&nbsp;crazy:&nbsp;120,&nbsp;plaid:&nbsp;140,&nbsp;tons:&nbsp;1.3,&nbsp;SP:&nbsp;13,&nbsp;armor:&nbsp;3},&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Also Motorcycle is missing a value in SP. Finally, the end of the worker looks like this: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}); &nbsp;&nbsp;&nbsp;&nbsp;)}; )}; It should be &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}); &nbsp;&nbsp;&nbsp;&nbsp;}); }); I'm not sure if that last one was my mistake. Typos are hard to avoid!
I'm very sure those are all my mistakes. No idea how you spotted them. I removed all the spaces turning Compact car into CompactCar and so on. Once I got them all, it started to work. Now it fills in every value (except SP) with a 0. However that's it. Only 9 of the 10 "none" values fill in. Is it because the line- const thisVehicle = vehicles[VehicleType] || vehicles['none']; should be- const thisVehicle = vehicles[VehicleType] || vehicles["none"]; ?
1586721673
GiGs
Pro
Sheet Author
API Scripter
four more mistakes, one of them mine. In your vehicles data, you spell "Compact car", but in the select it is "Compact Car".&nbsp; they have to use identical capitalisation, so change the vehicles entry to "Compact Car". In the setAttrs, you have the line "repeating_vehicles_VehicleSp":&nbsp;thisVehicle.sp, this should be "repeating_vehicles_VehicleSp":&nbsp;thisVehicle.SP, Your select looks like this: &lt;select name="attr_VehicleType"&gt; &lt;option selected&gt;&lt;/option&gt; &lt;option value="1"&gt;Skateboard&lt;/option&gt; &lt;option value="2"&gt;Bicycle&lt;/option&gt; &lt;option value="3"&gt;Moped&lt;/option&gt; &lt;option value="4"&gt;Motorcycle&lt;/option&gt; &lt;option value="5"&gt;Hog&lt;/option&gt; &lt;option value="6"&gt;Compact Car&lt;/option&gt; &lt;option value="7"&gt;Medium Car&lt;/option&gt; &lt;option value="8"&gt;Large SUV&lt;/option&gt; &lt;option value="9"&gt;Van&lt;/option&gt; &lt;option value="10"&gt;Small Truck&lt;/option&gt; &lt;option value="11"&gt;Truck&lt;/option&gt; &lt;option value="12"&gt;Bus&lt;/option&gt; &lt;/select&gt; You set each to a numerical value, but the data in the sheet worker is indexed by the vehicle name, not number. So delete all the Value="x" from those, like so &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb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bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/select&gt; If you dont supply a value, it'll use whatever text you supply as the value. And finally my mistake - something I often forget when dealing with repeating sections. This: &nbsp;const thisVehicle = vehicles[values.VehicleType] || vehicles['none']; should be &nbsp;const thisVehicle = vehicles[values.repeating_vehicles_VehicleType] || vehicles['none']; Putting those right gets the worker working properly. Finally one minor error. This doesnt cause the worker to fail, but doesnt work: you cant use sheet:opened &nbsp;in workers using this repeating section syntax. So your first line should be on("change:repeating_vehicles:vehicletype",&nbsp;function()&nbsp;{ If you change the various vehicle inputs to readonly, players cant edit them, and you dont need sheet:opened &nbsp;anyway. like changing &lt;input type="text" name="attr_VehicleSpeedSafe"&gt; to&nbsp; &lt;input type="number" name="attr_VehicleSpeedSafe" readonly&gt; (I also suggest changing this to a type=number, since it is a number after all.)
1586721796
GiGs
Pro
Sheet Author
API Scripter
I spotted them because I'm using a text editor which shows syntax errors :) I hope my last post answered your question.
I changed 1 value in the none row from a 0 to a 4 just to check,and yes, everything is being treated as if it's none. Oddly, the Skateboard doesn't get an Armor rating. Even a 0.
arg. Case sensitive. Of course. Doh. Thanks.
1586722138
GiGs
Pro
Sheet Author
API Scripter
If you use the select for vehicle type I posted a couple posts back, and this sheet worker, it should be working on("change:repeating_vehicles:vehicletype",&nbsp;function()&nbsp;{&nbsp;&nbsp;&nbsp;//when&nbsp;the&nbsp;VehicleType&nbsp;dropdown&nbsp;changes &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getAttrs(["repeating_vehicles_VehicleType"],&nbsp;function(values)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;//read&nbsp;the&nbsp;value&nbsp;of&nbsp;the&nbsp;selected&nbsp;entry&nbsp;in&nbsp;the&nbsp;VehicleType&nbsp;dropdown &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;vehicles&nbsp;=&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;none:&nbsp;{quick:&nbsp;0,&nbsp;safe:&nbsp;0,&nbsp;risky:&nbsp;0,&nbsp;dangerous:&nbsp;0,&nbsp;lifethreatening:&nbsp;0,&nbsp;crazy:&nbsp;0,&nbsp;plaid:&nbsp;0,&nbsp;tons:&nbsp;0,&nbsp;SP:&nbsp;0,&nbsp;armor:&nbsp;0}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Skateboard:&nbsp;{quick:&nbsp;7,&nbsp;safe:&nbsp;5,&nbsp;risky:&nbsp;10,&nbsp;dangerous:&nbsp;20,&nbsp;lifethreatening:&nbsp;30,&nbsp;crazy:&nbsp;40,&nbsp;plaid:&nbsp;50,&nbsp;tons:&nbsp;0.0001,&nbsp;SP:&nbsp;1,&nbsp;armor:&nbsp;0}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bicycle:&nbsp;{quick:&nbsp;6,&nbsp;safe:&nbsp;15,&nbsp;risky:&nbsp;25,&nbsp;dangerous:&nbsp;40,&nbsp;lifethreatening:&nbsp;50,&nbsp;crazy:&nbsp;70,&nbsp;plaid:&nbsp;80,&nbsp;tons:&nbsp;0.001,&nbsp;SP:&nbsp;2,&nbsp;armor:&nbsp;0}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Moped:&nbsp;{quick:&nbsp;4,&nbsp;safe:&nbsp;20,&nbsp;risky:&nbsp;40,&nbsp;dangerous:&nbsp;50,&nbsp;lifethreatening:&nbsp;70,&nbsp;crazy:&nbsp;100,&nbsp;plaid:&nbsp;1200,&nbsp;tons:&nbsp;0.03,&nbsp;SP:&nbsp;5,&nbsp;armor:&nbsp;1}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Motorcycle:&nbsp;{quick:&nbsp;10,&nbsp;safe:&nbsp;30,&nbsp;risky:&nbsp;50,&nbsp;dangerous:&nbsp;75,&nbsp;lifethreatening:&nbsp;100,&nbsp;crazy:&nbsp;130,&nbsp;plaid:&nbsp;50,&nbsp;tons:&nbsp;0.5,&nbsp;SP:&nbsp;-1,&nbsp;armor:&nbsp;1}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hog:&nbsp;{quick:&nbsp;7,&nbsp;safe:&nbsp;30,&nbsp;risky:&nbsp;60,&nbsp;dangerous:&nbsp;80,&nbsp;lifethreatening:&nbsp;110,&nbsp;crazy:&nbsp;150,&nbsp;plaid:&nbsp;180,&nbsp;tons:&nbsp;0.7,&nbsp;SP:&nbsp;8,&nbsp;armor:&nbsp;1}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Compact&nbsp;Car":&nbsp;{quick:&nbsp;4,&nbsp;safe:&nbsp;30,&nbsp;risky:&nbsp;50,&nbsp;dangerous:&nbsp;70,&nbsp;lifethreatening:&nbsp;90,&nbsp;crazy:&nbsp;120,&nbsp;plaid:&nbsp;140,&nbsp;tons:&nbsp;1.3,&nbsp;SP:&nbsp;13,&nbsp;armor:&nbsp;3}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Medium&nbsp;Car":&nbsp;{quick:&nbsp;6,&nbsp;safe:&nbsp;30,&nbsp;risky:&nbsp;50,&nbsp;dangerous:&nbsp;80,&nbsp;lifethreatening:&nbsp;100,&nbsp;crazy:&nbsp;130,&nbsp;plaid:&nbsp;150,&nbsp;tons:&nbsp;1.5,&nbsp;SP:&nbsp;15,&nbsp;armor:&nbsp;3}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Large&nbsp;SUV":&nbsp;{quick:&nbsp;6,&nbsp;safe:&nbsp;20,&nbsp;risky:&nbsp;50,&nbsp;dangerous:&nbsp;70,&nbsp;lifethreatening:&nbsp;90,&nbsp;crazy:&nbsp;120,&nbsp;plaid:&nbsp;150,&nbsp;tons:&nbsp;2.4,&nbsp;SP:&nbsp;24,&nbsp;armor:&nbsp;4}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Van:&nbsp;{quick:&nbsp;5,&nbsp;safe:&nbsp;30,&nbsp;risky:&nbsp;50,&nbsp;dangerous:&nbsp;70,&nbsp;lifethreatening:&nbsp;100,&nbsp;crazy:&nbsp;120,&nbsp;plaid:&nbsp;140,&nbsp;tons:&nbsp;6,&nbsp;SP:&nbsp;30,&nbsp;armor:&nbsp;3}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"Small&nbsp;Truck":&nbsp;{quick:&nbsp;4,&nbsp;safe:&nbsp;30,&nbsp;risky:&nbsp;50,&nbsp;dangerous:&nbsp;80,&nbsp;lifethreatening:&nbsp;100,&nbsp;crazy:&nbsp;110,&nbsp;plaid:&nbsp;120,&nbsp;tons:&nbsp;12,&nbsp;SP:&nbsp;40,&nbsp;armor:&nbsp;2}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Truck:&nbsp;{quick:&nbsp;3,&nbsp;safe:&nbsp;30,&nbsp;risky:&nbsp;50,&nbsp;dangerous:&nbsp;80,&nbsp;lifethreatening:&nbsp;100,&nbsp;crazy:&nbsp;110,&nbsp;plaid:&nbsp;120,&nbsp;tons:&nbsp;25,&nbsp;SP:&nbsp;60,&nbsp;armor:&nbsp;4}, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Bus:&nbsp;{quick:&nbsp;3,&nbsp;safe:&nbsp;30,&nbsp;risky:&nbsp;50,&nbsp;dangerous:&nbsp;80,&nbsp;lifethreatening:&nbsp;100,&nbsp;crazy:&nbsp;110,&nbsp;plaid:&nbsp;120,&nbsp;tons:&nbsp;17,&nbsp;SP:&nbsp;50,&nbsp;armor:&nbsp;4} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;VehicleType&nbsp;=&nbsp;values.repeating_vehicles_VehicleType;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;thisVehicle&nbsp;=&nbsp;vehicles[VehicleType]&nbsp;||&nbsp;vehicles['none'];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAttrs({ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repeating_vehicles_VehicleQuick":&nbsp;thisVehicle.quick,&nbsp;&nbsp;&nbsp;//pass&nbsp;VehicleTypeValue&nbsp;into&nbsp;VehicleSpeedSafe &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repeating_vehicles_VehicleSpeedSafe":&nbsp;thisVehicle.safe, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repeating_vehicles_VehicleSpeedRisky":&nbsp;thisVehicle.risky, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repeating_vehicles_VehicleSpeedDangerous":&nbsp;thisVehicle.dangerous, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repeating_vehicles_VehicleSpeedLifeThreatening":&nbsp;thisVehicle.lifethreatening, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repeating_vehicles_VehicleSpeedCrazy":&nbsp;thisVehicle.crazy, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repeating_vehicles_VehicleSpeedPlaid":&nbsp;thisVehicle.plaid, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repeating_vehicles_VehicleWeight":&nbsp;thisVehicle.tons, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repeating_vehicles_VehicleSp":&nbsp;thisVehicle.SP, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repeating_vehicles_VehicleArmor":&nbsp;thisVehicle.armor &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}); &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}); &nbsp;&nbsp;&nbsp;&nbsp;}); Note: this data has a -1 value for the SP of motorcycle because I dont know what it should be, but i needed to put in a value to make it work. I'm not sure why armor wouldnt show for the skateboard.
It's alive. ALIVE! Thanks GiGs. So kind. Now I can do the same for weapons and armor and all other fun things.
1586722503
GiGs
Pro
Sheet Author
API Scripter
Yay :) the most frustrating thing of coding in javascript is the massive amount of syntax errors we all inevitably create. :)
1586746832

Edited 1586748511
Can a value in the large data const be a negative one? I have weapons that are small enough to force a -1 or more on spot checks to find them. It's called "Conceal", and applies to all weapons. Some give you a bonus to spot them (crossbows are hard to hide) and others are easier. I think I've replicated the working sheetworker properly, but it's only half working. The dropdown works, but the fields don't propagate. Here's the code for the repeater- &lt;fieldset class="repeating_rangedWeapons"&gt; &lt;table width="100%"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th width="35%"&gt;Weapon4&lt;/th&gt; &lt;th width="13%"&gt;Rating&lt;/th&gt; &lt;th width="8%"&gt;Ammo&lt;/th&gt; &lt;th width="8%"&gt;RoF&lt;/th&gt; &lt;th width="8%"&gt;Conceal&lt;/th&gt; &lt;th width="20%"&gt;Damage (D/C/B/A)&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="35%"&gt; &lt;select name="attr_RangedWeaponType"&gt; &lt;option selected&gt;&lt;/option&gt; &lt;option &gt;Derringer&lt;/option&gt; &lt;option &gt;Revolver&lt;/option&gt; &lt;option &gt;Semi_Auto&lt;/option&gt; &lt;option &gt;Heavy_Pistol&lt;/option&gt; &lt;option &gt;Hungting_Rifle&lt;/option&gt; &lt;option &gt;Shotgun&lt;/option&gt; &lt;option &gt;Shotgun_solid_slugs&lt;/option&gt; &lt;option &gt;Assult_Rifle&lt;/option&gt; &lt;option &gt;LMG&lt;/option&gt; &lt;option &gt;HMG&lt;/option&gt; &lt;option &gt;Taser&lt;/option&gt; &lt;option &gt;Crossbow&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;td width="13%"&gt; &lt;input type="number" name="attr_RangedWeaponRating"&gt; &lt;button type="roll" title="Roll to hit" value="!continuum @{Weapon}|@{WeaponRating}|[[ ?{Modifiers not including IP|0} - @{IPTOTal}]]||combat"&gt;&lt;/button&gt; &lt;/td&gt; &lt;td width="8%"&gt;&lt;input type="number" name="attr_RangedAmmo" min="0"&gt;&lt;/td&gt; &lt;td width="8%"&gt;&lt;input type="number" name="attr_RangedRoF" min="0"&gt;&lt;/td&gt; &lt;td width="8%"&gt;&lt;input type="number" name="attr_RangedConceal"&gt;&lt;/td&gt; &lt;td width="5%"&gt;&lt;input type="text" name="attr_RangedDamageD"&gt;&lt;/td&gt; &lt;td width="5%"&gt;&lt;input type="text" name="attr_RangedDamageC"&gt;&lt;/td&gt; &lt;td width="5%"&gt;&lt;input type="text" name="attr_RangedDamageB"&gt;&lt;/td&gt; &lt;td width="5%"&gt;&lt;input type="text" name="attr_RangedDamageA"&gt;&lt;/td&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;/fieldset&gt; and here's the worker- on("change:repeating_rangedWeapons:rangedweapontype", function() { //when the WeaponType dropdown changes getAttrs(["repeating_rangedweapons_RangedWeaponType"], function(values) { //read the value of the selected entry in the WeaponType dropdown const rangedWeapons = { none: {rangedammo: 0, rangedrof: 0, rangedconceal: 0, rangeddamaged: 0, rangeddamagec: 0, rangeddamageb: 0, rangeddamagea: 0}, Derringer: {rangedammo: 2, rangedrof: 1, rangedconceal: -4, rangeddamaged: 1, rangeddamagec: 1, rangeddamageb: 2, rangeddamagea: 3}, Revolver: {rangedammo: 6, rangedrof: 1, rangedconceal: -2, rangeddamaged: 1, rangeddamagec: 2, rangeddamageb: 3, rangeddamagea: 4}, Semi_Auto: {rangedammo: 15, rangedrof: 2, rangedconceal: -2, rangeddamaged: 1, rangeddamagec: 2, rangeddamageb: 3, rangeddamagea: 4}, Heavy_Pistol: {rangedammo: 12, rangedrof: 1, rangedconceal: 0, rangeddamaged: 2, rangeddamagec: 4, rangeddamageb: 6, rangeddamagea: 8}, Hungting_Rifle: {rangedammo: 8, rangedrof: 1, rangedconceal: 6, rangeddamaged: 2, rangeddamagec: 4, rangeddamageb: 6, rangeddamagea: 9}, Shotgun: {rangedammo: 8, rangedrof: 1, rangedconceal: 4, rangeddamaged: 1, rangeddamagec: 3, rangeddamageb: 5, rangeddamagea: 7}, Shotgun_solid_slugs: {rangedammo: 8, rangedrof: 1, rangedconceal: 4, rangeddamaged: 2, rangeddamagec: 5, rangeddamageb: 7, rangeddamagea: 10}, Assult_Rifle: {rangedammo: 40, rangedrof: 5, rangedconceal: 0, rangeddamaged: 2, rangeddamagec: 3, rangeddamageb: 5, rangeddamagea: 7}, SMG: {rangedammo: 30, rangedrof: 3, rangedconceal: 0, rangeddamaged: 1, rangeddamagec: 3, rangeddamageb: 4, rangeddamagea: 6}, LMG: {rangedammo: 100, rangedrof: 10, rangedconceal: 4, rangeddamaged: 2, rangeddamagec: 4, rangeddamageb: 6, rangeddamagea: 8}, HMG: {rangedammo: 100, rangedrof: 10, rangedconceal: 6, rangeddamaged: 3, rangeddamagec: 5, rangeddamageb: 7, rangeddamagea: 10}, Taser: {rangedammo: 2, rangedrof: 1, rangedconceal: -1, rangeddamaged: 1, rangeddamagec: 1, rangeddamageb: 2, rangeddamagea: 4}, Crossbow: {rangedammo: 1, rangedrof: 1, rangedconceal: 6, rangeddamaged: 1, rangeddamagec: 2, rangeddamageb: 5, rangeddamagea: 7} }; const RangedWeaponType = values.RangedWeaponType; //make a temp variable called "RangedWeaponTypeValue" and store the value of RangedWeaponType in it. If not selected, 0 const thisRangedWeapon = rangedweapons[values.repeating_rangedweapons_RangedWeaponType] || rangedweapons['none']; setAttrs({ "repeating_rangedWeapons_RangedAmmo": thisRangedWeapon.rangedammo, //pass VehicleTypeValue into VehicleSpeedSafe "repeating_rangedWeapons_RangedRoF": thisRangedWeapon.rangedrof, "repeating_rangedWeapons_RangedConceal": thisRangedWeapon.rangedconceal, "repeating_rangedWeapons_RangedDamageD": thisRangedWeapon.rangeddamaged, "repeating_rangedWeapons_RangedDamageC": thisRangedWeapon.rangeddamagec, "repeating_rangedWeapons_RangedDamageB": thisRangedWeapon.rangeddamageb, "repeating_rangedWeapons_RangedDamageA": thisRangedWeapon.rangeddamagea }); }); }); I assume I've messed up a variable or something.
1586766087
GiGs
Pro
Sheet Author
API Scripter
There is a fairly important typo const&nbsp;thisRangedWeapon&nbsp;=&nbsp;rangedweapons shouldbe const&nbsp;thisRangedWeapon&nbsp;=&nbsp;rangedWeapons One other thing: your field section is called &lt;fieldset class="repeating_rangedWeapons"&gt; You should absolutely avoid capital letters in the class name of repeating sections. This causes subtle problems with buttons and scripts targeting that repeating section, so this should be &lt;fieldset class="repeating_rangedweapons"&gt;
Bloody hell that's subtle. How do you coders keep track of all the rules? Thanks again GiGs. I was pulling out my balding hair. Mostly I think because the first one you helped me with didn't have 2 words in either of those sections, so I went with what felt right. So you can see my mistake. Never trust my feelings where code is concerned.
1586776373
GiGs
Pro
Sheet Author
API Scripter
Some of the rules become second nature, and we constantly forget others and are tripping over them and then facepalming when we remember them again...&nbsp;
That worked. Thanks. I'm now further along the path to making this work in other places in the sheet.