schultzcole / FVTT-Turn-Alert

Set alerts to trigger on a particular round of combat or on a particular token's turn.
https://foundryvtt.com/packages/turnAlert/
MIT License
8 stars 4 forks source link

Macros do not execute. #40

Open DieterKosken opened 3 years ago

DieterKosken commented 3 years ago

Looks like macros do not execute. Macro by it self executes just fine. Chat commands from turnalert execute fine. I get two error messages when macros try to execute.

Im running 0.8.8 with Pf2e 2.5.0.6331

VM11874:9 Uncaught (in promise) TypeError: Cannot read property 'data' of undefined at main (eval at _customExecute (TurnAlert.js:180), :9:13) at eval (eval at _customExecute (TurnAlert.js:180), :67:1) at Function._customExecute (TurnAlert.js:180) at Function.execute (TurnAlert.js:152) at handleUpdateCombat (handleUpdateCombat.js:35) at Function._call (eval at (listeners.js:56), :4:14) at Function.callAll (foundry.js:153) at ClientDatabaseBackend.callback (foundry.js:8880) at foundry.js:8819 at Array.map () ... VM11875:8 Uncaught (in promise) TypeError: Cannot read property 'actor' of undefined at main (eval at _customExecute (TurnAlert.js:180), :8:13) at eval (eval at _customExecute (TurnAlert.js:180), :16:1) at Function._customExecute (TurnAlert.js:180) at Function.execute (TurnAlert.js:152) at handleUpdateCombat (handleUpdateCombat.js:35) at Function._call (eval at (listeners.js:56), :4:14) at Function.callAll (foundry.js:153) at ClientDatabaseBackend.callback (foundry.js:8880) at foundry.js:8819 at Array.map ()

DieterKosken commented 3 years ago

So the issue is calling 'token' and 'actor' in the macros without defining them. At least for PF2e, the work around is as follows:

const tokenid = game.combat?.combatant?.token.id; const token = canvas.tokens.children[0].children.find(i => i.id === tokenid ); const actorid = game.combat?.combatant?.actor.id; const actor = game.actors.find(i => i.id === actorid );

For macros that execute end of turn, you need to use the previous tokens ID

const tokenid = game.combat?.previous?.tokenId; const token = canvas.tokens.children[0].children.find(i => i.id === tokenid );