Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Character sheet won't open if a bad damage formula is used #197

Open
RikkiGibson opened this issue Sep 5, 2022 · 3 comments · May be fixed by #240
Open

Character sheet won't open if a bad damage formula is used #197

RikkiGibson opened this issue Sep 5, 2022 · 3 comments · May be fixed by #240
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@RikkiGibson
Copy link

I used the damage formula 1d10+@mod.strength for a monster's attack, then hit save, and found I wasn't able to open the monster's character sheet back up. I had to disable the mod, correct the bad formula, then re-enable the mod.

TypeError: right-hand side of 'in' should be an object, got number
[Detected 2 packages: monsterblock, system:dnd5e]
    getProperty common/utils/helpers.mjs:295
    replaceFormulaData scripts/foundry.js:7072
    replaceFormulaData scripts/foundry.js:7071
    parse scripts/foundry.js:7032
    Roll scripts/foundry.js:6591
    damageFormula modules/monsterblock/scripts/dnd5e/AttackPreper.js:251
    formatAttackAndDamage modules/monsterblock/scripts/dnd5e/AttackPreper.js:189
    getDamageData modules/monsterblock/scripts/dnd5e/AttackPreper.js:166
    getAllDamageData modules/monsterblock/scripts/dnd5e/AttackPreper.js:148
    getDescription modules/monsterblock/scripts/dnd5e/AttackPreper.js:53
    prepare modules/monsterblock/scripts/dnd5e/AttackPreper.js:21
    prepareItem modules/monsterblock/scripts/dnd5e/ItemPrep.js:123
    organizeFeatures modules/monsterblock/scripts/dnd5e/ItemPrep.js:105
    prepareItems modules/monsterblock/scripts/dnd5e/ItemPrep.js:62
    ItemPrep modules/monsterblock/scripts/dnd5e/ItemPrep.js:36
    _prepareItems modules/monsterblock/scripts/dnd5e/MonsterBlock5e.js:494
    getData systems/dnd5e/module/actor/sheets/base.js:158
    getData systems/dnd5e/module/actor/sheets/npc.js:78
    getData modules/monsterblock/scripts/dnd5e/MonsterBlock5e.js:64
    _render scripts/foundry.js:3062
    _render scripts/foundry.js:3764
    render scripts/foundry.js:3021
    render scripts/foundry.js:4259
    _onClickDocumentName scripts/foundry.js:47577
    jQuery 2
foundry.js:319:30
@guldelox
Copy link

Error is still occurring.
Foundry v10 build 291
DnD5e system v2.1.5
Monster Blocks v3.3.5
image

@zeel01 zeel01 added bug Something isn't working help wanted Extra attention is needed labels Feb 12, 2024
@LunarShade
Copy link
Contributor

LunarShade commented Feb 29, 2024

@zeel01 I looked into this one and it appears to be fixed in the latest stable version of foundry. The getProperty method (see below) seems to explicitly return undefined if the input key doesn't give an Object or Array type, which should prevent the error from occurring. Might want to confirm against an older version just to be certain, but I think this one can be closed.

    if ( !key ) return undefined;
    let target = object;
    for ( let p of key.split('.') ) {
      const t = getType(target);
      if ( !((t === "Object") || (t === "Array")) ) return undefined;
      if ( p in target ) target = target[p];
      else return undefined;
    }
    return target;
  }

@zeel01
Copy link
Owner

zeel01 commented Jan 30, 2025

@RikkiGibson Could you check if this is still a problem in the latest version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants