kandashi / Next-Up

Auto focus on new combatant
MIT License
12 stars 9 forks source link

firstGm is not Defined #131

Open galaara98 opened 2 years ago

galaara98 commented 2 years ago

an error in the console appears when GM advances the turn to the next participant in the combat tracker. the error looks like this:

Uncaught (in promise) ReferenceError: firstGm is not defined [Detected 2 packages: Next-Up, system:pf2e] at handleCombatUpdate (nextUp.js:349) at Function._call (foundry.js:294) at Function.callAll (foundry.js:253) at ClientDatabaseBackend.callback (foundry.js:10216) at foundry.js:10155 at Array.map () at ClientDatabaseBackend._handleUpdateDocuments (foundry.js:10155) at ClientDatabaseBackend._updateDocuments (foundry.js:10036) at async Function.updateDocuments (document.mjs:373) at async EncounterPF2e.update (document.mjs:456) at async EncounterPF2e.nextTurn (main.bundle.js:1) at async EncounterTrackerPF2e._onCombatControl (foundry.js:58273) at async EncounterTrackerPF2e._onCombatControl (main.bundle.js:1)

To Reproduce (Some step might not be required, I have a game soon and so did not strip it down to minimal mods, least number of variables... I am genuinely sorry)

Steps to reproduce the behavior: prepare a combat with at least one actor that is an NPC and one that is a PC open js console in the browser to see real-time logging start the encounter progress the encounter turn, each time the encounter moves to the next participant the error is logged *as far as I can tell at this time it is not hurting MY particular game (it is always possible I do not know what is or isnt working and it is, but I didn't need it personally)

Expected behavior Currenly All I am expecting is to not have an error when the encounter tracker progresses to the next participant

Screenshots If applicable, add screenshots to help explain your problem.

Environment:

Additional context Add any other context about the problem here.

galaara98 commented 2 years ago

i beleive the offending code is

NextUP.cycleSheets(nextToken, previousToken)
        if (playerPanEnable && playerPan && (nextToken.isVisible || game.user === firstGm)) {
            canvas.animatePan({ x: nextToken.center.x, y: nextToken.center.y, duration: 250 });
        }

and should be (I THINK this was your intention):

NextUP.cycleSheets(nextToken, previousToken)
        if (playerPanEnable && playerPan && (nextToken.isVisible || game.user === isGM)) {
            canvas.animatePan({ x: nextToken.center.x, y: nextToken.center.y, duration: 250 });
        }
galaara98 commented 2 years ago

hmm i went back through your past code, you were definitely using firstGm in the past... and noone was complaining, so that property must have existed... so my solution might not be correct,

I looked at my own game as it was running as a GM, and my game.user does not have a firstGm property, so I just don't know what the original purpose was???

:( I wish I could be more help! I am going to leave my game running with the above proposed solution, which causes panning to next token if panning is "on" and player is "GM"