caewok / fvtt-walled-templates

Foundry VTT templates that interact with walls
MIT License
9 stars 4 forks source link

TypeError: undefined. attachedTemplates is not iterable #77

Closed Aedif closed 8 months ago

Aedif commented 9 months ago

Prevents pretty much all interaction with a token. Appears to be a conflict between Walled Templates and Token Attacher that occurs on tokens that had their Actors deleted.

Steps to reproduce (tried this in fresh world too):

  1. Activate Token Attacher and Walled Templates
  2. Create an Actor and drag out a token onto the scene
  3. Delete the placed token's Actor
  4. Attempt to drag the token

image

Aedif commented 9 months ago

I tested this again and this does not appear to be a conflcit between TA and Walled Templates. Walled Template simply doesn't handle Tokens without Actors properly.

Line marked as Issue #65 should be changed to return an empty array.

function attachedTemplates() {
  if (!this?.actor?.effects) return; // Issue #65.
  return this.actor.effects
    .filter((e) => e.origin && e.origin.includes('MeasuredTemplate'))
    .map((e) => fromUuidSync(e.origin)?.object)
    .filter((t) => Boolean(t)); // Drop undefined templates
}
function attachedTemplates() {
  if (!this?.actor?.effects) return []; // Issue #65.
  return this.actor.effects
    .filter((e) => e.origin && e.origin.includes('MeasuredTemplate'))
    .map((e) => fromUuidSync(e.origin)?.object)
    .filter((t) => Boolean(t)); // Drop undefined templates
}
tirzah2 commented 8 months ago

Thumbs up

caewok commented 8 months ago

Should be fixed in v0.7.0. Thanks!