From eaf9cda07ec465307cb33f4b14fc71e0814a5c61 Mon Sep 17 00:00:00 2001 From: ymayarajan3 Date: Mon, 8 Jul 2024 23:41:34 -0400 Subject: [PATCH] comment cleanup --- .../mixins/base/scratchVersioning/index.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/extensions/src/common/extension/mixins/base/scratchVersioning/index.ts b/extensions/src/common/extension/mixins/base/scratchVersioning/index.ts index 3edb6c74c..f8d35d8f4 100644 --- a/extensions/src/common/extension/mixins/base/scratchVersioning/index.ts +++ b/extensions/src/common/extension/mixins/base/scratchVersioning/index.ts @@ -201,14 +201,16 @@ export default function (Ctor: BaseScratchExtensionConstuctor) { // Update the ArgEntry objects' IDs and get position mappings const { newEntries, mappings } = this.updateEntries(entries); totalList = newEntries; - // Update variable positions + // Change the menu block value if applicable for (const key of Object.keys(menus)) { if (mappings[key]) { let value = newEntries[mappings[key]].value; object.blocks[menus[key]].fields["0"][0] = value; } } + // Update menu positions menus = this.updateDictionary(menus, mappings); + // Update variable positions variables = this.updateDictionary(variables, mappings); } if (versions[i].previousType) { @@ -222,10 +224,12 @@ export default function (Ctor: BaseScratchExtensionConstuctor) { // Re-create the project JSON inputs/fields with the new values for (let i = 0; i < Object.keys(blockArgs).length; i++) { const argIndex = Object.keys(blockArgs)[i]; - // If there's a variable in the argIndex position + // If there's a menu block in the argIndex position if (Object.keys(menus).includes(argIndex)) { newInputs[argIndex] = [1, menus[argIndex]]; - } else if (Object.keys(variables).includes(argIndex)) { + } + // If there's a variable in the argIndex position + else if (Object.keys(variables).includes(argIndex)) { newInputs[argIndex] = variables[argIndex]; } // If we need to place the value in a field @@ -477,11 +481,14 @@ export default function (Ctor: BaseScratchExtensionConstuctor) { if (typeof input[1] == "string") { const variableBlock = blocks[input[1]]; if (variableBlock) { + // Store the block ID if the variable is a menu block if (variableBlock.opcode.includes("_menu_")) { menu[keyIndex] = input[1]; + // Find the menu block value const menuValue = variableBlock.fields["0"][0]; args.push({id: keyIndex, value: menuValue}); } else { + // Set the variables dictionary accordingly variables[keyIndex] = [ 3, input[1], @@ -490,9 +497,6 @@ export default function (Ctor: BaseScratchExtensionConstuctor) { args.push({id: keyIndex, value: input[2][1]}); } } - // Set the variables dictionary accordingly - - } else { // If the input is a value, push that value according to type const type = parseFloat(input[1][0]);