Feu-Secret / Tokenmagic

A Foundry VTT module that allows you to add animations and graphic effects to tokens, tiles, templates and drawings.
GNU General Public License v3.0
52 stars 36 forks source link

getControlledPlaceables() does not work in PF2e, causing macros to fail #178

Closed shemetz closed 2 years ago

shemetz commented 2 years ago

(PF2e v3.3.0, TokenMagic FX v0.5.3)

None of the macros work for me, because they all rely on the getControlledPlaceables function which has the following line:

    switch (canvas.activeLayer.name) {
        case TokenLayer.name:

When debugging, I see that: canvas.activeLayer.name = 'TokenLayerPF2e' TokenLayer.name = 'TokenLayer'

and for that reason, the code enters none of the cases, ending up with a list of 0 controlled placeables, causing nothing to happen.

shemetz commented 2 years ago

I believe a solution might be to change the case to case canvas.tokens.name.

For now, as a workaround, I can type the following in the console to temporarily fix the issue:

Object.defineProperty(canvas.tokens, "name", {
    get: function() { return 'TokenLayer' }
});
Feu-Secret commented 2 years ago

@itamarcu Thank you for the report!

rsimoes commented 2 years ago

It'd be better to just not check for exact constructor names

rsimoes commented 2 years ago

Screenshot from 2022-01-30 16-05-10