KayelGee / token-attacher

MIT License
11 stars 18 forks source link

attachElementToToken seems to fail in newest version of Foundry #41

Closed digitalpacman closed 3 years ago

digitalpacman commented 3 years ago

I'm using foundry version 0.8.7

This implementation used to work. Since this update came out all my users are receiving errors in the console and token attacher isn't working.

image

I'm using the most recent version of the token attacher module and it happens with only libwrapper, token attacher, and my code present.

  const drawn = await Drawing.create({
    type: CONST.DRAWING_TYPES.FREEHAND,
    author: game.user._id,
    x: token.x - (reach / 5) * canvas.scene.data.grid,
    y: token.y - (reach / 5) * canvas.scene.data.grid,
    fillType: CONST.DRAWING_FILL_TYPES.NONE,
    strokeWidth: 4,
    strokeColor: nextColor(),
    strokeAlpha: 0.75,
    points: template.map(([x, y]) => 
      [
        x * canvas.scene.data.grid,
        y * canvas.scene.data.grid,
      ]),
  });

The above is my code for drawing an element on the screen. The element is drawn and exists in the scene. Then I call

await tokenAttacher.attachElementToToken(drawn, token, true);

This is where the error happens and the drawing does not attach to the token.

digitalpacman commented 3 years ago

I closed this because it turns out Foundry made a backward incompatible change to draw(). It now returns an array.