diff --git a/extensions/TheShovel/ShovelUtils.js b/extensions/TheShovel/ShovelUtils.js index bbbba655e0..8533cfdb22 100644 --- a/extensions/TheShovel/ShovelUtils.js +++ b/extensions/TheShovel/ShovelUtils.js @@ -1,6 +1,9 @@ (function (Scratch) { 'use strict'; - console.log("ShovelUtils v1.3"); + if (!Scratch.extensions.unsandboxed) { + throw new Error('ShovelUtils must be run unsandboxed'); + } + console.log("ShovelUtils v1.4"); const vm = Scratch.vm; // Based on from https://www.growingwiththeweb.com/2017/12/fast-simple-js-fps-counter.html @@ -138,6 +141,21 @@ } } }, + { + opcode: 'deleteImage', + blockType: Scratch.BlockType.COMMAND, + text: 'Delete costume [COSNAME] in [SPRITE]', + arguments: { + COSNAME: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'costume1' + }, + SPRITE: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'Sprite1' + } + } + }, { opcode: 'setedtarget', blockType: Scratch.BlockType.COMMAND, @@ -162,6 +180,11 @@ } }, + { + opcode: 'getAllSprites', + blockType: Scratch.BlockType.REPORTER, + text: 'get all sprites' + }, { opcode: 'getfps', blockType: Scratch.BlockType.REPORTER, @@ -328,8 +351,25 @@ getfps(){ return fps; } - } + deleteImage({ SPRITE, COSNAME }){ + // 0znzw, since shovel did not add it yet. + const target = vm.runtime.getSpriteTargetByName(SPRITE); + if (!target) { + return; + } + target.deleteCostume(target.getCostumeIndexByName(COSNAME)); + } + + getAllSprites(){ + // 0znzw, since shovel did not add it yet. + let sprites = []; + for (const target of vm.runtime.targets) { + if (target.isOriginal) sprites.push(target.sprite.name); + } + return JSON.stringify(sprites); + } + } Scratch.extensions.register(new ShovelUtils()); // @ts-ignore })(Scratch);