Register

Bad Ideas Toolkit

An Add-on Module for Foundry Virtual Tabletop

Author: BadIdeasBureau Project Source: Project URL Versions 0.8.6+ (Verified 0.8.9) Last Updated 2 years ago

WARNING: This module contains functions which will allow tech-savvy players to completely bypass permissions on all Document types. If you don't trust your players, don't install this.

This is a library module, it does nothing on its own, but provides several functions for use in macros or by other modules.

Mainly, these functions are intended to help with making macros for use with MidiQoL, DAE, and similar automation modules.

Functions Provided

All functions are accessible at game.modules.get("bad-ideas-toolkit").api.functionName, e.g. game.modules.get("bad-ideas-toolkit").api.isMainGM(). Alternatively, badIdeas.functionName will be created if available (i.e. if it doesn't already exist in the globalThis object) as a convenience accessor. I don't think there should be clashes, but if there are then whatever is clashing with this will win.

This is set up as a hook on "init", so won't be available before then, and probably not in other "init" hooks.

Utility

isMainGM() : Returns true if the current user is the first active GM. Equivalent to game.users.find((u) => u.isGM && u.active)

async entityFromUuid(uuid) : Returns an Entity of the appropriate type (Scene, Token, Actor, etc.) for any UUID in the world (i.e. not in a compendium), including UUIDs for embedded entities. If this fails for any object, please add an issue to this repo. Where a base entity type is extended (e.g. Actor5e from Actor) this generally will return an object of the base entity type, rather than the extended type. removed as no longer necessary in 0.8

GM escalation

All the functions here can be called by anyone, and will then be executed by the GM. This allows users to update or delete pretty much anything if they have enough macro knowledge. Don't install this if you don't trust your users.

documentGetFlag(document, scope, flag) , documentSetFlag(document, scope, flag, value) , documentUnsetFlag(document, scope, flag) : gets/sets/unsets the flag specified by scope, flag for the document specified by document (which needs to be the actual document object).

documentUpdate(document, newData, options) : calls document.update(newData, options) on the GM side.

documentDelete(document, options) : calls document.delete(options) on the GM side

documentCreateEmbeddedDocuments(document, embedType, embedData, options) and documentDeleteEmbeddedDocuments(document, embedType, embedData, options) call the equivalent GM side functions (note that embedData must be an array in 0.8)

applyCUBCondition(condition, document) , removeCUBCondition(condition, document) uses Combat Utility Belt to apply/remove the specified condition. condition is the name of the condition (as a string), document is the document (i.e. Token or Actor) to apply/remove the condition to/from. This will return false if CUB is not active in the world (and handling that is your problem!)

All functions are async, and return the value of their equivalent GM side function if successful.

pre-0.8 versions of these functions (using "entity" in place of "document") are provided, but just call the new versions with appropriate argument transformations.

Categories

Available Versions

  1. Version 0.3.1

    2 years ago
    Foundry Version 0.8.6+ (Verified 0.8.9) Manifest URL Read Notes
  2. Version 0.3.0

    Foundry Version 0.8.6+ (Verified 0.8.6) Manifest URL Read Notes
  3. Version 0.2.2

    Foundry Version 0.7.5+ (Verified 0.7.9) Manifest URL Read Notes
  4. Version 0.2.1

    Foundry Version 0.7.5+ (Verified 0.7.9) Manifest URL Read Notes