Skip to content

Commit

Permalink
Make rendering of lock overlay more robust between GM and players' se…
Browse files Browse the repository at this point in the history
…ssions
  • Loading branch information
coffiarts committed Dec 16, 2023
1 parent 81fea9c commit f3bc989
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# TODO
- test movement
- test actions/check rolls/attacks
- run renderToken/renderOverlay by single token, not for all
- introduce green icon as well
- introduce green icon as well, and make icons configurable
- get rid of permanent messages
- identify and support more allowed actions
- test with actor prototypes
- make allowed actions configurable in settings (i.e. equip/unequip)
- test with actor prototypes => overlay in actors list?
- dnd5e test
- video (dnd5)
- finalize readme
Expand Down Expand Up @@ -45,10 +43,15 @@ With this nice little helper module the Game Master can block and unblock any ed
This helps, for instance, to protect them from accidental changes.
And of course, if you're of the paranoid type, it prevents cheating.

***BE AWARE, though***: As long as the lock is active, it also suppresses automatic (game-induced) changes, given that they're triggered by the players themselves - such as applying damage by chat message button, or picking up items from loot chests.
Such changes can still be applied from within the GM's session. But the lock should not be kept active at all times. Use it with some care.
***A slight warning:*** While sheets are locked, some intended changes may be suppressed, such as macro or chat triggered actions. But rest assured: There will be a screen message whenever that happens.
In such cases, just unlock the sheets and repeat the blocked action.

Toggling on/off works in various ways: By game settings, or with a nice UI Button (optional), or by macro code or macro button. Please refer to the various module preferences under game settings.
Toggling on/off works in various ways:
1. By a checkbox in the module settings
2. Through a nice UI Button in the scene control on the left (which is optional and can be turned off in the setings, if you don't like it)
3. By macro code (a ready-to-use macro button is already included as a compendium pack).

Please refer to the various module preferences under game settings (as explained below).

## Changelog
See [CHANGELOG.md](CHANGELOG.md)
Expand Down
23 changes: 12 additions & 11 deletions src/sheet-locker/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ let permanentUIMsgID;
createControlButton(controls);
});

if (game.user.isGM) {
Hooks.on("refreshToken", async () => {
await renderTokenOverlays();
});
}
Hooks.on("drawToken", () => {
renderTokenOverlays();
});
Hooks.on("refreshToken", () => {
renderTokenOverlays();
});

renderTokenOverlays();
stateChangeUIMessage();
});
}
Expand Down Expand Up @@ -209,12 +209,13 @@ function onItemDeletedFromSheet(item, options, userid) {
*/
async function renderTokenOverlays() {
let img = (SheetLocker.isActive) ? Config.setting('lockedStatusIcon') : "";
/*if (token != null && aToken.actorLink) {
await token.update({overlayEffect: img});
return;
} else */for (const aToken of game.scenes.current.tokens) {
for (const aToken of game.scenes.current.tokens) {
if (aToken.actorLink) {
await aToken.update({overlayEffect: img});
const ownedActor = game.actors.find((actor)=>{return (actor.id === game.users.current.character?.id)});
if (game.user.isGM || aToken.actorId === ownedActor?.id) {
//Logger.debug("aToken.actorId", aToken.actorId, "ownedActor?.id", ownedActor?.id);
await aToken.update({overlayEffect: img});
}
}
}
}
Expand Down

0 comments on commit f3bc989

Please sign in to comment.