espositos / fvtt-tokenactionhud

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

Action Hud fails for some Token #236

Closed garvielloken42 closed 3 years ago

garvielloken42 commented 3 years ago

For some Tokens the Action Hud Fails after the Recent update I have the follwoing error in the Dev Console. 2021-05-30 14_32_28-Window 2021-05-30 14_33_23-Window

TheTural commented 3 years ago

It fails on tokens with spells as a result of the changes made yesterday relating to 0.8.x compatibility.

If you replace the getData(i) instances with i.data as it was before on lines 851 and 853, it'll fix it for the time being until the proper fix is implemented.

Lines 850-854:

        if (settings.get('showAllNonpreparableSpells')) {
            result = spells.filter(i => getData(i).preparation.prepared || nonpreparableSpells.includes(getData(i).preparation.mode) || getData(i).level === 0)
        } else {
            result = spells.filter(i => getData(i).preparation.prepared);
        }

Change to:

        if (settings.get('showAllNonpreparableSpells')) {
            result = spells.filter(i => i.data.preparation.prepared || nonpreparableSpells.includes(i.data.preparation.mode) || i.data.level === 0)
        } else {
            result = spells.filter(i => i.data.preparation.prepared);
        }
ctbritt commented 3 years ago

I made those changes and I'm still getting nothing but errors:

Uncaught (in promise) TypeError: actor.effects.entries.some is not a function
    at dnd5e-actions.js:629
    at Array.forEach (<anonymous>)
    at ActionHandler5e._addConditionsSubcategory (dnd5e-actions.js:625)
    at ActionHandler5e._getConditionsList (dnd5e-actions.js:555)
    at ActionHandler5e.doBuildActionList (dnd5e-actions.js:35)
    at ActionHandler5e.buildActionList (actionHandler.js:32)
    at TokenActionHUD.updateHud (tokenactionhud.js:386)
Battenhatch commented 3 years ago

There are two errors - one for tokens with spells, and one if you enable conditions in the HUD

ctbritt commented 3 years ago

so there are. I turned off categories and non-preparable spells and it seems to work ok in 0.8.5, but now in 7.10, normal action items such a melee attack aren't showing up. The inventory and Features tabs aren't showing up in 7.10

ctbritt commented 3 years ago

OK. I finagled some of the settings and got back working, after changing the code suggested by @TheTural above. Disabling "HIding actions longer than 1 round" brought inventory and feats tabs back.

espositos commented 3 years ago

So this should be fixed for both 0.7.x and 0.8.x, but please let me know if it's not