wsaunders1014 / ShowDragDistance

Shows distance you dragged the token, similar to pressing ctrl.
10 stars 13 forks source link

The Document#_id property is deprecated #100

Open laurieathey opened 3 years ago

laurieathey commented 3 years ago

Getting the following warning spammed heavily. The Document#_id property is deprecated in favor of Document#id or Document#data#_id. Support will be removed in 0.9.0 image

Eventually this is just gonna stop working, and logs slow things down so clearing it up will likely improve performance while dragging.

crymic commented 3 years ago

Yeah.. I was going through this..

getTokenSpeed(token){
        const baseSpeed = parseFloat(getProperty(token,TokenSpeedAttributes.base));
        //const bonusSpeed = (TokenSpeedAttributes.bonus != "" && getProperty(token,TokenSpeedAttributes.bonus) !="") ? parseFloat(getProperty(token,TokenSpeedAttributes.bonus)):0;
        //console.log(bonusSpeed);
        //const flagBonusSpeed = (typeof token.document.getFlag('ShowDragDistance','speed') !='undefined') ? token.document.getFlag('ShowDragDistance','speed').normal:0;
        const normalSpeed = baseSpeed;
        //const normalSpeed = baseSpeed + flagBonusSpeed;
        const flagDashSpeed = (typeof token.document.getFlag('ShowDragDistance','speed') !='undefined') ? token.document.getFlag('ShowDragDistance','speed').dash:0;
        const dashSpeed = (normalSpeed + flagDashSpeed) * game.settings.get('ShowDragDistance','dashX');

        return {normal:normalSpeed,dash:dashSpeed}
    }

I made these changes and got rid of the error.. There's also an update line that needs to be changed

 await token.update(path.B);

to

  await token.document.update(path.B);

Also made this change..

  game.settings.register('ShowDragDistance', 'baseSpeedAttr', {
          name: "ShowDragDistance.baseSpeedAttr-s",
          hint: "ShowDragDistance.baseSpeedAttr-l",
          scope: "world",
          config: true,
          default: "actor.data.data.attributes.movement.walk",
          type: String,
          onChange: x => window.location.reload()
        });