Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
espositos committed Aug 20, 2020
2 parents ba0d9b1 + 2918c03 commit 738bead
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
38 changes: 30 additions & 8 deletions chatlink.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ export class ChatLink {
}

static getToken(speakerData) {
let token = game.actors.tokens[speakerData.idToken]?.token;
let token = canvas.tokens.placeables.find(t => t.id === speakerData.idToken);
if(!token)
token = canvas.tokens.placeables.find(t => t.actor?._id === speakerData.idActor);

return token;
}

static tokenExists(user, speakerData, token) {
if (token && token.interactive)
if (token && token.visible)
return true;

if (!ChatLink.isRightScene(user, speakerData))
Expand Down Expand Up @@ -152,18 +152,40 @@ export class ChatLink {

static controlToken(event, user, token, ctrlKey) {
let releaseOthers = {releaseOthers: !ctrlKey};
if (token._controlled && ctrlKey)
token.release();
else
if (ctrlKey) {
if (token._controlled)
token.release();
else
token.control(releaseOthers);

return;
}

if (token._controlled || canvas.tokens.controlled.length !== 1)
token.control(releaseOthers);
else if (!token._controlled && canvas.tokens.controlled.length === 1)
token.control(releaseOthers);
else
token.release();
}

static targetToken(event, user, token, ctrlKey) {
let releaseOthers = {releaseOthers: !ctrlKey};
if (token.isTargeted && ctrlKey)
token.setTarget(false, releaseOthers)
else
if (ctrlKey) {
if (token.isTargeted)
token.setTarget(false, releaseOthers);
else
token.setTarget(true, releaseOthers);

return;
}

if (token.isTargeted || game.user.targets.size !== 1)
token.setTarget(true, releaseOthers);
else if (!token.isTargeted && game.user.targets.size === 1)
token.setTarget(true, releaseOthers);
else
token.setTarget(false, releaseOthers);
}

static getCoords(token) {
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"token-chat-link","title":"Token Chat Link","author":"^ and stick#0520","description":"Turns the name of the speaker in the chat log into a link to their token.","minimumCoreVersion":"0.6.0","compatibleCoreVersion":"0.7.0","styles":["./styles/tokenchatlink.css"],"esmodules":["./init.js"],"languages":[{"lang":"en","name":"English","path":"lang/en.json"}],"url":"https://github.com/espositos/fvtt-tokenchatlink","manifest":"https://github.com/espositos/fvtt-tokenchatlink/raw/master/module.json","version":"1.0.8","download":"https://github.com/espositos/fvtt-tokenchatlink/releases/download/1.0.8/release_1.0.8.zip"}
{"name":"token-chat-link","title":"Token Chat Link","author":"^ and stick#0520","description":"Turns the name of the speaker in the chat log into a link to their token.","minimumCoreVersion":"0.6.5","compatibleCoreVersion":"0.7.1","styles":["./styles/tokenchatlink.css"],"esmodules":["./init.js"],"languages":[{"lang":"en","name":"English","path":"lang/en.json"}],"url":"https://github.com/espositos/fvtt-tokenchatlink","manifest":"https://github.com/espositos/fvtt-tokenchatlink/raw/master/module.json","version":"1.0.8","download":"https://github.com/espositos/fvtt-tokenchatlink/releases/download/1.0.8/release_1.0.8.zip"}

0 comments on commit 738bead

Please sign in to comment.