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

Help with WEG Star Wars D6 Sheet Workers

I'm creating a modified version of the Star Wars WEG D6 sheet because I want to be able to tweak the formatting some and total up the skill points being spent and track them. I have only the most flimsy understanding of how sheet workers operate, and this doesn't seem to be working at all--can anyone help me sort out what I'm doing wrong? This code defines DEX-based attributes: <!---Dex Attribute ---> <div class="tdborder"> <div class="bold"> <button name="roll_dex" class="d6-dice rollmod" type="roll" value="&{template:blue} {{name=@{character_name}: Dexterity}} {{Roll=[[(@{dexterity} -@{WoundMod} +@{Force_Up} + ?{Dice mods|0} -1)d6cf0cs7 + @{dexteritypip} + ?{Other Mods(pip)|0} + 1d6@{wilddie}]]}}" >Dexterity</button> <button name="roll_dex-w" class="d6-dice rollmod gmroll gmroll-hide" type="roll" value="/w gm &{template:blue} {{name=@{character_name}: Dexterity}} {{Roll=[[(@{dexterity} -@{WoundMod} +@{Force_Up} + ?{Dice mods|0} -1)d6cf0cs7 + @{dexteritypip} + ?{Other Mods(pip)|0} + 1d6@{wilddie}]]}}" ><span class="redtxt">GM</span></button> <button name="roll_dex_n" class="d6-dice rollmod-no" type="roll" value="&{template:blue} {{name=@{character_name}: Dexterity}} {{Roll=[[(@{dexterity} -@{WoundMod} +@{Force_Up} -1)d6cf0cs7 + @{dexteritypip} + 1d6@{wilddie}]]}}" >Dexterity</button> <button name="roll_dex_n-w" class="d6-dice rollmod-no gmroll gmroll-hide" type="roll" value="/w gm &{template:blue} {{name=@{character_name}: Dexterity}} {{Roll=[[(@{dexterity} -@{WoundMod} +@{Force_Up} -1)d6cf0cs7 + @{dexteritypip} + 1d6@{wilddie}]]}}" ><span class="redtxt">GM</span></button> <div style="float:right;"> <input type="number" name="attr_dexterity" class="smallnumber" min="1" value="3"/>D+<input type="number" name="attr_dexteritypip" class="pipnumber" min="0" max="2" value="0"/> </div> </div> <fieldset class="repeating_dexskills"> <!---Dex Skills ---> <button name="roll_dexskill" class="d6-dice rollmod" type="roll" value="&{template:blue} {{name=@{character_name}: @{dexskillname}}} {{Roll=[[(@{dexskilldice} -@{WoundMod} +@{Force_Up} + ?{Dice mods|0} -1)d6cf0cs7 + @{dexskillpip} + ?{Other Mods(pip)|0} + 1d6@{wilddie}]]}}"></button> <button name="roll_dexskill-w" class="d6-dice rollmod gmroll gmroll-hide" type="roll" value="/w gm &{template:blue} {{name=@{character_name}: @{dexskillname}}} {{Roll=[[(@{dexskilldice} -@{WoundMod} +@{Force_Up} + ?{Dice mods|0} -1)d6cf0cs7 + @{dexskillpip} + ?{Other Mods(pip)|0} + 1d6@{wilddie}]]}}"><span class="redtxt">GM</span></button> <button name="roll_dexskill_n" class="d6-dice rollmod-no" type="roll" value="&{template:blue} {{name=@{character_name}: @{dexskillname}}} {{Roll=[[(@{dexskilldice} -@{WoundMod} +@{Force_Up} -1)d6cf0cs7 + @{dexskillpip} + 1d6@{wilddie}]]}}"></button> <button name="roll_dexskill_n-w" class="d6-dice rollmod-no gmroll gmroll-hide" type="roll" value="/w gm &{template:blue} {{name=@{character_name}: @{dexskillname}}} {{Roll=[[(@{dexskilldice} -@{WoundMod} +@{Force_Up} -1)d6cf0cs7 + @{dexskillpip} + 1d6@{wilddie}]]}}"><span class="redtxt">GM</span></button> <input class="skilltext" type="text" name="attr_dexskillname" style="width:150px"/> <div class="right"> <input type="number" name="attr_dexskilldice" class="smallnumber shortnumber" min="1" value="3"/>D+<input type="number" name="attr_dexskillpip" class="pipnumber shortnumber" min="0" max="2" value="0"/> <input type="hidden" name="attr_dexskillpipnum" value="(@{dexskillpip}-@{dexteritypip})" disabled/> </div> </fieldset> </div> This is the sheet worker designed to total up the DEX-based skill dice (but not the pips, which I plan to total separately). It's supposed to track how many more dice the character has in each skill than they have in their base DEX, then total up how many dice they have spent on DEX-based skills. on("change:repeating_dexskills:dexskilldice change:dexterity remove:repeating_dexskills", function() { getAttrs(['repeating_dexskills_dexskilldice','dexterity'], function(values) { var base = +values.dexterity || 0; var level = +values.repeating_dexskills_dexskilldice || 0; var total = level - base; setAttrs({ repeating_dexskills_dexskillcost: total }); }); }); on("change:repeating_dexskills:dexskillcost remove:repeating_dexskills", function() { getSectionIDs("repeating_dexskills", function(IDArray) { let fieldNames = []; for (var i=0; i < IDArray.length; i++) { fieldNames.push("repeating_dexskills_" + IDArray[i] + "_dexskillcost"); } let total = 0; getAttrs(fieldNames, function(values) { for (var i=0; i < IDArray.length; i++) { total += parseInt(values["repeating_dexskills_" + IDArray[i] + "_dexskillcost"])||0; } setAttrs({ dexskilldicetotal:total }); }); }); }); This is then output to: <input type="text" name="attr_dexskilldicetotal" style="width:50px" value="0" readonly/> At present, it's just not totaling at all, and the output shows as 0. Anyone have any ideas? Thanks!
1590501725
GiGs
Pro
Sheet Author
API Scripter
I soent a bit of time writing up a reply to your previous post, but got an error when trying to submit saying post has been closed. So I'll keep this short in case it happens again. Your sheet worker (if it hasnt changed since the last post_ is working. You have two problems that conceal this fact: 1) your first sheet worker tries to assign cost to  repeating_dexskills_dexskillcost , but that doesnt exist in the fieldset so you cant see it. Create it, make it type number and you'll see it, 2) also in your first sheet worker, you are using two incompatbile syntaxes. You cant use this syntax  repeating_dexskills_dexskilldice  with this:  change:dexterity . Wen using that repeating section syntax, roll20 supplies a row id, and it obnly works if the change is being triggered from inside the repeating syntax. When you use change:dexterity  and want to affect a repeating section, roll20 doesnt know what row to affect, so you have to use getSectionIDs.   
1590501891
GiGs
Pro
Sheet Author
API Scripter
There's no need to have those two workers separate. You can combine them, and also combine the pips calculation at the same time. Here's a sheet worker that does that (and dispenses with the need for a cost stat within the fieldset): on('change:dexterity change:dexskillpip change:repeating_dexskills:dexskilldice change:repeating_dexskills:dexskillpips remove:repeating_dexskills', function() {         getSectionIDs('repeating_dexskills', function(IDArray) {             let fieldNames = [];             IDArray.forEach(id => {                 fieldNames.push(                     'repeating_dexskills_' + id + '_dexskilldice',                     'repeating_dexskills_' + id + '_dexskillpips'                 );             });                          let totalDice = 0, totalPips = 0;             getAttrs([...fieldNames, 'dexskillpip', 'dexterity'], function(values) {                 log(values);                 const baseDice = parseInt(values['dexterity']) || 0;                 const basePips = parseInt(values['dexskillpips']) || 0;                 IDArray.forEach(id => {                     const thisDice = parseInt(values['repeating_dexskills_' + id + '_dexskilldice'])||0;                     const thisPips = parseInt(values['repeating_dexskills_' + id + '_dexskillpips'])||0;                     totalDice += Math.max(0, thisDice - baseDice);                     totalPips += (thisPips - basePips);                 });                 const total = totalDice * 3 + totalPips;                 setAttrs({                     dexskillstotal:total                 });             });         });     }); Notice is changed to for loops to forEach loops, because i find them simpler. In this worker, i give an example calculation: tripling skill dice and adding single pips, and saving that to a cost attribute. Your cost scheme might not work that way, but hopefully this will show you the way.
1590502043
GiGs
Pro
Sheet Author
API Scripter
If you tell me the ttaribute names for the other stats, and their pip stat names (for dexterity, we have 'dexskillpip' and 'dexterity'), I'll show you how to calculate all the stats with a single sheet worker. (See Universal Sheet Workers for the concept I'll use).
1590502648

Edited 1590502806
Andreas J.
Forum Champion
Sheet Author
Translator
The sheet has a section to track spent character points and it sums things up, maybe you could modify it to suit your needs? You could use that section as a template for creating a separate tracker for each attribute's skills. It's using RepeatSum sheet worker example to sum up things. HTML: <a href="https://github.com/Roll20/roll20-character-sheets/blob/6a353db127d4db0f57285ae6d2aaea1e5bab1e33/D6StarWars/D6StarWars.html#L656" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/blob/6a353db127d4db0f57285ae6d2aaea1e5bab1e33/D6StarWars/D6StarWars.html#L656</a> Sheetworker: <a href="https://github.com/Roll20/roll20-character-sheets/blob/6a353db127d4db0f57285ae6d2aaea1e5bab1e33/D6StarWars/D6StarWars.html#L897" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/blob/6a353db127d4db0f57285ae6d2aaea1e5bab1e33/D6StarWars/D6StarWars.html#L897</a> BTW, I'm the author of the sheet.
1590502749
GiGs
Pro
Sheet Author
API Scripter
That does seem like it would be a lot simpler!
1590537141

Edited 1590537636
Dave
Pro
Sorry about this. I had an error and messed up with the post, then deleted it by mistake. (This is why I shouldn't try to make forum posts after being up all night wrestling with a code issue.) My bad on that. :/ GiGs said: I soent a bit of time writing up a reply to your previous post, but got an error when trying to submit saying post has been closed. So I'll keep this short in case it happens again. Your sheet worker (if it hasnt changed since the last post_ is working. You have two problems that conceal this fact: 1) your first sheet worker tries to assign cost to&nbsp; repeating_dexskills_dexskillcost , but that doesnt exist in the fieldset so you cant see it. Create it, make it type number and you'll see it, 2) also in your first sheet worker, you are using two incompatbile syntaxes. You cant use this syntax&nbsp; repeating_dexskills_dexskilldice &nbsp;with this:&nbsp; change:dexterity . Wen using that repeating section syntax, roll20 supplies a row id, and it obnly works if the change is being triggered from inside the repeating syntax. When you use change:dexterity &nbsp;and want to affect a repeating section, roll20 doesnt know what row to affect, so you have to use getSectionIDs. I'll look over that code you shared and try to learn from it. Thank you! Andreas J. said: The sheet has a section to track spent character points and it sums things up, maybe you could modify it to suit your needs? You could use that section as a template for creating a separate tracker for each attribute's skills. It's using RepeatSum sheet worker example to sum up things. HTML: <a href="https://github.com/Roll20/roll20-character-sheets/blob/6a353db127d4db0f57285ae6d2aaea1e5bab1e33/D6StarWars/D6StarWars.html#L656" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/blob/6a353db127d4db0f57285ae6d2aaea1e5bab1e33/D6StarWars/D6StarWars.html#L656</a> Sheetworker: <a href="https://github.com/Roll20/roll20-character-sheets/blob/6a353db127d4db0f57285ae6d2aaea1e5bab1e33/D6StarWars/D6StarWars.html#L897" rel="nofollow">https://github.com/Roll20/roll20-character-sheets/blob/6a353db127d4db0f57285ae6d2aaea1e5bab1e33/D6StarWars/D6StarWars.html#L897</a> BTW, I'm the author of the sheet. Well, first of all, let me say that you've created an awesome sheet! The only issue I had with the built-in tracker is that I couldn't understand how to make it work. It seems to output nothing when I activate it from the character sheet menu. Edit: I understand, now, where I was confused. This comes from a *cough*-decade old confusion of mine that's apparently resurfaced where I get the names of things wrong in this system. Please ignore that previous part.
As usual, I seem to be getting in over my head, here. I don't understand the code for the sheetworker to track character points at all, which is entirely the fault of my own lack of knowledge and no criticism whatsoever of the sheet code. I'll try working with GiGs' code and see what I can come up with. Thank you both, and I'm sorry for so much bumbling on my part today.
1590538174
GiGs
Pro
Sheet Author
API Scripter
Do you need to understand the code on the character sheet? What do you want to do exact;y? Andreas says the sheet calculates character points already. If that's not working for you, I'm sure he'll want to figure out why and help you get it sorted. If you describe exactly what you're trying to achieve - your final goal - we can better help you achieve it.
1590538902

Edited 1590538930
Dave
Pro
Okay, so the problem is that I've been conflating "character points" (a character creation term from another system) with "starting skill dice." What I actually want to track is the number of skill dice a player has allocated on their sheet to make sure that the sheet balances at character creation without having to count dice and pips. Character points in this system are a different thing, more of a currency that can be used after character creation.
To break it up more clearly, for anyone less familiar with the system: Each attribute gets a number of dice/pips allocated to it. Each die can be broken up into three "pips." Skill dice (and pips) are added "on top" of the attribute dice, so that if a character has a Dexterity of 3 and spends 2 skill dice on the "Blaster" skill, they then have a Blaster skill of 5 for that cost of 2 skill dice. I want to quickly track how many skill dice/pips a player has built into the character sheet so I can tell if they balance properly at character creation.
1590571688

Edited 1590571703
Dave
Pro
I couldn't quite make such sophisticated sheet workers do what I wanted, but I took a step back and looked at the sheet as a whole, then I worked out a way to do what I wanted with a fresh approach. Using Andreas J. 's nicely set up toggles for displaying certain rolls, I adapted one to toggle input fields--so you now go to "edit mode" and you enter the amount of dice to be added to the skill, then shift to "play" mode and it shows the totals. It tracks the total dice and pips, as well as now tracking specializations, and it works exactly as I wanted it to for my group's particular needs. Thanks for the help, guys!
1590573091
GiGs
Pro
Sheet Author
API Scripter
That's great! Since you're a pro user, I was wondering if it might be better to do this as a script. Otherwise you have to choose between misisng out on any updates to the sheet, or having to re-add your code every time the sheet updates. Admittedly this is only an issue if the sheet has frequent updates, which probably isnt the case.
1590574281
Andreas J.
Forum Champion
Sheet Author
Translator
Dave said: I adapted one to toggle input fields--so you now go to "edit mode" and you enter the amount of dice to be added to the skill, then shift to "play" mode and it shows the totals. It tracks the total dice and pips, as well as now tracking specializations, and it works exactly as I wanted it to for my group's particular needs. Would you mind sharing the sheet code for what you did? It sounds like something that could be incorporated into the existing sheet, so everybody could enjoy this optional feature! And if you have any other improvements you're considering making, it would be great if they could also be included in the live Roll20 sheet. There is an update for the ship section that's I've left hanging, so you'd have to manually update and combine the code if you want it with your version when it's eventually done. I have a test campaign set up for it, and I could show you the current version if you're interested. Might finish it sometime late summer, but no idea. You're also more than welcome to take a look at the WIP ship update or to make one yourself, I'd be delighted if someone else would also improve the sheet! GiGs said: Admittedly this is only an issue if the sheet has frequent updates, which probably isnt the case. I do lots of sheet stuff, but I haven't done much updates on this one, but was kinda planning on updating and refactoring it eventually, when I run out of work and paid commissions this summer. It's the first sheet I started working on, but I haven't given it much attention or updates in the last year when I've improved a ton when it comes to these things.
1590574762
GiGs
Pro
Sheet Author
API Scripter
Andreas J. said: I do lots of sheet stuff, but I haven't done much updates on this one, but was kinda planning on updating and refactoring it eventually, when I run out of work and paid commissions this summer. It's the first sheet I started working on, but I haven't given it much attention or updates in the last year when I've improved a ton when it comes to these things. Cool. I know the feeling. I want to upgrade the first sheet i designed when i get the time (maybe one day...), fortunately not on the repo so no-one has to see what a mess it is, hehe.
1590581043

Edited 1590581849
Dave
Pro
Andreas J. said: Would you mind sharing the sheet code for what you did? It sounds like something that could be incorporated into the existing sheet, so everybody could enjoy this optional feature! And if you have any other improvements you're considering making, it would be great if they could also be included in the live Roll20 sheet. There is an update for the ship section that's I've left hanging, so you'd have to manually update and combine the code if you want it with your version when it's eventually done. I have a test campaign set up for it, and I could show you the current version if you're interested. Might finish it sometime late summer, but no idea. You're also more than welcome to take a look at the WIP ship update or to make one yourself, I'd be delighted if someone else would also improve the sheet! I'm happy to share what little I've done in case it's useful! Here's what I'm using in my own game right now: <a href="https://pastebin.com/8JLqegdZ" rel="nofollow">https://pastebin.com/8JLqegdZ</a> Edit: Of course, now that I've posted it I'm seeing all the errors in what I added--but, oh well, I'm sure you'll see the important bits. ;)