Skip to content

Developers

Forien edited this page Jun 19, 2020 · 3 revisions

This page is meant to provide Macro / Module / System developers with documentation on public API endpoints of my Module.

QuestLog Api

close()

Corresponds to Application.close(). Can be used to close the Quest Log.

QuestLog.close()

render()

Corresponds to Application.render(). Can be used to force Quest Log open.

QuestLog.render(true)

rendered

Corresponds to Application.rendered. Can be used to check if Quest Log is currently rendered (visible).

if (QuestLog.rendered)

toggleSort(target, ?direction)

Enables and toggles direction of sorting. target can be one of: actor, title, checkedTasks. direction is optional parameter, that when provided with asc or desc, sets desired direction instead of toggling it.

QuestLog.toggleSort('title', 'asc')
QuestLog.toggleSort('checkedTasks')

Quests Api

get(questId)

Retrieves the "entity-like" instance of Quest class, provided the questId was valid Quest ID, Quest exists and user has permission for it. Otherwise returns undefined

Quests.get("EtC6FyAEaxX9XeNC");

open(questId)

Opens the Details window of Quest, provided the questId was valid Quest ID, Quest exists and user has permission for it. Otherwise pushes error notification.

Quests.open("EtC6FyAEaxX9XeNC");

create(data)

Programmatically creates new Quest and returns it's instance. actor needs to be valid Actor._id. tasks and rewards needs to be arrays of respective instantiated objects, created by next API calls.

let quest = Quests.create({
  actor: qgActor._id,
  title: "My new Quest",
  description: "It's <b>the best!</b>",
  gmnotes: null,
  tasks: [],
  rewards: rewardsArray
});

reward.create(data)

Programmatically creates new Reward and returns it's instance.
Supported types: Item, Abstract.
Item requires valid ItemData under risk of breaking when trying to apply Reward to an Actor.
Abstract requires exactly two data properties: { name: '', img: '' }, where img should be valid path.

let item = game.items.get("a5dhZpWjcVci8HbX");
let itemData = duplicate(item);

let reward = Quests.reward.create({
  type: "Item",
  data: itemData,
  hidden: true
});

task.create(data)

Programmatically creates new Task and returns it's instance.

let task = Quests.task.create({
  name: "Retrieve @Item[Silver Amulet]",
  hidden: false
});