Skip to content

Commit

Permalink
Merge branch 'fix-detach'
Browse files Browse the repository at this point in the history
  • Loading branch information
KayelGee committed Feb 19, 2025
2 parents d2f5042 + 23ed221 commit 20957c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "token-attacher",
"title": "Token Attacher",
"description": "Attach anything(even tokens) to tokens, so that they move when the token moves and rotate/move when the token rotates. Create prefabs and many more features, see the github readme for more details.",
"version": "4.6.10",
"version": "4.6.11",
"compatibility" :{
"minimum": 12,
"verified": 12,
Expand Down
12 changes: 6 additions & 6 deletions scripts/token-attacher.js
Original file line number Diff line number Diff line change
Expand Up @@ -1410,23 +1410,23 @@ import {libWrapper} from './shim.js';
return await canvas.scene.unsetFlag(moduleName, "attach_base");
}

static detachElementFromToken(element, target_token, suppressNotification=false){
static async detachElementFromToken(element, target_token, suppressNotification=false){
const type = element.layer.constructor.documentName;
const selected = [element.document._id];
const selected = [element.document?._id ?? element._id];

if(TokenAttacher.isFirstActiveGM()) TokenAttacher._DetachFromToken(target_token, {type:type, ids:selected}, suppressNotification);
if(TokenAttacher.isFirstActiveGM()) return await TokenAttacher._DetachFromToken(target_token, {type:type, ids:selected}, suppressNotification);
else game.socket.emit(`module.${moduleName}`, {event: `DetachFromToken`, eventdata: [target_token.document._id, {type:type, ids:selected}, suppressNotification]});
}

static detachElementsFromToken(element_array, target_token, suppressNotification=false){
static async detachElementsFromToken(element_array, target_token, suppressNotification=false){
let selected = {}
for (const element of element_array) {
const type = element.layer.constructor.documentName;
if(!selected.hasOwnProperty(type)) selected[type] = [];
selected[type].push(element.document._id);
selected[type].push(element.document?._id ?? element._id);
}

if(TokenAttacher.isFirstActiveGM()) TokenAttacher._detachElementsFromToken(selected, target_token, suppressNotification);
if(TokenAttacher.isFirstActiveGM()) return await TokenAttacher._detachElementsFromToken(selected, target_token, suppressNotification);
else game.socket.emit(`module.${moduleName}`, {event: `detachElementsFromToken`, eventdata: [selected, target_token.document._id, suppressNotification]});
}

Expand Down

0 comments on commit 20957c7

Please sign in to comment.