From c1528ab96e90404fdaad41646408e2de4a21ac83 Mon Sep 17 00:00:00 2001 From: GarboMuffin Date: Tue, 9 Jan 2024 13:19:52 -0600 Subject: [PATCH] Lily/Assets: alert user for packaged runtime (#1232) --- extensions/Lily/Assets.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/extensions/Lily/Assets.js b/extensions/Lily/Assets.js index ad5e3aaebb..4bc3f19adf 100644 --- a/extensions/Lily/Assets.js +++ b/extensions/Lily/Assets.js @@ -11,6 +11,16 @@ const runtime = vm.runtime; const Cast = Scratch.Cast; + const requireNonPackagedRuntime = (blockName) => { + if (vm.runtime.isPackaged) { + alert( + `To use the Asset Manager ${blockName} block, the creator of the packaged project must uncheck "Remove raw asset data after loading to save RAM" under advanced settings in the packager.` + ); + return false; + } + return true; + }; + class Assets { getInfo() { return { @@ -517,14 +527,18 @@ const costume = target.sprite.costumes[costumeIndex]; switch (attribute) { case "dataURI": + if (!requireNonPackagedRuntime("dataURI of costume")) return ""; return costume.asset.encodeDataURI(); case "index": return costumeIndex + 1; case "format": + if (!requireNonPackagedRuntime("format of costume")) return ""; return costume.asset.assetType.runtimeFormat; case "header": + if (!requireNonPackagedRuntime("header of costume")) return ""; return costume.asset.assetType.contentType; case "asset ID": + if (!requireNonPackagedRuntime("asset ID of costume")) return ""; return costume.asset.assetId; default: return ""; @@ -541,14 +555,18 @@ const sound = target.sprite.sounds[soundIndex]; switch (attribute) { case "dataURI": + if (!requireNonPackagedRuntime("dataURI of sound")) return ""; return sound.asset.encodeDataURI(); case "index": return soundIndex + 1; case "format": + if (!requireNonPackagedRuntime("format of sound")) return ""; return sound.asset.assetType.runtimeFormat; case "header": + if (!requireNonPackagedRuntime("header of sound")) return ""; return sound.asset.assetType.contentType; case "asset ID": + if (!requireNonPackagedRuntime("asset ID of sound")) return ""; return sound.asset.assetId; default: return "";