espositos / fvtt-tokenactionhud

Creating a token action HUD module for Foundry VTT
31 stars 38 forks source link

Error with tokens that are not attached to actors #106

Closed shemetz closed 3 years ago

shemetz commented 3 years ago

Whenever you hover over any token, if the scene contains another token that does not have an actor associated with it (represented actor = none, link actor data false), an error message is thrown into the console.

The culprit is this line (around line 420):

            let token = canvas.tokens.placeables.find(t => t.actor._id === character._id)

It should probably be fixed, to become:

            let token = canvas.tokens.placeables.find(t => t.actor && t.actor._id === character._id)

Similarly:

        return game.user.isGM || actor.hasPerm(user, "OWNER");
espositos commented 3 years ago

I've added the checks in 0.9.4. If you still get the errors let me know and I will have to come up with a more resilient solution.