Advertisement
Kitsunay

Untitled

May 8th, 2020
2,256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // A system-agnostic macro for time-limited effects.
  2. // You can set custom start/end message and number of combat rounds.
  3. // Requires about-time.
  4. // This macro was written by @Phenomen#1337
  5.  
  6. let applyChanges = false;
  7. new Dialog({
  8.   title: `Timed Effect Configuration`,
  9.   content: `
  10.     <form>
  11.       <div class="form-group">
  12.         <label>What message will start the effect?</label>
  13.         <input type="text" id="effect-start" name="effect-start" value="I'm blessed by Gods!">
  14.       </div>
  15.       <div class="form-group">
  16.         <label>What message will end the effect?</label>
  17.         <input type="text" id="effect-end" name="effect-end" value="The Gods have abandoned me...">
  18.       </div>
  19.       <div class="form-group">
  20.         <label>How many combat rounds will the effect last?</label>
  21.         <input type="number" id="effect-rounds" name="effect-rounds" min=0 value=1>
  22.     </form>
  23.     `,
  24.   buttons: {
  25.     yes: {
  26.       icon: "<i class='fas fa-check'></i>",
  27.       label: `Apply Changes`,
  28.       callback: () => applyChanges = true
  29.     },
  30.     no: {
  31.       icon: "<i class='fas fa-times'></i>",
  32.       label: `Cancel Changes`
  33.     },
  34.   },
  35.   default: "yes",
  36.   close: html => {
  37.     if (applyChanges) {
  38.       let effectStartString = html.find('[name="effect-start"]')[0].value;
  39.       let effectEndString = html.find('[name="effect-end"]')[0].value;
  40.       let effectRounds = html.find('[name="effect-rounds"]')[0].value || 1;
  41.       ChatMessage.create({
  42.         user: game.user._id,
  43.         content: effectStartString,
  44.         speaker: ChatMessage.getSpeaker()
  45.       }, {});
  46.       game.Gametime.doIn({seconds:effectRounds*6}, () => {
  47.         ChatMessage.create({
  48.           user: game.user._id,
  49.           content: effectEndString,
  50.           speaker: ChatMessage.getSpeaker()
  51.         }, {});
  52.       });
  53.     }
  54.   }
  55. }).render(true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement