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

Dynamic table in a roll template

February 09 (4 years ago)
Peter B.
Plus
Sheet Author

Hello Roll20.

Is it possible in some way to add a dynamic table to a roll template?

I want to be able to post a table with a different amount of rows and columns based on some underlying data.

Sometimes there might be 3 columns:

Some times it might just be two columns:

I have tried to directly insert HTML into a field and then print it with a roll template, but the HTML elements are all removed, as I expected.

So are there some helper function or something like it that allows for multiple iterations, forloops or anything of the likes where something is generated based on all the data?

February 09 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter


Peter B. said:

Sometimes there might be 3 columns:

Some times it might just be two columns:

Both of your pics seem to have two columns, with a section with just one column, so it's not clear what exactly you are asking.

Yes, you can change the layout of whatever goes into a rolltemplate, but you need to code the html in your rolltemplate, and add some css to support it.

There are numerous rolltemplate helpers you can use to interpret data, as longas the data is numeric.

You cant do pure loops or calculations within a rolltemplate, but it is possible to handle all data supplied (look at the allprops property).

I'd love to be more specific, but you need to describe exactly what you want to achieve, including the specific data and specific logic tests you see being needed.

February 09 (4 years ago)
Kraynic
Pro
Sheet Author


GiGs said:


Both of your pics seem to have two columns, with a section with just one column, so it's not clear what exactly you are asking.

I think that is speaking of the description area in the bottom section of the template.  The only way I could think of would be to have different roll template sections with different columns.  Like a description without columns, description2 with 2 columns, and description3 with 3 columns, probably followed by a notes section to have another bit below all that with no columns to finish off any explanatory text at the end.


February 09 (4 years ago)
Peter B.
Plus
Sheet Author

Kraynic said:

I think that is speaking of the description area in the bottom section of the template.  The only way I could think of would be to have different roll template sections with different columns.  Like a description without columns, description2 with 2 columns, and description3 with 3 columns, probably followed by a notes section to have another bit below all that with no columns to finish off any explanatory text at the end.

You are exactly right. It is the description / Effect part of the roll template I am looking for. 

As I do not know before hand which template to use (description2, description3, and so on) before selecting the template, I would like something generic that would generate the correct content based on the data.

February 09 (4 years ago)
Peter B.
Plus
Sheet Author

GiGs said:

There are numerous rolltemplate helpers you can use to interpret data, as longas the data is numeric.

Do you have a link to those helpers? I have been unable to find them

February 09 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter


Peter B. said:

GiGs said:

There are numerous rolltemplate helpers you can use to interpret data, as longas the data is numeric.

Do you have a link to those helpers? I have been unable to find them

Here you go: https://wiki.roll20.net/Building_Character_Sheets/Roll_Templates#Helper_Functions



February 09 (4 years ago)
Peter B.
Plus
Sheet Author

Hmm thinking about it, I think that the easiest, most straight forward solution is just to make some attributes like column1, column2 and so on.

February 10 (4 years ago)
Peter B.
Plus
Sheet Author

So I just realized that I can actually add any amount of prorperties from a field to a roll template as long as the field follows the same syntax

So an example of this would be, a field called attr_addition-template-info, if this field has the value: {{col1=Hello}}{{col2=Horse}}{{col3=fish}}

and I then call my template like normally, but add the attribute in the end:

<button type="roll" name="roll_template" value="&{template:default}{{title=Some title}}@{additional-tempalte-info}">Roll Template</button>
                                                                                                 ↑   ↑  ↑   ↑ 

Now the output looks like this in the chat:

OBS: After testing this does only seem to work from within a button. If I try to add the value of the button directly to the chat, then I get the following error:


February 10 (4 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

In chat, it doesn't know which sheet to reference. You would need to write that section as something like:

@{charactername|additional-tempalte-info}
@{selected|additional-tempalte-info}

or

@{target|additional-tempalte-info}
February 11 (4 years ago)
Peter B.
Plus
Sheet Author

keithcurtis said:

In chat, it doesn't know which sheet to reference. You would need to write that section as something like:

@{charactername|additional-tempalte-info}
@{selected|additional-tempalte-info}

or

@{target|additional-tempalte-info}

You are completely right.

I totally forgot in the heat of the moment :)


February 11 (4 years ago)


Peter B. said:

Hello Roll20.

Is it possible in some way to add a dynamic table to a roll template?

I want to be able to post a table with a different amount of rows and columns based on some underlying data.

Sometimes there might be 3 columns:

Some times it might just be two columns:

I have tried to directly insert HTML into a field and then print it with a roll template, but the HTML elements are all removed, as I expected.

So are there some helper function or something like it that allows for multiple iterations, forloops or anything of the likes where something is generated based on all the data?


It’s much easier just to automate the spell. I have an automatic version if you like.

February 12 (4 years ago)
Peter B.
Plus
Sheet Author

Gargamond said:

It’s much easier just to automate the spell. I have an automatic version if you like.

I am very much intrigued. Please let me know more. What do you mean "automate" and how d you do it?