Skip to content

For developers

Averrin edited this page Aug 1, 2022 · 9 revisions

actual for version 0.8

Sequences API

await Director.playSequence("%Sequence name / id%", {"%variable%": "%value%"})

Playing a sequence by name. You are also able to specify overrides for sequence's variables

await Director.getSequence("%Sequence name / id%", {"%variable%": "%value%"})

Returns native Sequencer's sequence.

Director.findSequence("%Sequence name / id%")

Returns Director's sequence instance.

Director.listSequences()

Returns all available for this scene (global + scene-specific) Director's sequences.

Director.runAction("%Action name / id%")

Run action by name or ID

Fixes

Director.clearSceneData()

Clears all scene-specific data (actions, hooks, sequences)

Director.clearGlobalData()

Clears global data (sequences)

Extension API

You can find the examples here: https://github.com/averrin/director/blob/master/src/modules/Integrations.js

Director.addSection({
  id: 'tmDel', // unique id
  group: "Token Magic", // sorting group
  label: 'Remove Token Magic', // name
  multiplyMode: "self", // override value of "mode" for `multiply` modifier
  args: [
    { type: 'token', label: 'target' },
    { type: 'token-magic', label: 'filter' },
    { type: "obvious", label: "too", option: "packed into the last 'options' object argument", optional: true } // can contain "undefined" and omit from section calling
  ], // optional. list of arguments
  thenDo: (args) => { // function for placing inside `thenDo` section
    const code = 'await TokenMagic.deleteFilters(target, filter);';
    const filter = args[1];

    const target = args[0];
    const f = new AsyncFunction('target', 'filter', code);
    return async () => await f(target, filter);
  },
  addSequence: (args) => { // calling if thenDo is missing. It returns sequence for placing inside `addSequence` section
    let s = new globalThis.Sequence("director").wait(100);
    return s;
  }

  toCode: (args) => { // code string for copy as code
    if (args.length < 2) return '';
    return `\t.thenDo(async () => await TokenMagic.deleteFilters(${args[0]}, ${args[1]}))\n`;
  }
})
Director.addModifier() // useless for now
Director.addArgSpec({
  id: "token-magic", // unique id
  var_types: ["token-magic", "string", "expression"], // acceptable types for variables
  options: (value) => globalThis.TokenMagic.getPresets().map((p) => p.name), // optional. array or function which represents available options
  control: "select" // required for custom arg with options
})
Director.addHook({
  id: "#onCeAdd", // unique id
  name: "On Add Convenient Effect", // hook's name
  parents: ["createActiveEffect"], // existing foundry's parent hook name
  target: (target, ...args) => {
    return target.actor.id == args[0].parent.id; // check is target is eligible, bool
  },
  test: (effect, ...args) => {
    return args[1].data.label == effect; // check should hook be triggered, bool
  },
  args: [{ type: "ce-effect", label: "effect" }] // optional. arguments
})
Director.addAction({
  id: 'execute', // unique id
  label: 'Execute trigger', // action's name
  group: 'Active Tiles', // sorting group
  ignoreTarget: false, // to not calc target (prevents "nothing selected" error) and calls action only once (ignoring count of targets)
  execute: (object, action, event) => { // actual code
  },
  args: [{ type: 'ce-effect', label: 'effect' }] // optional. arguments
})

Clone this wiki locally