-
Notifications
You must be signed in to change notification settings - Fork 12
Example Macros
crash1115 edited this page May 18, 2021
·
5 revisions
Here are just a few sample macros to get you started. I'll be adding more over time.
This is a simple macro that rolls a d20, then adds the result to the progress of actor Joe Smith's tracked item called Roll Lots of D20s.
// Specify our actor and the item we want to deal with.
let actorName = `Joe Smith`;
let itemName = `Roll Lots of D20s`;
// This command takes the names we just specified and fetches the appropriate item.
let item = CrashTNT.getActivity(actorName, itemName);
// Roll the dice! Adding some flavor to describe what the roll is for while we're here.
let roll = new Roll('1d20').roll();
roll.toMessage({flavor:"Increasing our progress by 1d20"});
// Now let's get the result so we can use it.
// The parseInt around the roll ensures we get a number, rather than a string.
let result = parseInt(roll.result);
// Figure out what we want our new progress value to be.
// This is the item's current progress + the result of our d20 roll.
let newProgress = item.progress + result;
// Now we update! This function takes the name of the actor and item we specified at the start,
// then finds that item and sets its progress to some new value we specify.
CrashTNT.updateActivityProgress(actorName, itemName, newProgress);
// All done!
This is a template you can use to do whatever you want with. It contains the bare minimum you need to get by modifying an item's progress value.
// Specify our actor and the item we want to deal with.
let actorName = `Actor Name`;
let itemName = `Item Name`;
let item = CrashTNT.getActivity(actorName, itemName);
let newProgressValue;
// Do stuff here.
// Make sure at some point you set newProgressValue equal to some integer before you hit the last line.
// Make the update
CrashTNT.updateActivityProgress(actorName, itemName, newProgressValue);
Last Updated | C. Ash | 21 SEP 2021 | Version 0.6.5