Difference between revisions of "Sheet Author Tips"
From Roll20 Wiki
Andreas J. (Talk | contribs) m (Regex example) |
Andreas J. (Talk | contribs) m (→Sheet Changelog and notification) |
||
Line 197: | Line 197: | ||
{{repo|shdwjk/TheAaronSheet TheAaronSheet}} contains a number of helpful sheetworker functions like simplifying repeating sections, but it also has a improved debugging settings that can help making various dev console messages more distinct. | {{repo|shdwjk/TheAaronSheet TheAaronSheet}} contains a number of helpful sheetworker functions like simplifying repeating sections, but it also has a improved debugging settings that can help making various dev console messages more distinct. | ||
− | === | + | ===Changelog and Update Notification inside Sheet=== |
[[File:GURPS-sheet-update-notice.png|right|thumb|350px|The GURPS sheet displaying the latest sheet update notice.]] | [[File:GURPS-sheet-update-notice.png|right|thumb|350px|The GURPS sheet displaying the latest sheet update notice.]] | ||
− | If you a lots of changes to a sheet, or want to make sure that | + | If you a lots of changes to a sheet, or want to make sure that all users of the sheet are informed of the updates, you could integrate the sheet changelog & notification into the sheet, so next time they open a sheet their sheet they seem the update notice, & can dismiss them at will. |
− | The team behind the [[GURPS]] character sheet is | + | Alternatively, the changelog could be placed on a separate tab, such as folded it into the '''Settings'''-tab |
− | + | ||
+ | The team behind the [[GURPS]] character sheet is a great example of incorporating a comprehensive changelog into the sheet, with a collapsible notice of the latest update/message from the sheet authors, and is non-obstructive even when not dismissed. | ||
+ | * {{repo|Roll20/roll20-character-sheets/tree/master/GURPS GURPS 4E sourcecode}} | ||
<br> | <br> | ||
<br> | <br> | ||
<br> | <br> | ||
<br> | <br> | ||
+ | |||
=== Documentation === | === Documentation === | ||
The '''"Instructions"'''-section of the <code>sheet.json</code> is a bit unwieldy to fill out and structure(mix of normal Markdown and using <code>/n</code> and similar for), so it might be easier to place any larger documentation here on the Roll20 Community Wiki. | The '''"Instructions"'''-section of the <code>sheet.json</code> is a bit unwieldy to fill out and structure(mix of normal Markdown and using <code>/n</code> and similar for), so it might be easier to place any larger documentation here on the Roll20 Community Wiki. |
Revision as of 13:20, 17 April 2021
This is about a Roll20 feature exclusive to Pro-subscribers (and often to players in a Game created by a Pro-subscriber). If you'd like to use this feature, consider upgrading your account. |
Character Sheet Development
Getting Started
- Using Custom Sheets
- Building Sheets
(Main Page) - Glossary
- Code Restrictions
- Best Practice
- Common Mistakes
- Tutorials
- Examples, Templates
- Pattern Libraries
- HTML & storing data
- CSS & Styling
General
- Updates & Changelog
- Known Bugs
- Character Sheet Enhancement(CSE)
- Custom Roll Parsing
- Legacy Sheet(LCS)
- Beacon SDK
Reference
- Buttons
- Repeating Sections
- Sheetworkers
- Roll Templates
- sheet.json
- Translation
- Auto-Calc
- Advanced
- All SheetDev Pages
Tools & Tips
- Sheet Sandbox
- Sheet Editor
- Sheet Dev Tools
- Sheet Author Tips
Other
This is a collection of more advanced Sheet Author Tips that currently doesn't fit on the other pages relating to character sheet creation & editing. Most of the suggestions & ideas are taken from the Roll20 forums, or discussions among Sheet Authors.
Sheet Author is a badge people who have created & submitted character sheets to Roll20 get.
Contents |
Read the documentation
Give the Building Character Sheets-article a full read, as it contains lots of information on the specific quirks & pitfalls of how Roll20 character sheets works compared to default HTML/CSS/JavaScript. Even if you know how things work.
Some Highlights:
Sheet Sandbox
Using the Sheet Sandbox while editing/developing character sheets is much more effective and quicker than the normal Sheet Editor.
Alongside it, most authors use a text editor such as VSCode or Sublime Text.
Code with a Proper Text Editor
Rather than using the built-in code editor, all sheet authors who do sheets with any regularity use a separate text editor meant for coding, as they makes things much easier, and have tons of features & extensions that are useful.
Some use an IDE, but due to Roll20 having a bunch of unique stuff, it's not really practical to test code locally. It's best to test the code live in a Sheet Sandbox, or the Sheet Editor.
It's quicker to edit & save code on your computer, then upload the new sheet version to the Sheet Sandbox through the menu, than editing & using the Sheet Editor.
Popular Text Editors(among sheet authors):
- VSCode
- Sublime Text 3
- SublimeSettings - Roll20-specific HTML Syntax highlight that also does sheetworker highlight in html sheets. Created by Andreas J.
Web Developer Tools
Using the built in Web Dev tools in your browser helps a lot with figuring things out. Both Firefox & Chrome have their own versions, which both are accessed by pressing F12 at any time.
User Cases
- make live edits on you sheet and see how things change(like adjusting the width of a number input to look good)
- figure out why something works or doesn't work in your code, to narrow down the problem source (like why a css class is not working)
- reading the webdev console to figure out what's going on with your sheetworkers. (If you add
console.log("set strength mod to" + strmod)
to specific places in your code, you can see what steps are taken and what is left out)
Code Validation
It's a good idea to use a validator to check your code for mistakes in your code. Many IDE & text editors can install such extensions automatically, but given that Roll20 does a few things their own way, by default a HTML validator would complain about lot of things that aren't wrong, but just isn't accepted as standard HTML, such as <button type="roll"></button>
.
- HTML: W3C's HTML Validator
- initially give many varnings and errors on roll20-specific things, but you can filter away things that aren't wrong, and the list of error is quickly reduced to a manageable amount
- JavaScript(for sheetworkers & API): Closure Compiler for JS
- CSS: W3C's CSS Validator
- JSON(for translation files &
sheet.json
: jsonlint.com
Frameworks
Beyond just using HTML/CSS directly, you could use some pre-processors that can speed up the development, instead of directly writing HTML/CSS. Here is a few suggestion, used by some sheet authors including Roll20 themselves.
PUG & SCSS
Suggestion by Cassie
Use PUG & SCSS & JavaScript to make sheets. PUG & SCSS are the two most useful things I've ever learned for sheet development. Character sheets which use to take hundred+ hours takes now 20-40 thanks to PUG which is a JavaScript based language to write HTML. You'll save yourself a lot of redundant work by just using the power of loops & variables if nothing else.
Troubleshooting becomes much easier when you need to fix just one line in a loop rather than a dozen copy/paste html snippets.
PUG and SCSS can be used to simply split up the HTML & CSS files into smaller, more manageable files, which can then simply be compiled into their end results when it's time to use the sheet in a game.
These are compiled languages so you'll need to do that. Easily done via terminal if your tech savy or https://prepros.io/ if you're not.
- PUG - Getting Started
- Learn SCSS/SASS
- The processor seems to be generally called SASS, while SCSS is variation of it that more closely looks like regular CSS. The SASS too can output things as either.
- Guides to SASS should apply to SCSS
Cassie's Roll20 Sheet template, built using PUG & SCSS:
Handlebars
Suggestion by Primal Zed
Pros:
- Looks like HTML (or whatever file type you're templating), with handlebars blocks added in
- Inject data values anywhere directly into the HTML
- Can yield benefit with little effort - sheet authors can use as much or as little as they want
- Handlebars blocks have opening and close tags similar to HTML
- Easy to add new templates for re-use and organization
Cons:
- Involves new syntax to learn and helpers to understand
- Built-In Helpers
- For advanced use: Additional Helpers
- For advanced use: Repeat Helper
- Requires Node.js installation and some command lines
Git/GitHub
- Beginner's Guide to GitHub(Roll20)
- Short Git Guide - A guide to using the command line version of Git to work on your computer, instead of GitHub Desktop
Install the Pull App to GitHub
Be sure to create separate branches on your fork for editing since the PULL bot might overwrite your master -branch when syncing with the Roll20 repository. Use at your own risk. |
Pull App is a GitHub bot that can automatically watch and pull in Roll20's upstream default master
-branch to your fork using hard reset every few hours. You can also manually trigger it anytime.
Failure to keep your GitHub fork in sync with the master repo can create merge conflicts causing a pull request to be rejected or delayed. The Pull App can help automate this process and keep your fork in sync with Roll20's master
-branch.
While the Pull App will sync in the background every few hours, it is recommended that you manually run the bot before creating a branch for editing to ensure your fork's master
-branch is in sync with Roll20's most current master
-branch.
Use Branches in GitHub
Do not make changes to your GitHub master
-branch. Instead make a branch from master
to do all upgrades there. Submit pull request to the Roll20 repo directly from a branch. This is a safe way to do version control and will improve the integrity of your work.
Pattern Libraries & Components
Suggestion by Cassie
A pattern library can be your best friend if you want to make multiple sheets. Component style programming will let you save styles to be reused between sheets. With my last project I put work into my Sheet Template. This saves me a good deal of time by not needing to start from scratch every time. Its a slow work in progress were I'm reinventing much of Bootstrap.
Helpful Functions
//Convert Integers to be Negative const convertIntegerNegative = number => number > 0 ? -Math.abs(number) : number //Convert an object with negative numbers const convertIntegersNegatives = numbers => { numbers => { for (let [key, value] of Object.entries(numbers)) { numbers[key] = convertIntegerNegative(value); } return numbers } } //Pass in eventinfo.triggerName const findRepeatingField = trigger => trigger.split('_')[1] //Pass in eventinfo.triggerName const getReprowid = trigger => { const split = trigger.split('_'); return `${split[0]}_${split[1]}_${split[2]}` } //Pass in an object keep that has the repeating section //Example repeating_weapon_-m1czg68yzicwhfdpyys_name const getReprowAttribute = key => { const getReprowid = processingFunctions.getReprowid(key) return key.split(`${getReprowid}_`)[1] } //Provide the function with an array of keys to find transations for //Example ['strenght', 'agility', 'willpower'] const getTranslations = translationKeys => { let translations = {} translationKeys.forEach(key => translations[`${key}`] = getTranslationByKey(key)) return translations } const parseInteger = string => parseInt(string) || 0 //Use for convernting the result of getAttrs from strings into integers const parseIntegers = numbers => { for (let [key, value] of Object.entries(numbers)) { numbers[key] = parseInt(value) || 0 } return numbers } const setAttributes = (update, silent) => silent && typeof update === 'object' ? setAttrs(update, {silent:true}) : typeof update === 'object' ? setAttrs(update) : console.error(`${update} is not an object`) //returns strength from @{strenght} const sliceAttr = attribute => attribute.slice(2, -1) const sumIntegers = numbers => numbers.reduce((a,b) => a + b, 0)
Sheet Versioning
It can be beneficial to use a visible sheet version on a sheet, so people know when the sheet have updated. Also using sheet version will make it easier for you and others to track the state of the sheet and possible changelog.
If you have complex stat & sheetworkers in you sheet and make changes to them, it can be beneficial to add sheet versioning sheetworker that updates things for character using older version of the sheet to a new one.
An example would be to update an attribute name with a typo, to one with the correct spelling. The sheet versioning would next time a sheet is opened notice it is a older version, and then perform the sheet update transferring the attribute values of the old attribute to the new one, while it would do nothing on sheet that are already the latest version.
- Forum post(Forum) by GiGs, explaining a sheet versioning script, found in this gist
- The Aaron's take on a Versioning script, in the context of API scripts forum post(Forum)
Improved Sheetworker diagnostics
TheAaronSheet contains a number of helpful sheetworker functions like simplifying repeating sections, but it also has a improved debugging settings that can help making various dev console messages more distinct.
Changelog and Update Notification inside Sheet
If you a lots of changes to a sheet, or want to make sure that all users of the sheet are informed of the updates, you could integrate the sheet changelog & notification into the sheet, so next time they open a sheet their sheet they seem the update notice, & can dismiss them at will.
Alternatively, the changelog could be placed on a separate tab, such as folded it into the Settings-tab
The team behind the GURPS character sheet is a great example of incorporating a comprehensive changelog into the sheet, with a collapsible notice of the latest update/message from the sheet authors, and is non-obstructive even when not dismissed.
Documentation
The "Instructions"-section of the sheet.json
is a bit unwieldy to fill out and structure(mix of normal Markdown and using /n
and similar for), so it might be easier to place any larger documentation here on the Roll20 Community Wiki.
If the character sheet have several tabs or is long, the wiki could better fit more preview images of the sheet, rather than having something complicated on GitHub/the Sheet Template Preview.
Link to the sheet's wiki page in
.
Alternatively, add a Readme.md
Using REGEX
One method of saving time with sheet dev is to use regex to find & replace more complex things in code.
Example:
- Using REGEX to add Title code for attribute and roll names
- Many sheets do not tell users the different attribute names. The easiest method is to include a title="@{attrname}" in each input/select. Buttons could also benefit from adding a title="%{buttonname}" but isn't as big of a deal.
- It's possible to create a regex or some other syntax/replace command that could be run on any sheet that already doesn't have them, and add these attribute name tooltips for all attributes.
- Basic syntax to add Attribute titles:
- find all: name="attr_REGEX"
- replace with: name="attr_REGEX" title="@{REGEX}"
- REGEX is replaced with regex commands or some other search syntax that search/accepts alphanumerals, -, _ (in essence, anything that's a valid attribute name)
- Basic syntax to add Roll buttons titles:
- find all: name="roll_REGEX"
- replace with: name="roll_REGEX" title="%{REGEX}"
- Attribute example:
find regex: name="attr_([A-Za-z0-9_-]{1,50})" replace regex: name="attr_$1" title="@{$1}"
- Buttons example:
find regex: name="roll_([A-Za-z0-9_-]{1,50})" replace regex: name="roll_$1" title="%{$1}"
- (Arbitrarily chose "50" as max-length of attr name, use larger number if you might have super long names of course.)
Sharing code/collaboration
If you need to share larger parts of a sheets code with others on the Roll20 forums or somewhere else quickly, using GitHub Gist to share the full sheet is a smart alternative to Dropbox/Google Drive/Pastebin.
The "Revisions" tab of a gist shows clearly code changes between revisions, so tracking what have changed makes things easier for you and others.
Related Pages
- Sheet Sandbox – the better editor to use when you code your character sheets
- Javascript:Best Practices
- Andreas Guide to Sheet Development - general advice & mentions of things to consider when developing sheets
- Building Character Sheets - main article
- CSS Wizardry - List of Tips & Tricks on how to create a variety of effects on your character sheet
- Designing Character Sheet Layout - tips on how to best design the broad strokes of a character sheet
- Default Sheet Settings - Customize default settings and values of new character sheets added to a campaigns
- List of all pages related to "Character Sheet Creation"
- Reusing Rolls - Recent macro-related discovery that have uses for character sheet rolls
See Also
- Community
- Roll20 Forums - Character Sheets & Compendiums - Best place for discussing Sheets with other Sheet Creators, and to get current info
- Unofficial Roll20 Discord - The Discord server have two channels for discussing Character Sheet Creation, and many active Sheet Authors are present.
- Google's HTML/CSS Styleguide
- css-tricks.com Style Guides collection
- Sheet Templates/Examples
- Roll20's character sheet Roll20's template
- Cassie's sheet template by Cassie (Uses PUG/SCSS so not recommended for beginners)
- CSS Grid sheet template by Anduh
- Sheet template based on Blades in the Dark by Jakob