From 719d7f60211c43751f12a51fc35f233e2ea091a4 Mon Sep 17 00:00:00 2001 From: Vance Date: Tue, 25 Aug 2020 22:30:11 -0700 Subject: [PATCH] add 5e skills, notifications, roll table examples --- 5e-roll-skill.js | 31 +++++++++++++++++++++++++++++++ notification-warning-error.js | 8 ++++++++ roll-tables.js | 16 ++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100644 5e-roll-skill.js create mode 100644 notification-warning-error.js create mode 100644 roll-tables.js diff --git a/5e-roll-skill.js b/5e-roll-skill.js new file mode 100644 index 0000000..f80c59e --- /dev/null +++ b/5e-roll-skill.js @@ -0,0 +1,31 @@ +// Make a skill (Athletics) check +actor.rollSkill('ath'); + +// Skip advantage dialog and roll immediately +actor.rollSkill('ath', { fastForward: true }); + +/* +* Available params for 5e's rollSkill(): +* +* @param {Array} parts The dice roll component parts, excluding the initial d20 +* @param {Object} data Actor or item data against which to parse the roll +* @param {Event|object} event The triggering event which initiated the roll +* @param {string} rollMode A specific roll mode to apply as the default for the resulting roll +* @param {string|null} template The HTML template used to render the roll dialog +* @param {string|null} title The dice roll UI window title +* @param {Object} speaker The ChatMessage speaker to pass when creating the chat +* @param {string|null} flavor Flavor text to use in the posted chat message +* @param {Boolean} fastForward Allow fast-forward advantage selection +* @param {Function} onClose Callback for actions to take when the dialog form is closed +* @param {Object} dialogOptions Modal dialog options +* @param {boolean} advantage Apply advantage to the roll (unless otherwise specified) +* @param {boolean} disadvantage Apply disadvantage to the roll (unless otherwise specified) +* @param {number} critical The value of d20 result which represents a critical success +* @param {number} fumble The value of d20 result which represents a critical failure +* @param {number} targetValue Assign a target value against which the result of this roll should be compared +* @param {boolean} elvenAccuracy Allow Elven Accuracy to modify this roll? +* @param {boolean} halflingLucky Allow Halfling Luck to modify this roll? +* @param {boolean} reliableTalent Allow Reliable Talent to modify this roll? +* @param {boolean} chatMessage Automatically create a Chat Message for the result of this roll +* @param {object} messageData Additional data which is applied to the created Chat Message, if any +*/ \ No newline at end of file diff --git a/notification-warning-error.js b/notification-warning-error.js new file mode 100644 index 0000000..2725984 --- /dev/null +++ b/notification-warning-error.js @@ -0,0 +1,8 @@ +// Display notification +ui.notifications.notify('This is a notification'); + +// Display warning +ui.notifications.warn('This is a warning'); + +// Display error +ui.notifications.error('This is an error'); diff --git a/roll-tables.js b/roll-tables.js new file mode 100644 index 0000000..b2e35e6 --- /dev/null +++ b/roll-tables.js @@ -0,0 +1,16 @@ +/* + * Examples for using roll tables + * Examples assume existence of a basic roll table + * called "Months" that contains text entries + */ + +// Roll table and output to chat +game.tables.getName('Months').draw(); + +// Roll table and store result for later use +let roll = game.tables.getName('Months').roll(); + +// Roll table and send custom chat with result +let draw = game.tables.getName('Months').roll(); +let month = draw.results[0].text; +ChatMessage.create({ content: `The month is: ${month}`});