grandseiken/foundryvtt-multilevel-tokens

Teleporting overrides the elevation set through a macro trigger

Opened this issue · 0 comments

A drawing that has both a macro changing elevation and a teleport, will teleport the token but discard the elevation changes.

By looking carefully, it is possible to see that the elevation is changed for a split second before being switched back after the teleport is done.

This might be a concurrency issue, caused by the teleportation overriding the changes made by the macro.

For the record, here is the macro I use:

if(args && args.length>0){
  console.log(args);
  let enterval=parseFloat(args[0]);
  let exitval= args.length>1?parseFloat(args[1]):null;
  let moveval= args.length>2?parseFloat(args[2]):null;

  let elevation=0;
  if     (event && event === MLT.ENTER)  elevation = enterval;
  else if(event && event === MLT.LEAVE)  elevation = exitval;
  else if(event && event === MLT.MOVE)   elevation = moveval;

  token.update({ "elevation": parseFloat(elevation)});
}