SpectralCiphers / safety-tools

Safety tools for Foundry VTT
BSD 3-Clause "New" or "Revised" License
3 stars 10 forks source link

Error: The SafetyToolsLayer subclass of CanvasLayer must define the _draw method #11

Open mundusartis opened 1 year ago

mundusartis commented 1 year ago

The module has issues, causing it to be listed as incompatible with version 10. Additionally, Foundry fails to load all of my maps so long as this module is active. Below is a pasted error log entry

Canvas drawing failed: The SafetyToolsLayer subclass of CanvasLayer must define the _draw method

Error: The SafetyToolsLayer subclass of CanvasLayer must define the _draw method
[No packages detected]
    at SafetyToolsLayer._draw (foundry.js:30222)
    at SafetyToolsLayer.draw (foundry.js:30210)

This error comes up regardless or whether or not other modules are installed alongside it. The resulting behavior is map screens load but the map layers fail to rez.

DrMcCoy commented 1 year ago

Yeah, seems like this module is incompatible wth Foundry VTT V10 for now :(

DrMcCoy commented 1 year ago

Okay, I found the problem. SafetyToolsLayer needs to extend InteractionLayer now instead of CanvasLayer.

I've opened up a PR at #12. In the meanwhile, this here is a patch that can be applied to the built module in the foundry modules directory:

diff -ur modules/safety-tools.orig/src/SafetyToolsLayer.js modules/safety-tools/src/SafetyToolsLayer.js
--- modules/safety-tools.orig/src/SafetyToolsLayer.js   2022-10-31 21:12:01.503967054 +0100
+++ modules/safety-tools/src/SafetyToolsLayer.js    2022-10-31 21:11:40.912047467 +0100
@@ -7,7 +7,7 @@
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
 };
-export class SafetyToolsLayer extends CanvasLayer {
+export class SafetyToolsLayer extends InteractionLayer {
    constructor() {
        super();
        console.log('Safety Tools | Loaded into canvas');
mundusartis commented 1 year ago

Which line do I paste this into?

On Mon, Oct 31, 2022, 1:24 PM Sven Hesse @.***> wrote:

Okay, I found the problem. SafetyToolsLayer needs to extend InteractionLayer now instead of CanvasLayer.

I've opened up a PR at #12 https://github.com/SpectralCiphers/safety-tools/pull/12. In the meanwhile, this here is a patch that can be applied to the built module in the foundry modules directory:

diff -ur modules/safety-tools.orig/src/SafetyToolsLayer.js modules/safety-tools/src/SafetyToolsLayer.js --- modules/safety-tools.orig/src/SafetyToolsLayer.js 2022-10-31 21:12:01.503967054 +0100 +++ modules/safety-tools/src/SafetyToolsLayer.js 2022-10-31 21:11:40.912047467 +0100 @@ -7,7 +7,7 @@ step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -export class SafetyToolsLayer extends CanvasLayer { +export class SafetyToolsLayer extends InteractionLayer { constructor() { super(); console.log('Safety Tools | Loaded into canvas');

— Reply to this email directly, view it on GitHub https://github.com/SpectralCiphers/safety-tools/issues/11#issuecomment-1297639507, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZWWYNRMTKX3SX6DU5UTSMTWGATIPANCNFSM6AAAAAARRU7JGQ . You are receiving this because you authored the thread.Message ID: @.***>

DrMcCoy commented 1 year ago

Oof, no, that's a Unix style patch. You'd save that text into a file, and then apply it with the command line tool "patch". If you're not accustomed to that, that's a bit of a steep hill for something this small.

You can fix it manually, if you want. You need to go into your foundry data directory, subfolders Data/modules/safety-tools/src/ . In there is a SafetyToolsLayer.js file. On line 10, change "CanvasLayer" to "InteractionLayer". Save and restart foundry. Now it should work.

mundusartis commented 1 year ago

Got it.

On Mon, Oct 31, 2022, 1:30 PM Sven Hesse @.***> wrote:

Oof, no, that's a Unix style patch. You'd save that text into a file, and then apply it with the command line tool "patch". If you're not accustomed to that, that's a bit of a steep hill for something this small.

You can fix it manually, if you want. You need to go into your foundry data directory, subfolders Data/modules/safety-tools/src/ . In there is a SafetyToolsLayer.js file. On line 10, change "CanvasLayer" to "InteractionLayer". Save and restart foundry. Now it should work.

— Reply to this email directly, view it on GitHub https://github.com/SpectralCiphers/safety-tools/issues/11#issuecomment-1297645308, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZWWYNT2PLZSFVWVYOPXUFLWGAT4TANCNFSM6AAAAAARRU7JGQ . You are receiving this because you authored the thread.Message ID: @.***>

mundusartis commented 1 year ago

Yep that's the exact precise fix needed. Applied the change to line 10, saved the file, reloaded the module, and all errors are now gone.