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 variable number of dice

September 29 (6 years ago)

So I've been working on a custom sheet for my game using the Panic at the Dojo system (as a side tangent, it's inspired by Ranma 1/2). However, I've run into an issue: being able to put a variable number of dice on the sheet and have it work correctly.

To expand on this, Panic at the Dojo has you select Forms and Styles. The thing is, each Form has different dice, and some have more (but usually smaller) dice than others. For example, the Power Form has two d10s and a d4, while the Shadow Form has six d4's. And then there's the Zen Form which gives you a fixed array of 7 5 3 1. Each dice result can be used to power an action (which is granted by Forms and Styles, and there're also basic actions everyone has). For example, with a result spread of 9 4 1, I could put the 9 into the Damage basic action to inflict a strong hit of 5 damage which pushes the target 3 spaces, the 4 into the Suppression action granted by the Control Form to move 1 space and gain a token which can be spent to negate an opponent's action, and the 1 into the Beacon action granted by the Shining Style to pull an ally up to 3 spaces and heal yourself and the ally by 1. The higher the dice, the more powerful a result you can get on an action.

Now, part of the problem? Each character has 3 Forms, thus three different sets of dice (and 3 Styles, but that doesn't present any problem). I tried copying something from the basic Savage World sheet linked as an example on the Roll20 wiki entry on building character sheets, but that didn't work very well. So, here's what I want: something that'll let players add as many dice to each different Form as necessary and set them to the right dice sizes (or fixed results for the Zen Form). And then I'd like to create a button which lets them click it to roll all of that Form's dice at once.

Here's the character sheet HTML

And here's the character sheet CSS

The issue with that sheet code is that adding a dice in one column also adds a dice in every other column and deleting a dice deletes a dice from every column. So I'm clearly taking the wrong approach, but I don't know how to do it.

September 29 (6 years ago)
GiGs
Pro
Sheet Author
API Scripter

what you need:

something that'll let players add as many dice to each different Form as necessary and set them to the right dice sizes (or fixed results for the Zen Form). And then I'd like to create a button which lets them click it to roll all of that Form's dice at once.

I dont have the patience to look through your entire sheet to figure out exactly what is needed, but it doesnt sound too tricky. 

For each form, you need an input to select the number of dice (for example, named attr_formNumDice), and a dropdown to select the die type (eg attr_formDieType). And a button to roll appropriately, something like "/roll @{formNumDice}d{@formDieType}"






September 29 (6 years ago)
I appreciate the suggestion, but that solution appears to set all of a form's dice to the same size, when a form's dice will usually vary (like d10 d8 d6). What I need is something that'll let me set a number of dice and the size for each individual dice. However, I'll see if I can figure something out using the tip you gave me.
September 29 (6 years ago)

I just had a thought for a simple and hacky solution, which is providing six dropdowns for dice for each form and including N/A or something as an option.

September 29 (6 years ago)

Edited September 29 (6 years ago)
GiGs
Pro
Sheet Author
API Scripter

Ah I didnt realise they coould be different sizes. 

There are two ways I can think of doing this:

1. Text Field

Provide a textarea/input field, and allow people to write in a dice string ("1d6 1d8 2d4") or whatever. Not pretty, prone to error, but simple.

2. Repeating Set

Using a repeating field set for each form: allow people to add dice using the Add/Delete button.

You'd use a hidden attribute outside the repeating section, and a sheet worker to iterate through the set, build a dice string, and store it in that hidden attribute.

Then the button rolls the dice string.

Edit: Your own suggestion

Having a dropdown for the number of each die type is a lot simpler than using repeating set. The dropdown could display 0 or N/A and have a value of 0 or od0, which would make the dice roll work properly.


September 29 (6 years ago)
Quick question, is there a way to definite a template for an option dropdown and then reference that template? Because C&Ping the same dropdown code eighteen times just doesn't seem elegant at all.
September 29 (6 years ago)

And thanks for the help you've already given by the way!

September 29 (6 years ago)
GiGs
Pro
Sheet Author
API Scripter

do you mean template within the html editor, to speed up copying and pasting stuff?

I'm pretty sure various html creation softwaree includes this functionality, but you'd need to learn how to use it and write your html outside of roll20. In the basic roll20 editor, you are stuck copying and pasting.

September 29 (6 years ago)
I just wanted to make my sheet code a little less repetitive, but if that's my only option, I'll do it.
September 29 (6 years ago)
GiGs
Pro
Sheet Author
API Scripter

Unfortunately the limitations of html force a lot of copy and pasting.

September 29 (6 years ago)

Okay, copying and pasting it is then.