Skip to content

Commit

Permalink
Lily/Assets: alert user for packaged runtime (#1232)
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Jan 9, 2024
1 parent 95d37cb commit c1528ab
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions extensions/Lily/Assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 "";
Expand All @@ -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 "";
Expand Down

0 comments on commit c1528ab

Please sign in to comment.