From 93983a291877f4fa7baee848081985767e308573 Mon Sep 17 00:00:00 2001 From: Muffin Date: Wed, 16 Oct 2024 16:38:15 -0500 Subject: [PATCH] Lily/ClonesPlus, Lily/LooksPlus, Skyhigh173/json: editingTarget can be null (#1727) for example, extensions can be loaded while the project is still loading should resolve https://discordapp.com/channels/837024174865776680/1285154510527922186 --- extensions/Lily/ClonesPlus.js | 10 +++++----- extensions/Lily/LooksPlus.js | 4 ++-- extensions/Skyhigh173/json.js | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/extensions/Lily/ClonesPlus.js b/extensions/Lily/ClonesPlus.js index 21fb181f53..ff03493ad0 100644 --- a/extensions/Lily/ClonesPlus.js +++ b/extensions/Lily/ClonesPlus.js @@ -643,11 +643,11 @@ getSprites() { let spriteNames = []; const targets = Scratch.vm.runtime.targets; - const myself = Scratch.vm.runtime.getEditingTarget().sprite.name; + const editingTarget = Scratch.vm.runtime.getEditingTarget(); for (let index = 1; index < targets.length; index++) { - const curTarget = targets[index].sprite; - let display = curTarget.name; - if (myself === curTarget.name) { + const curTarget = targets[index]; + let display = curTarget.getName(); + if (editingTarget === curTarget) { display = Scratch.translate({ default: "myself", description: "Item in a dropdown that refers to the current sprite", @@ -656,7 +656,7 @@ if (targets[index].isOriginal) { const jsonOBJ = { text: display, - value: curTarget.name, + value: curTarget.getName(), }; spriteNames.push(jsonOBJ); } diff --git a/extensions/Lily/LooksPlus.js b/extensions/Lily/LooksPlus.js index df18e449be..2a7bc3bfe5 100644 --- a/extensions/Lily/LooksPlus.js +++ b/extensions/Lily/LooksPlus.js @@ -583,12 +583,12 @@ getSprites() { const spriteNames = []; const targets = Scratch.vm.runtime.targets; - const myself = Scratch.vm.runtime.getEditingTarget().getName(); + const editingTarget = Scratch.vm.runtime.getEditingTarget(); for (let index = 1; index < targets.length; index++) { const target = targets[index]; if (target.isOriginal) { const targetName = target.getName(); - if (targetName === myself) { + if (target === editingTarget) { spriteNames.unshift({ text: "this sprite", value: targetName, diff --git a/extensions/Skyhigh173/json.js b/extensions/Skyhigh173/json.js index 22e6d8aaf0..638df3ada1 100644 --- a/extensions/Skyhigh173/json.js +++ b/extensions/Skyhigh173/json.js @@ -565,10 +565,12 @@ getLists() { const globalLists = Object.values( vm.runtime.getTargetForStage().variables - ).filter((x) => x.type == "list"); - const localLists = Object.values(vm.editingTarget.variables).filter( - (x) => x.type == "list" - ); + ).filter((x) => x.type === "list"); + const localLists = vm.editingTarget + ? Object.values(vm.editingTarget.variables).filter( + (x) => x.type === "list" + ) + : []; const uniqueLists = [...new Set([...globalLists, ...localLists])]; if (uniqueLists.length === 0) { return [