Skip to content

Commit

Permalink
Fix Clock Actors with no active scene
Browse files Browse the repository at this point in the history
  • Loading branch information
drewg13 committed Dec 13, 2023
1 parent 010c07d commit eedd0fe
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 35 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,3 +219,5 @@ v1.9.4 Fix Trauma tooltip z-indexing
2.2.0 Adds new Faction Status Actor sheet contributed by MarkPearce

2.2.1 Minor fixes to new Faction sheet, default type for Factions

2.2.2 Fix making changes to Clock Actors with no active scene
72 changes: 37 additions & 35 deletions module/sav-clock-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,20 +116,20 @@ export class SaVClockSheet extends ActorSheet {

// update associated tokens
const tokens = actor.getActiveTokens();

let update = [];
let tokenObj = {};
for (const t of tokens) {
tokenObj = {
_id: t.id,
name: actor.name,
img: clock.image.img,
actorLink: true
};
update.push(tokenObj);
if( tokens.length !== 0 ) {
let update = [];
let tokenObj = {};
for( const t of tokens ) {
tokenObj = {
_id: t.id,
name: actor.name,
img: clock.image.img,
actorLink: true
};
update.push( tokenObj );
}
await TokenDocument.updateDocuments( update, { parent: game.scenes.current } );
}
await TokenDocument.updateDocuments(update, {parent: game.scenes.current});

// update the Actor
const persistObj = await this.system.persistClockToActor({ actor, clock });
const visualObj = {
Expand Down Expand Up @@ -206,18 +206,19 @@ export default {
await Actor.updateDocuments(update);
update = [];
const tokens = a.getActiveTokens();
for (const t of tokens) {
tokenObj = {
_id: t.id,
name: a.name,
img: newClock.image.img,
flags: newClock.flags,
actorLink: true
};
update.push(tokenObj);
if( tokens.length !== 0 ) {
for( const t of tokens ) {
tokenObj = {
_id: t.id,
name: a.name,
img: newClock.image.img,
flags: newClock.flags,
actorLink: true
};
update.push( tokenObj );
}
await TokenDocument.updateDocuments( update, { parent: game.scenes.current } );
}

await TokenDocument.updateDocuments(update, {parent: game.scenes.current});
});

html.find("div.right").append(button2HTML).click(async (event) => {
Expand Down Expand Up @@ -269,18 +270,19 @@ export default {

update = [];
const tokens = a.getActiveTokens();
for (const t of tokens) {
tokenObj = {
_id: t.id,
name: a.name,
img: newClock.image.img,
flags: newClock.flags,
actorLink: true
};
update.push(tokenObj);
if( tokens.length !== 0 ) {
for( const t of tokens ) {
tokenObj = {
_id: t.id,
name: a.name,
img: newClock.image.img,
flags: newClock.flags,
actorLink: true
};
update.push( tokenObj );
}
await TokenDocument.updateDocuments( update, { parent: game.scenes.current } );
}

await TokenDocument.updateDocuments(update, {parent: game.scenes.current});
});
return true;
}
Expand Down

0 comments on commit eedd0fe

Please sign in to comment.