MATT Triggering a Tile via Macro - ironmonk88/monks-module-wiki GitHub Wiki

Triggering a Tile Via Macro

Quick Trigger Function

game.MonksActiveTiles.triggerTile('Scene.ykdBMiSq6M7Qu1Yy.Tile.KSaaDmKLQ390bJMd')

ID Trigger

// Replace the tile ID with the ID of the tile to be triggered.
canvas.tiles.get("tile ID").document.trigger({});

ID Trigger, Requires Token

This one passes the selected token to the tile.

// Replace the tile ID with the ID of the tile to be triggered.
// Requires a token to be selected when activated.
canvas.tiles.get("tile ID").document.trigger({tokens:[canvas.tokens.controlled[0].document], method: 'trigger'})

ID Trigger at Specific Landing

Triggers the tile at a specific Landing; it instead triggers it at the start of the tile actions if the landing doesn't exist.

// Replace the tile ID with the ID of the tile to be triggered.
let tile = canvas.tiles.get("tile ID");
tile.document.trigger({options: { landing: "test2"}});

ID Trigger at Specific Landing, Requires Token

This one passes the selected token to the tile. Triggers the tile at a specific Landing; it instead triggers it at the start of the tile actions if the landing doesn't exist.

// Replace the tile ID with the ID of the tile to be triggered.
// Requires a token to be selected when activated.
canvas.tiles.get("tile ID").document.trigger({tokens:[canvas.tokens.controlled[0].document], method: 'trigger', options: { landing: "test2"}})

Fancier Version of ID Trigger at Specific Landing, Requires Token


// Replace the tile ID with the ID of the tile to be triggered.
// Requires a token to be selected when activated.
let tileID = "tile ID";
let tileb = canvas.tiles.get(tileID);
let landingName = "test 2b";

if (tileb) {
  let token = canvas.tokens.controlled[0];
  if (token) {
    // Check if the landing name exists
    if (tileb.document.flags?.['monks-active-tiles']?.actions?.some(action => action.data.tag === landingName)) {
      tileb.document.trigger({
        tokens: [token.document],
        method: 'trigger',
        options: { landing: landingName }
      });
    } else {
      ui.notifications.error("Landing not found.");
    }
  } else {
    ui.notifications.error("No token selected.");
  }
} else {
  ui.notifications.error("Tile not found.");
}

Tagger Trigger

// Replace Test Tag with the Tag you're using.
// Only triggers the oldest tile with this particular Tag
Tagger.getByTag("Test Tag")[0].trigger({});

Tagger Trigger, Requires Token

This one passes the selected token to the tile.

// Replace Test Tag with the Tag you're using.
// Only triggers the oldest tile with this particular Tag
Tagger.getByTag("Test Tag")[0].trigger({tokens:[canvas.tokens.controlled[0].document], method: 'trigger'})

Page Last Updated

  • MATT 11.27