Coder Social home page Coder Social logo

hookmacros's Introduction

Hia

Discord Foundry Module Downloads Donate Sponsors Patreon

I'm Ardit, an independent coder from the Netherlands. Right now I enjoy making modules for Foundry on my free time, but other than that I also like doing other projects in JavaScript for my different hobbies.

Here's a list of my current Foundry Modules

wakatime stats
GitHub metrics

Keystrokes in languages:

TypeScript |   41113 �[0m╢■■■■■■■■■
Markdown |   59371   �[0m╢■■■■■■■■■■■■
HTML |   64199       �[0m╢■■■■■■■■■■■■■
JSON |   81007       �[0m╢■■■■■■■■■■■■■■■■■
Vue |  120236        �[0m╢■■■■■■■■■■■■■■■■■■■■■■■■■
C# |  435522         �[0m╢■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
JavaScript |  713483 �[0m╢■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
                     ╚══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════

hookmacros's People

Contributors

ardittristan avatar hmqgg avatar n1xx1 avatar

Stargazers

 avatar

Forkers

n1xx1

hookmacros's Issues

Unable to open settings on v10

When attempting to open the Hook Macros settings window in v10, the following exception occurs:

TypeError: Cannot read properties of undefined (reading 'includes')
[Detected 1 package: launchmacro]
    at HookSettingsApplication.getData (hookmacro.js:151:38)
    at HookSettingsApplication._render (foundry.js:4959:29)
    at HookSettingsApplication._render (foundry.js:5684:17)
    at HookSettingsApplication.render (foundry.js:4918:10)
    at MonksSettingsConfig._onClickSubmenu (foundry.js:70865:16)
    at HTMLButtonElement.dispatch (jquery.min.js:2:43064)
    at y.handle (jquery.min.js:2:41048)

The exception occurs at this line because game.data.version is undefined.

Exception thrown

Hey folks,

I'm noticing a seemingly harmless exception in my logs when a hook fires:

TypeError: filteredMacro.execute(...) is undefined
    startHookListener hookmacro.js:154
    _call foundry.js:2496
    call foundry.js:2481
    _render foundry.js:4547
    _render foundry.js:15851
    render foundry.js:4479
    render foundry.js:27973
    _onModifyEmbeddedEntity foundry.js:32022
    _handleDeleteEmbeddedEntity foundry.js:30168
    deleteEmbeddedEntity foundry.js:30133
    toggleCombat foundry.js:40461
    toggleCombat foundry.js:44952
    _onToggleCombat foundry.js:23302
    jQuery 9
    activateListeners foundry.js:23226
    _render foundry.js:4537
    _render foundry.js:20787
    render foundry.js:4479
    bind foundry.js:20762
    bind foundry.js:23107
    _onClickRight foundry.js:11887
    callback foundry.js:36392
    _handleClickRight foundry.js:36646
    _handleRightDown foundry.js:36626
    emit index.js:181
    dispatchEvent InteractionManager.ts:1106
    processPointerDown InteractionManager.ts:1307
    recursiveFindHit TreeSearch.ts:173
    recursiveFindHit TreeSearch.ts:113
    recursiveFindHit TreeSearch.ts:113
    recursiveFindHit TreeSearch.ts:113
    findHit TreeSearch.ts:200
    processInteractive InteractionManager.ts:1177
    onPointerDown InteractionManager.ts:1252
    addEvents InteractionManager.ts:885
    setTargetElement InteractionManager.ts:815
    r InteractionManager.ts:733
    initPlugins AbstractRenderer.ts:229
    r Renderer.ts:268
    create Renderer.ts:85
    mn autoDetectRenderer.ts:39
    t Application.ts:87
    Canvas foundry.js:9967
    initializeCanvas foundry.js:6661
    setupGame foundry.js:6546
    _initializeGameView foundry.js:7319
    initialize foundry.js:6471
    async* foundry.js:7449
    async* foundry.js:7447
foundry.js:2499:15
    _call foundry.js:2499
    call foundry.js:2481
    _render foundry.js:4547
    _render foundry.js:15851
    render foundry.js:4479
    render foundry.js:27973
    _onModifyEmbeddedEntity foundry.js:32022
    _handleDeleteEmbeddedEntity foundry.js:30168
    deleteEmbeddedEntity foundry.js:30133
    toggleCombat foundry.js:40461
    toggleCombat foundry.js:44952
    _onToggleCombat foundry.js:23302
    jQuery 9
    activateListeners foundry.js:23226
    _render foundry.js:4537
    _render foundry.js:20787
    render foundry.js:4479
    bind foundry.js:20762
    bind foundry.js:23107
    _onClickRight foundry.js:11887
    callback foundry.js:36392
    _handleClickRight foundry.js:36646
    _handleRightDown foundry.js:36626
    emit index.js:181
    dispatchEvent InteractionManager.ts:1106
    processPointerDown InteractionManager.ts:1307
    recursiveFindHit TreeSearch.ts:173
    recursiveFindHit TreeSearch.ts:113
    recursiveFindHit TreeSearch.ts:113
    recursiveFindHit TreeSearch.ts:113
    findHit TreeSearch.ts:200
    processInteractive InteractionManager.ts:1177
    onPointerDown InteractionManager.ts:1252
    addEvents InteractionManager.ts:885
    setTargetElement InteractionManager.ts:815
    r InteractionManager.ts:733
    initPlugins AbstractRenderer.ts:229
    r Renderer.ts:268
    create Renderer.ts:85
    mn autoDetectRenderer.ts:39
    t Application.ts:87
    Canvas foundry.js:9967
    initializeCanvas foundry.js:6661
    setupGame foundry.js:6546
    _initializeGameView foundry.js:7319
    initialize foundry.js:6471
    <anonymous> foundry.js:7449
    <anonymous> foundry.js:7447

It looks like execute is returning undefined, and the then call is throwing the error.

Relevant code:

filteredMacro.execute(...args).then(async function () {

I'm not sure if this is expected, or related to my setup. Just in case, this is my Hook Macros journal:

@Hook[renderCombatTracker] @Macro[Combat]

Again, this appears to be harmless in my case. The hook works as expected and the macro is called.

Feature Request

Please support furnace advanced macros so that we can pass arguments to the macros - i.e. allow parameter specs in the journal entry and with furnace enabled do macro.execture(...args) instead of macro.execute().
Love the module - wish I thought to write it.

v2.0.2 --- unable to trigger any macros....

I couldn't figure out why the last few weeks, my triggers (which were being run via journals) weren't working. I realized that I updated to v2.0.2 about that time, and just learned today, that the interface for managing/overseeing HookMacros has completely changed.

The side effect of this, and hence the reason for this issue, is to advise, that I'm unable to trigger ANY macros, whether via the Settings, Local Settings or the Legacy Journal approach.

I've tried the following very simple configurations

Settings variation 1

  • Hook name: updateToken
  • Macro name: hpChange
  • Macro Arguments: none

Settings variation 2

  • Hook name: updateToken
  • Macro name: hpChange
  • Macro Arguments: arg1,arg2,arg3

Settings variation 3

  • Hook name: updateCombat
  • Macro name: Sanity Trigger ---Note: this was fully functional in the Journal configuration model
  • Macro Arguments: arg1

Local Settings variation 1

  • Hook name: updateToken
  • Macro name: hpChange
  • Macro Arguments: none

Local Settings variation 2

  • Hook name: updateToken
  • Macro name: hpChange
  • Macro Arguments: arg1,arg2,arg3

Local Settings variation 3

  • Hook name: updateCombat
  • Macro name: Sanity Trigger ---Note: this was fully functional in the Journal configuration model
  • Macro Arguments: arg1

Syntax examples might be useful

I'm trying to set up a macro that triggers upon a hook from another module (wild magic surge), but it doesn't seem to be triggering correctly. Or at least the arguments don't seem to be getting passed to the macro. It's hard to troubleshoot (As a complete novice) without any examples of what syntax this module is expecting. Even a single working example would be nice!

FYI:

First, your module is pretty slick. I'm using it as a sort of springboard for a module I'm developing.

I noticed, though, at line 102 of hookmacro.js, you have this comment:
// For whatever reason using return crashes foundry, but using if it works great

As I modified my code to suit my module, I realized why a return crashes foundry or, rather, causes it to (apparently) freeze. After your if statement, there are 2 lines:

  updating = false;
  init = true;

I didn't dig deep enough to determine which of those settings causes it to hang, but I suspect it's the updating variable.

By setting those variables (to false/true respectively) before my return, it worked. Of course, your code works fine too, but I figured, given that comment in the code, you might be interested in this.

Arguments passing doesn't work

I'm using Foundry VTT v10.

The mechanism used to pass arguments into the macro on line 118 of hookmacro.js doesn't work. The code looks like this:

        try {
          filteredMacro.execute(...args, ...hookArgs).then(async function () {
            lastRan = Date.now();
          });
        } catch {}

However, Macro.execute has the following signature: execute({actor, token}={}), which does not match the input arguments above. Therefore, those arguments will be ignored, which is what seems to be happening in the code.

The only way to pass parameters into the macros is to essentially re-implement the Macro.execute() mechanism, creating a function object and then using Function.call() to execute the javascript. That will allow you to pass the parameters as you see fit.

Otherwise, you need to change the current code above to simply pass in the actor and token, as required by the Macro.execute() signature.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.