From 21ef3016d027442ef53ee67359d68af5af1c506a Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sun, 25 Jun 2023 18:55:31 +0100 Subject: [PATCH 01/47] Add files via upload --- extensions/Lily/MoreEvents.js | 378 ++++++++++++++++++++++++++++++++++ 1 file changed, 378 insertions(+) create mode 100644 extensions/Lily/MoreEvents.js diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js new file mode 100644 index 0000000000..be13c6b500 --- /dev/null +++ b/extensions/Lily/MoreEvents.js @@ -0,0 +1,378 @@ +(function (Scratch) { + 'use strict'; + + const vm = Scratch.vm; + const runtime = vm.runtime; + + let frameToggle = false; + + const stopIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAQlBMVEUAAAC/UFC8Q0OzTU24SEi4SEi3SEi4R0e4SEi4SEi4SEi4SEi7SUm8SUnMTk7MT0/OT0/PT0/gVVXiVVXsWVn///+CoOd2AAAAC3RSTlMAEBMUu7zLz9D8/dIXnJwAAAABYktHRBXl2PmjAAAAxklEQVRIx+3WwRKDIBAD0JWqVEOtWv7/W3twOqKwELzW3N9wYhORMMYiztgZUZMUAKxqmh5Kno/MG256nzI59Z2mB+BWH+XzUt5RhWoyQjFZkTQFkTBFERlCnAwlDoYUgaHFblpaeL86AK0MvNjMIABmT2cGIAAWniw3ucm/k9ovduEjXzgXtUfJmtrTt9VZzYH9FSB/xvfKZMsiLFmuko61zBTfucjL9RpXf6nEU2MhPxXS86J+kORmjz6V6seViOnG8oT7ApMcjsYZwhXCAAAAAElFTkSuQmCC'; + + // Source: + // https://github.com/TurboWarp/scratch-vm/blob/develop/src/io/keyboard.js + // https://github.com/TurboWarp/scratch-blocks/blob/develop/blocks_vertical/event.js + const validKeyboardInputs = [ + // Special Inputs + { text: 'any', value: '_any_' }, + { text: 'space', value: 'space' }, + { text: 'left arrow', value: 'left arrow' }, + { text: 'up arrow', value: 'up arrow' }, + { text: 'right arrow', value: 'right arrow' }, + { text: 'down arrow', value: 'down arrow' }, + { text: 'enter', value: 'enter' }, + // TW: Extra Special Inputs + { text: 'backspace', value: 'backspace' }, + { text: 'delete', value: 'delete' }, + { text: 'shift', value: 'shift' }, + { text: 'caps lock', value: 'caps lock' }, + { text: 'scroll lock', value: 'scroll lock' }, + { text: 'control', value: 'control' }, + { text: 'escape', value: 'escape' }, + { text: 'insert', value: 'insert' }, + { text: 'home', value: 'home' }, + { text: 'end', value: 'end' }, + { text: 'page up', value: 'page up' }, + { text: 'page down', value: 'page down' }, + // Letter Keyboard Inputs + { text: 'a', value: 'a' }, + { text: 'b', value: 'b' }, + { text: 'c', value: 'c' }, + { text: 'd', value: 'd' }, + { text: 'e', value: 'e' }, + { text: 'f', value: 'f' }, + { text: 'g', value: 'g' }, + { text: 'h', value: 'h' }, + { text: 'i', value: 'i' }, + { text: 'j', value: 'j' }, + { text: 'k', value: 'k' }, + { text: 'l', value: 'l' }, + { text: 'm', value: 'm' }, + { text: 'n', value: 'n' }, + { text: 'o', value: 'o' }, + { text: 'p', value: 'p' }, + { text: 'q', value: 'q' }, + { text: 'r', value: 'r' }, + { text: 's', value: 's' }, + { text: 't', value: 't' }, + { text: 'u', value: 'u' }, + { text: 'v', value: 'v' }, + { text: 'w', value: 'w' }, + { text: 'x', value: 'x' }, + { text: 'y', value: 'y' }, + { text: 'z', value: 'z' }, + // Number Keyboard Inputs + { text: '0', value: '0' }, + { text: '1', value: '1' }, + { text: '2', value: '2' }, + { text: '3', value: '3' }, + { text: '4', value: '4' }, + { text: '5', value: '5' }, + { text: '6', value: '6' }, + { text: '7', value: '7' }, + { text: '8', value: '8' }, + { text: '9', value: '9' }, + ]; + + setInterval(() => { + runtime.startHats('lmsMoreEvents_always', { + CONDITION: 'true' + }); + runtime.startHats('lmsMoreEvents_whileTurboMode', { + STATE: (runtime.turboMode) ? 'enabled' : 'disabled' + }); + }); + + class MoreEvents { + constructor() { + runtime.on('STAGE_SIZE_CHANGED', () => { + runtime.startHats('lmsMoreEvents_whenRuntimeOptionChanged', { + OPTION: 'stage size' + }); + }); + + runtime.on('FRAMERATE_CHANGED', () => { + runtime.startHats('lmsMoreEvents_whenRuntimeOptionChanged', { + OPTION: 'framerate' + }); + }); + + runtime.on('INTERPOLATION_CHANGED', () => { + runtime.startHats('lmsMoreEvents_whenRuntimeOptionChanged', { + OPTION: 'interpolation' + }); + }); + + runtime.on('RUNTIME_OPTIONS_CHANGED', () => { + runtime.startHats('lmsMoreEvents_whenAnyRuntimeOptionChanged'); + }); + + runtime.on('EXTENSION_ADDED', () => { + runtime.startHats('lmsMoreEvents_whenExtensionAdded'); + }); + } + + getInfo() { + return { + id: 'lmsMoreEvents', + name: 'More Events', + color1: '#FFBF00', + color2: '#E6AC00', + color3: '#CC9900', + blocks: [ + /* + { + opcode: 'whenStopClicked', + blockType: Scratch.BlockType.HAT, + text: 'when [STOP] clicked', + isEdgeActivated: false, + arguments: { + STOP: { + type: Scratch.ArgumentType.IMAGE, + dataURI: stopIcon + } + } + }, + */ + { + opcode: 'whenTrue', + blockType: Scratch.BlockType.HAT, + text: 'when [CONDITION] is true', + isEdgeActivated: true, + arguments: { + CONDITION: { + type: Scratch.ArgumentType.BOOLEAN + } + } + }, + { + opcode: 'whenKeyStringPressed', + blockType: Scratch.BlockType.HAT, + text: 'when [KEY_OPTION] key pressed', + isEdgeActivated: true, + arguments: { + KEY_OPTION: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'space' + } + } + }, + { + opcode: 'always', + blockType: Scratch.BlockType.HAT, + text: 'always return [CONDITION]', + isEdgeActivated: false, + arguments: { + CONDITION: { + type: Scratch.ArgumentType.STRING, + menu: 'boolean' + } + } + }, + + '---', + + { + opcode: 'broadcastToTarget', + blockType: Scratch.BlockType.COMMAND, + text: 'broadcast [BROADCAST_OPTION] to [TARGET]', + arguments: { + BROADCAST_OPTION: { + type: Scratch.ArgumentType.STRING, + menu: 'broadcastMenu' + }, + TARGET: { + type: Scratch.ArgumentType.STRING, + menu: 'targetMenu' + } + } + }, + { + opcode: 'broadcastAll', + blockType: Scratch.BlockType.COMMAND, + text: 'broadcast everything' + }, + + '---', + + { + opcode: 'whileTurboMode', + blockType: Scratch.BlockType.HAT, + text: 'while turbo mode is [STATE]', + isEdgeActivated: false, + arguments: { + STATE: { + type: Scratch.ArgumentType.STRING, + menu: 'state' + } + } + }, + { + opcode: 'whenRuntimeOptionChanged', + blockType: Scratch.BlockType.HAT, + text: 'when [OPTION] is changed', + isEdgeActivated: false, + arguments: { + OPTION: { + type: Scratch.ArgumentType.STRING, + menu: 'runtimeOptions' + } + } + }, + { + opcode: 'whenAnyRuntimeOptionChanged', + blockType: Scratch.BlockType.HAT, + text: 'when runtime options changed', + isEdgeActivated: false + }, + { + opcode: 'whenExtensionAdded', + blockType: Scratch.BlockType.HAT, + text: 'when extension added', + isEdgeActivated: false, + arguments: { + EXT: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'utilities' + } + } + }, + + '---', + + { + opcode: 'startHats', + blockType: Scratch.BlockType.COMMAND, + text: 'start hats [HAT]', + arguments: { + HAT: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'event_whenflagclicked' + } + } + }, + { + opcode: 'startHatsInTarget', + blockType: Scratch.BlockType.COMMAND, + text: 'start hats [HAT] in [TARGET]', + arguments: { + HAT: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'event_whenflagclicked' + }, + TARGET: { + type: Scratch.ArgumentType.STRING, + menu: 'targetMenu' + } + } + } + ], + menus: { + // Targets have acceptReporters: true + targetMenu: { + acceptReporters: true, + items: '_getTargets' + }, + broadcastMenu: { + acceptReporters: true, + items: '_getBroadcastMsgs' + }, + // Attributes have acceptReporters: false + boolean: { + acceptReporters: false, + items: ['true', 'false'] + }, + keyboardButtons: { // This isn't used just yet + acceptReporters: false, + items: validKeyboardInputs + }, + state: { + acceptReporters: false, + items: ['enabled', 'disabled'] + }, + runtimeOptions: { + acceptReporters: false, + items: ['framerate', 'stage size', 'interpolation'] + }, + startStop: { + acceptReporters: false, + items: ['started', 'stopped'] + } + } + }; + } + + whenKeyStringPressed(args, util) { + const pressed = util.ioQuery('keyboard', 'getKeyIsDown', [args.KEY_OPTION]); + return pressed; + } + + whenTrue(args) { + return args.CONDITION; + } + + broadcastToTarget(args, util) { + if (!args.BROADCAST_OPTION) return; + const broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg(args.BROADCAST_OPTION); + if (!broadcastVar) return; + const target = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); + util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, target); + } + + broadcastAll(args, util) { + util.startHats('event_whenbroadcastreceived'); + } + + startHats(args, util) { + util.startHats(args.HAT); + } + + startHatsInTarget(args, util) { + const target = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); + util.startHats(args.HAT, null, target); + } + + _getTargets() { + const spriteNames = []; + const targets = Scratch.vm.runtime.targets; + const myself = Scratch.vm.runtime.getEditingTarget().getName(); + for (let index = 1; index < targets.length; index++) { + const targetName = targets[index].getName(); + if (targetName === myself) { + spriteNames.unshift({ + text: 'this sprite', + value: targetName + }); + } else { + spriteNames.push({ + text: targetName, + value: targetName + }); + } + } + if (spriteNames.length > 0) { + return spriteNames; + } else { + return [{text: "", value: 0}]; //this should never happen but it's a failsafe + } + } + + _getBroadcastMsgs() { + // @ts-expect-error - Blockly not typed yet + // eslint-disable-next-line no-undef + const broadcasts = typeof Blockly === 'undefined' ? [] : Blockly.getMainWorkspace() + .getVariableMap() + .getVariablesOfType('broadcast_msg') + .map(model => ({ + text: model.name, + value: model.getId() + })); + if (broadcasts.length > 0) { + return broadcasts; + } else { + return [{ text: "", value: 0 }]; + } + } + } + + Scratch.extensions.register(new MoreEvents()); +})(Scratch); \ No newline at end of file From c7c96b980b0ff2b30a4cd195a4c0426934a60a53 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sun, 25 Jun 2023 19:19:33 +0100 Subject: [PATCH 02/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index be13c6b500..567f31e589 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -1,10 +1,8 @@ (function (Scratch) { 'use strict'; - + const vm = Scratch.vm; const runtime = vm.runtime; - - let frameToggle = false; const stopIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAQlBMVEUAAAC/UFC8Q0OzTU24SEi4SEi3SEi4R0e4SEi4SEi4SEi4SEi7SUm8SUnMTk7MT0/OT0/PT0/gVVXiVVXsWVn///+CoOd2AAAAC3RSTlMAEBMUu7zLz9D8/dIXnJwAAAABYktHRBXl2PmjAAAAxklEQVRIx+3WwRKDIBAD0JWqVEOtWv7/W3twOqKwELzW3N9wYhORMMYiztgZUZMUAKxqmh5Kno/MG256nzI59Z2mB+BWH+XzUt5RhWoyQjFZkTQFkTBFERlCnAwlDoYUgaHFblpaeL86AK0MvNjMIABmT2cGIAAWniw3ucm/k9ovduEjXzgXtUfJmtrTt9VZzYH9FSB/xvfKZMsiLFmuko61zBTfucjL9RpXf6nEU2MhPxXS86J+kORmjz6V6seViOnG8oT7ApMcjsYZwhXCAAAAAElFTkSuQmCC'; @@ -355,7 +353,7 @@ return [{text: "", value: 0}]; //this should never happen but it's a failsafe } } - + _getBroadcastMsgs() { // @ts-expect-error - Blockly not typed yet // eslint-disable-next-line no-undef @@ -375,4 +373,4 @@ } Scratch.extensions.register(new MoreEvents()); -})(Scratch); \ No newline at end of file +})(Scratch); From 6da7fb75de499e96db6a2f02301df3b907ef850d Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sun, 25 Jun 2023 19:21:40 +0100 Subject: [PATCH 03/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 567f31e589..7b1254d108 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -117,7 +117,11 @@ color2: '#E6AC00', color3: '#CC9900', blocks: [ - /* + /** + * I have a feeling this won't work unless there's an + * event specifically to detect the stop button + * being clicked. I'm still going to work on this as + * I'm sure there's a way to prevent the recursion. { opcode: 'whenStopClicked', blockType: Scratch.BlockType.HAT, From e32db293e9600c0e39f89a83c7bd50248095d2a6 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sun, 25 Jun 2023 19:23:16 +0100 Subject: [PATCH 04/47] Remove runtime options changed --- extensions/Lily/MoreEvents.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 7b1254d108..e59d3e1659 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -100,10 +100,6 @@ }); }); - runtime.on('RUNTIME_OPTIONS_CHANGED', () => { - runtime.startHats('lmsMoreEvents_whenAnyRuntimeOptionChanged'); - }); - runtime.on('EXTENSION_ADDED', () => { runtime.startHats('lmsMoreEvents_whenExtensionAdded'); }); @@ -220,12 +216,6 @@ } } }, - { - opcode: 'whenAnyRuntimeOptionChanged', - blockType: Scratch.BlockType.HAT, - text: 'when runtime options changed', - isEdgeActivated: false - }, { opcode: 'whenExtensionAdded', blockType: Scratch.BlockType.HAT, From a1b51d635702d2d3d5bc73dd896c618972301c45 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Tue, 27 Jun 2023 22:17:33 +0100 Subject: [PATCH 05/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 87 +++++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 24 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index e59d3e1659..372c480b50 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -11,12 +11,11 @@ // https://github.com/TurboWarp/scratch-blocks/blob/develop/blocks_vertical/event.js const validKeyboardInputs = [ // Special Inputs - { text: 'any', value: '_any_' }, { text: 'space', value: 'space' }, - { text: 'left arrow', value: 'left arrow' }, { text: 'up arrow', value: 'up arrow' }, - { text: 'right arrow', value: 'right arrow' }, { text: 'down arrow', value: 'down arrow' }, + { text: 'right arrow', value: 'right arrow' }, + { text: 'left arrow', value: 'left arrow' }, { text: 'enter', value: 'enter' }, // TW: Extra Special Inputs { text: 'backspace', value: 'backspace' }, @@ -75,13 +74,20 @@ runtime.startHats('lmsMoreEvents_always', { CONDITION: 'true' }); + runtime.startHats('lmsMoreEvents_whileTurboMode', { STATE: (runtime.turboMode) ? 'enabled' : 'disabled' }); }); + var lastValues = {}; + class MoreEvents { constructor() { + runtime.on('PROJECT_RUN_STOP', () => { + runtime.startHats('lmsMoreEvents_whenStopClicked'); + }); + runtime.on('STAGE_SIZE_CHANGED', () => { runtime.startHats('lmsMoreEvents_whenRuntimeOptionChanged', { OPTION: 'stage size' @@ -113,11 +119,7 @@ color2: '#E6AC00', color3: '#CC9900', blocks: [ - /** - * I have a feeling this won't work unless there's an - * event specifically to detect the stop button - * being clicked. I'm still going to work on this as - * I'm sure there's a way to prevent the recursion. + /* { opcode: 'whenStopClicked', blockType: Scratch.BlockType.HAT, @@ -132,25 +134,28 @@ }, */ { - opcode: 'whenTrue', + opcode: 'whenTrueFalse', blockType: Scratch.BlockType.HAT, - text: 'when [CONDITION] is true', + text: 'when [CONDITION] is [STATE]', isEdgeActivated: true, arguments: { CONDITION: { type: Scratch.ArgumentType.BOOLEAN + }, + STATE: { + type: Scratch.ArgumentType.STRING, + menu: 'boolean' } } }, { - opcode: 'whenKeyStringPressed', + opcode: 'whenValueChanged', blockType: Scratch.BlockType.HAT, - text: 'when [KEY_OPTION] key pressed', + text: 'when [INPUT] changed', isEdgeActivated: true, arguments: { - KEY_OPTION: { - type: Scratch.ArgumentType.STRING, - defaultValue: 'space' + INPUT: { + type: Scratch.ArgumentType.STRING } } }, @@ -169,6 +174,26 @@ '---', + { + opcode: 'whenKeyAction', + blockType: Scratch.BlockType.HAT, + text: 'when [KEY_OPTION] key [ACTION]', + isEdgeActivated: true, + arguments: { + KEY_OPTION: { + type: Scratch.ArgumentType.STRING, + defaultValue: 'space', + menu: 'keyboardButtons' + }, + ACTION: { + type: Scratch.ArgumentType.STRING, + menu: 'action' + } + } + }, + + '---', + { opcode: 'broadcastToTarget', blockType: Scratch.BlockType.COMMAND, @@ -268,14 +293,18 @@ acceptReporters: true, items: '_getBroadcastMsgs' }, + keyboardButtons: { + acceptReporters: true, + items: validKeyboardInputs + }, // Attributes have acceptReporters: false - boolean: { + action: { acceptReporters: false, - items: ['true', 'false'] + items: ['hit', 'released'] }, - keyboardButtons: { // This isn't used just yet + boolean: { acceptReporters: false, - items: validKeyboardInputs + items: ['true', 'false'] }, state: { acceptReporters: false, @@ -293,13 +322,23 @@ }; } - whenKeyStringPressed(args, util) { - const pressed = util.ioQuery('keyboard', 'getKeyIsDown', [args.KEY_OPTION]); - return pressed; + whenTrueFalse(args) { + return (args.STATE === 'true') ? args.CONDITION : !args.CONDITION; } - whenTrue(args) { - return args.CONDITION; + whenValueChanged(args, blockInfo) { + const blockId = blockInfo.thread.topBlock; + if (!lastValues[blockId]) lastValues[blockId] = Scratch.Cast.toString(args.INPUT); + if (lastValues[blockId] !== Scratch.Cast.toString(args.INPUT)) { + lastValues[blockId] = Scratch.Cast.toString(args.INPUT); + return true; + } + return false; + } + + whenKeyAction(args, util) { + const pressed = util.ioQuery('keyboard', 'getKeyIsDown', [args.KEY_OPTION]); + return (args.ACTION === 'released') ? !pressed : pressed; } broadcastToTarget(args, util) { From 2e691474fd5dbed86125ece834de89bb6ff1f38c Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Tue, 27 Jun 2023 22:24:23 +0100 Subject: [PATCH 06/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 372c480b50..3eff91adda 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -149,6 +149,7 @@ } }, { + /* Credit to @mark-alex2004 for the idea */ opcode: 'whenValueChanged', blockType: Scratch.BlockType.HAT, text: 'when [INPUT] changed', From e33adb9878bd7d05485bce4319b797c2f808acdd Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 28 Jun 2023 00:12:56 +0100 Subject: [PATCH 07/47] we did it, reddit --- extensions/Lily/MoreEvents.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 3eff91adda..272658c45b 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -84,8 +84,16 @@ class MoreEvents { constructor() { - runtime.on('PROJECT_RUN_STOP', () => { - runtime.startHats('lmsMoreEvents_whenStopClicked'); + // Stop Sign Clicked contributed by @CST1229 + runtime.shouldExecuteStopClicked = true; + runtime.on('BEFORE_EXECUTE', () => { + runtime.shouldExecuteStopClicked = false; + }); + runtime.on('PROJECT_STOP_ALL', () => { + queueMicrotask(() => runtime.startHats('lmsMoreEvents_whenStopClicked')); + }); + runtime.on('AFTER_EXECUTE', () => { + runtime.shouldExecuteStopClicked = true; }); runtime.on('STAGE_SIZE_CHANGED', () => { @@ -119,7 +127,6 @@ color2: '#E6AC00', color3: '#CC9900', blocks: [ - /* { opcode: 'whenStopClicked', blockType: Scratch.BlockType.HAT, @@ -132,7 +139,6 @@ } } }, - */ { opcode: 'whenTrueFalse', blockType: Scratch.BlockType.HAT, @@ -149,7 +155,6 @@ } }, { - /* Credit to @mark-alex2004 for the idea */ opcode: 'whenValueChanged', blockType: Scratch.BlockType.HAT, text: 'when [INPUT] changed', From 2cbe898e9039f33830a9bc8b88a2072de545fb79 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 28 Jun 2023 00:15:05 +0100 Subject: [PATCH 08/47] reimplement missing if statement --- extensions/Lily/MoreEvents.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 272658c45b..27ae51ff3b 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -90,7 +90,8 @@ runtime.shouldExecuteStopClicked = false; }); runtime.on('PROJECT_STOP_ALL', () => { - queueMicrotask(() => runtime.startHats('lmsMoreEvents_whenStopClicked')); + if (runtime.shouldExecuteStopClicked) + queueMicrotask(() => runtime.startHats('lmsMoreEvents_whenStopClicked')); }); runtime.on('AFTER_EXECUTE', () => { runtime.shouldExecuteStopClicked = true; From 1e370e2d2917f74ff209ce83bda6776ff577821d Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 28 Jun 2023 00:38:37 +0100 Subject: [PATCH 09/47] when stop clicked fix - Fixes it being triggered by a green flag click - Modifies the VM function --- extensions/Lily/MoreEvents.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 27ae51ff3b..643017c022 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -96,6 +96,11 @@ runtime.on('AFTER_EXECUTE', () => { runtime.shouldExecuteStopClicked = true; }); + const originalGreenFlag = vm.greenFlag; + vm.greenFlag = function() { + runtime.shouldExecuteStopClicked = false; + originalGreenFlag.call(this); + }; runtime.on('STAGE_SIZE_CHANGED', () => { runtime.startHats('lmsMoreEvents_whenRuntimeOptionChanged', { From a99a92b22d809b662d2e233d97857f7caa9f9b0f Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 28 Jun 2023 00:42:55 +0100 Subject: [PATCH 10/47] Add MoreEvents.svg --- images/Lily/MoreEvents.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 images/Lily/MoreEvents.svg diff --git a/images/Lily/MoreEvents.svg b/images/Lily/MoreEvents.svg new file mode 100644 index 0000000000..9d410dea4d --- /dev/null +++ b/images/Lily/MoreEvents.svg @@ -0,0 +1 @@ +whenclicked \ No newline at end of file From ed162011da851cb0636f1e6d7da767ba4f32a751 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 28 Jun 2023 00:46:59 +0100 Subject: [PATCH 11/47] Update README.md --- images/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/images/README.md b/images/README.md index 39f6bbd570..e25ea19463 100644 --- a/images/README.md +++ b/images/README.md @@ -231,3 +231,7 @@ All images in this folder are licensed under the [GNU General Public License ver ## ZXMushroom63/searchApi.svg - Created by [@CST1229](https://github.com/CST1229) and [@BlueDome77](https://github.com/BlueDome77) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1596177193 + +## Lily/MoreEvents.svg +- Created by [@LilyMakesThings](https://scratch.mit.edu/users/LilyMakesThings/). +- Background "blobs" by Scratch From 582ea1a39c1a7f03e4479bf67605dc61cdf70af1 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 28 Jun 2023 01:02:22 +0100 Subject: [PATCH 12/47] Fix when key action - Fixes bug where keys that were in uppercase/not a string were not valid in the menu input. - Casts the key value to a string and forces it to lowercase. --- extensions/Lily/MoreEvents.js | 1 + 1 file changed, 1 insertion(+) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 643017c022..ebd76f24ba 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -349,6 +349,7 @@ } whenKeyAction(args, util) { + const key = Scratch.Cast.toString(args.KEY_OPTION).toLowerCase(); const pressed = util.ioQuery('keyboard', 'getKeyIsDown', [args.KEY_OPTION]); return (args.ACTION === 'released') ? !pressed : pressed; } From 4cb05b752ce64adcb8cf10e71a889b1a7c606fc0 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Fri, 30 Jun 2023 03:35:59 +0100 Subject: [PATCH 13/47] Delete MoreEvents.svg --- images/Lily/MoreEvents.svg | 1 - 1 file changed, 1 deletion(-) delete mode 100644 images/Lily/MoreEvents.svg diff --git a/images/Lily/MoreEvents.svg b/images/Lily/MoreEvents.svg deleted file mode 100644 index 9d410dea4d..0000000000 --- a/images/Lily/MoreEvents.svg +++ /dev/null @@ -1 +0,0 @@ -whenclicked \ No newline at end of file From 51177860bc647e9aac554fba664220785f0758f2 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Fri, 30 Jun 2023 03:36:04 +0100 Subject: [PATCH 14/47] Add files via upload --- images/Lily/MoreEvents.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 images/Lily/MoreEvents.svg diff --git a/images/Lily/MoreEvents.svg b/images/Lily/MoreEvents.svg new file mode 100644 index 0000000000..8c33d44f0a --- /dev/null +++ b/images/Lily/MoreEvents.svg @@ -0,0 +1 @@ +whenclicked \ No newline at end of file From fcc6168d2309d2774f42e7021ae8a7b573957894 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 5 Jul 2023 02:32:51 +0100 Subject: [PATCH 15/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index ebd76f24ba..97d9d0c6ce 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -338,8 +338,10 @@ return (args.STATE === 'true') ? args.CONDITION : !args.CONDITION; } - whenValueChanged(args, blockInfo) { - const blockId = blockInfo.thread.topBlock; + whenValueChanged(args, util) { + // I've come to realise that this is NOT the way to get the blockId. + // However, considering that the hat block will ALWAYS be the top block, it works fine. + const blockId = util.thread.topBlock; if (!lastValues[blockId]) lastValues[blockId] = Scratch.Cast.toString(args.INPUT); if (lastValues[blockId] !== Scratch.Cast.toString(args.INPUT)) { lastValues[blockId] = Scratch.Cast.toString(args.INPUT); From 14907dbeadb601554497dc768391cd3940be384b Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Fri, 7 Jul 2023 17:42:27 +0100 Subject: [PATCH 16/47] Patches in prep for GMTK --- extensions/Lily/MoreEvents.js | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 97d9d0c6ce..cfebfa5f33 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -339,9 +339,7 @@ } whenValueChanged(args, util) { - // I've come to realise that this is NOT the way to get the blockId. - // However, considering that the hat block will ALWAYS be the top block, it works fine. - const blockId = util.thread.topBlock; + const blockId = util.thread.peekStack(); if (!lastValues[blockId]) lastValues[blockId] = Scratch.Cast.toString(args.INPUT); if (lastValues[blockId] !== Scratch.Cast.toString(args.INPUT)) { lastValues[blockId] = Scratch.Cast.toString(args.INPUT); @@ -360,8 +358,10 @@ if (!args.BROADCAST_OPTION) return; const broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg(args.BROADCAST_OPTION); if (!broadcastVar) return; - const target = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); - util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, target); + const spriteTarget = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); + const cloneTargets = spriteTarget.sprite.clones; + cloneTargets.forEach(model => util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, model)); + util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, spriteTarget); } broadcastAll(args, util) { @@ -382,13 +382,9 @@ const targets = Scratch.vm.runtime.targets; const myself = Scratch.vm.runtime.getEditingTarget().getName(); for (let index = 1; index < targets.length; index++) { - const targetName = targets[index].getName(); - if (targetName === myself) { - spriteNames.unshift({ - text: 'this sprite', - value: targetName - }); - } else { + const target = targets[index]; + if (target.isOriginal) { + const targetName = target.getName(); spriteNames.push({ text: targetName, value: targetName From c7e60030d3451f65ecc472e578e34468b6d88829 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Fri, 7 Jul 2023 23:15:41 +0100 Subject: [PATCH 17/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index cfebfa5f33..98ab9b87ba 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -358,6 +358,10 @@ if (!args.BROADCAST_OPTION) return; const broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg(args.BROADCAST_OPTION); if (!broadcastVar) return; + if (args.TARGET = '_stage_') { + util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, runtime.getTargetForStage()); + return; + } const spriteTarget = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); const cloneTargets = spriteTarget.sprite.clones; cloneTargets.forEach(model => util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, model)); @@ -378,7 +382,7 @@ } _getTargets() { - const spriteNames = []; + const spriteNames = [{text: 'Stage', value: '_stage_'}]; const targets = Scratch.vm.runtime.targets; const myself = Scratch.vm.runtime.getEditingTarget().getName(); for (let index = 1; index < targets.length; index++) { From 8868c3848abb5d4d80271f40da6791aeab961018 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Mon, 17 Jul 2023 03:36:07 +0100 Subject: [PATCH 18/47] Update MoreEvents.js - Removed "when runtime options changed" - Removed "when extension added" --- extensions/Lily/MoreEvents.js | 79 +++++++---------------------------- 1 file changed, 15 insertions(+), 64 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 98ab9b87ba..597f7a62d9 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -70,15 +70,15 @@ { text: '9', value: '9' }, ]; - setInterval(() => { + vm.runtime.on('BEFORE_EXECUTE', () => { runtime.startHats('lmsMoreEvents_always', { CONDITION: 'true' }); - + runtime.startHats('lmsMoreEvents_whileTurboMode', { STATE: (runtime.turboMode) ? 'enabled' : 'disabled' }); - }); + }) var lastValues = {}; @@ -101,28 +101,6 @@ runtime.shouldExecuteStopClicked = false; originalGreenFlag.call(this); }; - - runtime.on('STAGE_SIZE_CHANGED', () => { - runtime.startHats('lmsMoreEvents_whenRuntimeOptionChanged', { - OPTION: 'stage size' - }); - }); - - runtime.on('FRAMERATE_CHANGED', () => { - runtime.startHats('lmsMoreEvents_whenRuntimeOptionChanged', { - OPTION: 'framerate' - }); - }); - - runtime.on('INTERPOLATION_CHANGED', () => { - runtime.startHats('lmsMoreEvents_whenRuntimeOptionChanged', { - OPTION: 'interpolation' - }); - }); - - runtime.on('EXTENSION_ADDED', () => { - runtime.startHats('lmsMoreEvents_whenExtensionAdded'); - }); } getInfo() { @@ -203,6 +181,18 @@ } } }, + { + opcode: 'whileTurboMode', + blockType: Scratch.BlockType.HAT, + text: 'while turbo mode is [STATE]', + isEdgeActivated: false, + arguments: { + STATE: { + type: Scratch.ArgumentType.STRING, + menu: 'state' + } + } + }, '---', @@ -229,45 +219,6 @@ '---', - { - opcode: 'whileTurboMode', - blockType: Scratch.BlockType.HAT, - text: 'while turbo mode is [STATE]', - isEdgeActivated: false, - arguments: { - STATE: { - type: Scratch.ArgumentType.STRING, - menu: 'state' - } - } - }, - { - opcode: 'whenRuntimeOptionChanged', - blockType: Scratch.BlockType.HAT, - text: 'when [OPTION] is changed', - isEdgeActivated: false, - arguments: { - OPTION: { - type: Scratch.ArgumentType.STRING, - menu: 'runtimeOptions' - } - } - }, - { - opcode: 'whenExtensionAdded', - blockType: Scratch.BlockType.HAT, - text: 'when extension added', - isEdgeActivated: false, - arguments: { - EXT: { - type: Scratch.ArgumentType.STRING, - defaultValue: 'utilities' - } - } - }, - - '---', - { opcode: 'startHats', blockType: Scratch.BlockType.COMMAND, From baaf3adcecb46aec9ec63fb9b55b93e2190221ea Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sat, 29 Jul 2023 03:51:14 +0100 Subject: [PATCH 19/47] Delete MoreEvents.svg --- images/Lily/MoreEvents.svg | 1 - 1 file changed, 1 deletion(-) delete mode 100644 images/Lily/MoreEvents.svg diff --git a/images/Lily/MoreEvents.svg b/images/Lily/MoreEvents.svg deleted file mode 100644 index 8c33d44f0a..0000000000 --- a/images/Lily/MoreEvents.svg +++ /dev/null @@ -1 +0,0 @@ -whenclicked \ No newline at end of file From 3770928908ebb40b93274730758b0a91013ed9b0 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sat, 29 Jul 2023 03:52:40 +0100 Subject: [PATCH 20/47] Add files via upload --- images/Lily/MoreEvents.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 images/Lily/MoreEvents.svg diff --git a/images/Lily/MoreEvents.svg b/images/Lily/MoreEvents.svg new file mode 100644 index 0000000000..7dd349bc18 --- /dev/null +++ b/images/Lily/MoreEvents.svg @@ -0,0 +1 @@ +whenclicked \ No newline at end of file From f52c6215659d82319c4f25cc1ad5d8fe8a9d6507 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sat, 29 Jul 2023 03:56:49 +0100 Subject: [PATCH 21/47] Update README.md --- images/README.md | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/images/README.md b/images/README.md index e25ea19463..7979556442 100644 --- a/images/README.md +++ b/images/README.md @@ -64,8 +64,7 @@ All images in this folder are licensed under the [GNU General Public License ver - Created by [@softedco](https://scratch.mit.edu/users/softed/) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1369138404. ## encoding.svg - - Created by @SIPC in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1396819269. - - Font is Noto Sans. + - Created by [@BlueDome77](https://github.com/BlueDome77) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1632625905 ## true-fantom/network.svg - Created by [@True-Fantom](https://scratch.mit.edu/users/TrueFantom/) in https://github.com/TurboWarp/extensions/pull/122#issue-1524383752. @@ -106,12 +105,12 @@ All images in this folder are licensed under the [GNU General Public License ver - Background based on https://bgjar.com/rect-light under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). ## -SIPC-/consoles.svg - - Created by @SIPC in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1431207669. - - Font is Noto Sans. + - Created by [@SharkPool](https://scratch.mit.edu/users/DemonX5/) + - Based on an image by [@SIPC](https://github.com/SIPC) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1431207669 ## -SIPC-/time.svg - - Created by @SIPC in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1431207669. - - Font is Noto Sans. + - Created by [@SharkPool](https://scratch.mit.edu/users/DemonX5/) + - Based on an image by [@SIPC](https://github.com/SIPC) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1431207669. ## Skyhigh173/json.svg - Created by @Skyhigh173 in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1457973080. @@ -123,8 +122,7 @@ All images in this folder are licensed under the [GNU General Public License ver - Created by [@LilyMakesThings](https://scratch.mit.edu/users/LilyMakesThings/) in https://github.com/TurboWarp/extensions/pull/271#issuecomment-1475119545. ## 0832/rxFS2.svg - - Created by @0832k12 in https://github.com/TurboWarp/extensions/pull/291. - - Background from https://app.haikei.app/. + - Created by [@BlueDome77](https://github.com/BlueDome77) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1604175329. ## NOname-awa/math-and-string.svg - Created by @NOname in https://github.com/TurboWarp/extensions/pull/316. @@ -145,7 +143,9 @@ All images in this folder are licensed under the [GNU General Public License ver - Created by @Pizzalover4783 in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1526886264. ## cs2627883/numericalencoding.svg - - Created by @Pizzalover4783 in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1534022176. + - Created by [@NexusKitten](https://scratch.mit.edu/users/namelesscat/). + - Silkscreen font used under [Open Font License](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL) + - Dango based on dango from [Twemoji](https://twemoji.twitter.com/) under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). ## NOname-awa/graphics2d.svg - Created by @Pizzalover4783 in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1550426448. @@ -169,11 +169,11 @@ All images in this folder are licensed under the [GNU General Public License ver - Created by [@True-Fantom](https://scratch.mit.edu/users/TrueFantom/) and [@LilyMakesThings](https://scratch.mit.edu/users/LilyMakesThings/) in https://github.com/TurboWarp/extensions/pull/498. ## Lily/ClonesPlus.svg - - Created by [@LilyMakesThings](https://scratch.mit.edu/users/LilyMakesThings/) in https://github.com/TurboWarp/extensions/pull/382. + - Created by [@LilyMakesThings](https://scratch.mit.edu/users/LilyMakesThings/) in https://github.com/TurboWarp/extensions/pull/656. - Dango based on dango from [Twemoji](https://twemoji.twitter.com/) under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). -## Lily/TempVariables.svg - - Created by [@LilyMakesThings](https://scratch.mit.edu/users/LilyMakesThings/) in https://github.com/TurboWarp/extensions/pull/410. +## Lily/TempVariables2.svg + - Created by [@LilyMakesThings](https://scratch.mit.edu/users/LilyMakesThings/) in https://github.com/TurboWarp/extensions/pull/656. ## obviousAlexC/SensingPlus.svg - Created by [@David-Orangemoon](https://scratch.mit.edu/users/pinksheep2917/) in https://github.com/TurboWarp/extensions/pull/379. @@ -204,10 +204,10 @@ All images in this folder are licensed under the [GNU General Public License ver - Based on image created by [@Flappy25](https://github.com/Flappy25) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1575100933 ## mdwalters/notifications.svg - - Created by [@Juenjos](https://github.com/Juenjos) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1573040329 + - Created by [@BlueDome77](https://github.com/BlueDome77) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1637077987 ## Lily/MoreTimers.svg -- Created by [@LilyMakesThings](https://scratch.mit.edu/users/LilyMakesThings/). +- Created by [@LilyMakesThings](https://scratch.mit.edu/users/LilyMakesThings/) in https://github.com/TurboWarp/extensions/pull/656. - Timer SVG based from https://www.svgrepo.com/svg/2045/stopwatch under CC0. ## rixxyx.svg @@ -223,15 +223,27 @@ All images in this folder are licensed under the [GNU General Public License ver - Created by [@HamsterCreativity](https://github.com/HamsterCreativity) ## navigator.svg - - Created by [@HamsterCreativity](https://github.com/HamsterCreativity) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1593886519 + - Created by [@BlueDome77](https://github.com/BlueDome77) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1602552989 ## qxsck/var-and-list.svg - Created by [@CST1229](https://github.com/CST1229) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1595642879 - Based on icons: [list_icon.svg](https://github.com/ScratchAddons/ScratchAddons/blob/master/addons/block-palette-icons/icons/list_icon.svg) and [variables_icon.svg](https://github.com/ScratchAddons/ScratchAddons/blob/master/addons/block-palette-icons/icons/variables_icon.svg) ## ZXMushroom63/searchApi.svg - - Created by [@CST1229](https://github.com/CST1229) and [@BlueDome77](https://github.com/BlueDome77) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1596177193 + - Created by [@CST1229](https://github.com/CST1229) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1596158611 + +## Lily/LooksPlus.svg + - Created by [@LilyMakesThings](https://github.com/LilyMakesThings) in https://github.com/TurboWarp/extensions/pull/656 + +## clipboard.svg + - Created by [@AdamMady](https://github.com/AdamMady/) + +## godslayerakp/http.svg + - Created by [@HamsterCreativity](https://github.com/HamsterCreativity) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1636912111 + +## Alestore/nfcwarp.svg + - Created by [@HamsterCreativity](https://github.com/HamsterCreativity) in https://github.com/TurboWarp/extensions/issues/90#issuecomment-1636726352 ## Lily/MoreEvents.svg -- Created by [@LilyMakesThings](https://scratch.mit.edu/users/LilyMakesThings/). -- Background "blobs" by Scratch + - Created by [@LilyMakesThings](https://github.com/LilyMakesThings). + - Background "blobs" by Scratch. From cd5ad1b00081dbe73061b4378f993a90282306fd Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sat, 29 Jul 2023 04:06:34 +0100 Subject: [PATCH 22/47] Delete MoreEvents.svg --- images/Lily/MoreEvents.svg | 1 - 1 file changed, 1 deletion(-) delete mode 100644 images/Lily/MoreEvents.svg diff --git a/images/Lily/MoreEvents.svg b/images/Lily/MoreEvents.svg deleted file mode 100644 index 7dd349bc18..0000000000 --- a/images/Lily/MoreEvents.svg +++ /dev/null @@ -1 +0,0 @@ -whenclicked \ No newline at end of file From 11a598c9d94b3e43406334347e870d59eb39b6ed Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sat, 29 Jul 2023 04:06:42 +0100 Subject: [PATCH 23/47] Add files via upload --- images/Lily/MoreEvents.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 images/Lily/MoreEvents.svg diff --git a/images/Lily/MoreEvents.svg b/images/Lily/MoreEvents.svg new file mode 100644 index 0000000000..a85290fea2 --- /dev/null +++ b/images/Lily/MoreEvents.svg @@ -0,0 +1 @@ + \ No newline at end of file From e535eb4cac763bb2372901dff89689719f6f23bf Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sat, 29 Jul 2023 04:08:49 +0100 Subject: [PATCH 24/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 597f7a62d9..e8898399f0 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -78,7 +78,7 @@ runtime.startHats('lmsMoreEvents_whileTurboMode', { STATE: (runtime.turboMode) ? 'enabled' : 'disabled' }); - }) + }); var lastValues = {}; @@ -309,7 +309,7 @@ if (!args.BROADCAST_OPTION) return; const broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg(args.BROADCAST_OPTION); if (!broadcastVar) return; - if (args.TARGET = '_stage_') { + if (args.TARGET === '_stage_') { util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, runtime.getTargetForStage()); return; } From ac590582de04ebf1eff98269eae61f65608bcf5b Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sat, 29 Jul 2023 04:10:37 +0100 Subject: [PATCH 25/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index e8898399f0..5dcdd51180 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -74,7 +74,7 @@ runtime.startHats('lmsMoreEvents_always', { CONDITION: 'true' }); - + runtime.startHats('lmsMoreEvents_whileTurboMode', { STATE: (runtime.turboMode) ? 'enabled' : 'disabled' }); From b2169e9cea6d0dc47f03c96a412057a2c3fcf188 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sun, 30 Jul 2023 16:37:10 +0100 Subject: [PATCH 26/47] Delete MoreEvents.svg --- images/Lily/MoreEvents.svg | 1 - 1 file changed, 1 deletion(-) delete mode 100644 images/Lily/MoreEvents.svg diff --git a/images/Lily/MoreEvents.svg b/images/Lily/MoreEvents.svg deleted file mode 100644 index a85290fea2..0000000000 --- a/images/Lily/MoreEvents.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file From c8274792b0802a5ec63cb20b9cadf275186a3a85 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sat, 5 Aug 2023 16:59:06 +0100 Subject: [PATCH 27/47] Add files via upload --- images/Lily/MoreEvents.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 images/Lily/MoreEvents.svg diff --git a/images/Lily/MoreEvents.svg b/images/Lily/MoreEvents.svg new file mode 100644 index 0000000000..7dd349bc18 --- /dev/null +++ b/images/Lily/MoreEvents.svg @@ -0,0 +1 @@ +whenclicked \ No newline at end of file From d0ad81cab686c229c682caa22eb5cdf19f444781 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sun, 6 Aug 2023 02:29:21 +0100 Subject: [PATCH 28/47] Delete MoreEvents.svg --- images/Lily/MoreEvents.svg | 1 - 1 file changed, 1 deletion(-) delete mode 100644 images/Lily/MoreEvents.svg diff --git a/images/Lily/MoreEvents.svg b/images/Lily/MoreEvents.svg deleted file mode 100644 index 7dd349bc18..0000000000 --- a/images/Lily/MoreEvents.svg +++ /dev/null @@ -1 +0,0 @@ -whenclicked \ No newline at end of file From 29224e42c8c0c6c84144c1e5f46e1da1826819ff Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Sun, 6 Aug 2023 02:29:38 +0100 Subject: [PATCH 29/47] Add files via upload --- images/Lily/MoreEvents.svg | 1 + 1 file changed, 1 insertion(+) create mode 100644 images/Lily/MoreEvents.svg diff --git a/images/Lily/MoreEvents.svg b/images/Lily/MoreEvents.svg new file mode 100644 index 0000000000..82ec5703a2 --- /dev/null +++ b/images/Lily/MoreEvents.svg @@ -0,0 +1 @@ + \ No newline at end of file From 2881842be3eada5feb06ac7b610ab5e8f89d9001 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Mon, 7 Aug 2023 02:07:52 +0100 Subject: [PATCH 30/47] Update index.ejs --- website/index.ejs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/website/index.ejs b/website/index.ejs index da2953cdf6..416689d49b 100644 --- a/website/index.ejs +++ b/website/index.ejs @@ -506,6 +506,12 @@

Expands upon the looks category, allowing you to show/hide, get costume data and edit SVG skins on sprites. Created by LilyMakesThings.

+
+ <%- banner('Lily/MoreEvents') %> +

More Events

+

Start your scripts in new ways. Created by LilyMakesThings.

+
+
<%- banner('NexusKitten/moremotion') %>

More Motion

From 3010d77ffab9631388bd1ff01ea44b1809ee5a1e Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Tue, 8 Aug 2023 01:09:31 +0100 Subject: [PATCH 31/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 62 +++-------------------------------- 1 file changed, 4 insertions(+), 58 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 5dcdd51180..0cdf8c98b6 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -71,9 +71,7 @@ ]; vm.runtime.on('BEFORE_EXECUTE', () => { - runtime.startHats('lmsMoreEvents_always', { - CONDITION: 'true' - }); + runtime.startHats('lmsMoreEvents_forever'); runtime.startHats('lmsMoreEvents_whileTurboMode', { STATE: (runtime.turboMode) ? 'enabled' : 'disabled' @@ -150,16 +148,10 @@ } }, { - opcode: 'always', + opcode: 'forever', blockType: Scratch.BlockType.HAT, - text: 'always return [CONDITION]', - isEdgeActivated: false, - arguments: { - CONDITION: { - type: Scratch.ArgumentType.STRING, - menu: 'boolean' - } - } + text: 'forever', + isEdgeActivated: false }, '---', @@ -215,35 +207,6 @@ opcode: 'broadcastAll', blockType: Scratch.BlockType.COMMAND, text: 'broadcast everything' - }, - - '---', - - { - opcode: 'startHats', - blockType: Scratch.BlockType.COMMAND, - text: 'start hats [HAT]', - arguments: { - HAT: { - type: Scratch.ArgumentType.STRING, - defaultValue: 'event_whenflagclicked' - } - } - }, - { - opcode: 'startHatsInTarget', - blockType: Scratch.BlockType.COMMAND, - text: 'start hats [HAT] in [TARGET]', - arguments: { - HAT: { - type: Scratch.ArgumentType.STRING, - defaultValue: 'event_whenflagclicked' - }, - TARGET: { - type: Scratch.ArgumentType.STRING, - menu: 'targetMenu' - } - } } ], menus: { @@ -272,14 +235,6 @@ state: { acceptReporters: false, items: ['enabled', 'disabled'] - }, - runtimeOptions: { - acceptReporters: false, - items: ['framerate', 'stage size', 'interpolation'] - }, - startStop: { - acceptReporters: false, - items: ['started', 'stopped'] } } }; @@ -323,15 +278,6 @@ util.startHats('event_whenbroadcastreceived'); } - startHats(args, util) { - util.startHats(args.HAT); - } - - startHatsInTarget(args, util) { - const target = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); - util.startHats(args.HAT, null, target); - } - _getTargets() { const spriteNames = [{text: 'Stage', value: '_stage_'}]; const targets = Scratch.vm.runtime.targets; From b89403d4139bc296ac2e9cbcf71269459fbda4d7 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 9 Aug 2023 05:37:37 +0100 Subject: [PATCH 32/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 97 +++++++++++++++++++++++++++++------ 1 file changed, 82 insertions(+), 15 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 0cdf8c98b6..129835c0e9 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -70,14 +70,6 @@ { text: '9', value: '9' }, ]; - vm.runtime.on('BEFORE_EXECUTE', () => { - runtime.startHats('lmsMoreEvents_forever'); - - runtime.startHats('lmsMoreEvents_whileTurboMode', { - STATE: (runtime.turboMode) ? 'enabled' : 'disabled' - }); - }); - var lastValues = {}; class MoreEvents { @@ -86,6 +78,11 @@ runtime.shouldExecuteStopClicked = true; runtime.on('BEFORE_EXECUTE', () => { runtime.shouldExecuteStopClicked = false; + runtime.startHats('lmsMoreEvents_forever'); + + runtime.startHats('lmsMoreEvents_whileTurboMode', { + STATE: (runtime.turboMode) ? 'enabled' : 'disabled' + }); }); runtime.on('PROJECT_STOP_ALL', () => { if (runtime.shouldExecuteStopClicked) @@ -139,7 +136,7 @@ { opcode: 'whenValueChanged', blockType: Scratch.BlockType.HAT, - text: 'when [INPUT] changed', + text: 'when [INPUT] is changed', isEdgeActivated: true, arguments: { INPUT: { @@ -204,9 +201,43 @@ } }, { - opcode: 'broadcastAll', + opcode: 'broadcastData', + blockType: Scratch.BlockType.COMMAND, + text: 'broadcast [BROADCAST_OPTION] with data [DATA]', + arguments: { + BROADCAST_OPTION: { + type: Scratch.ArgumentType.STRING, + menu: 'broadcastMenu' + }, + DATA: { + type: Scratch.ArgumentType.STRING + } + } + }, + { + opcode: 'broadcastDataToTarget', blockType: Scratch.BlockType.COMMAND, - text: 'broadcast everything' + text: 'broadcast [BROADCAST_OPTION] to [TARGET] with data [DATA]', + arguments: { + BROADCAST_OPTION: { + type: Scratch.ArgumentType.STRING, + menu: 'broadcastMenu' + }, + TARGET: { + type: Scratch.ArgumentType.STRING, + menu: 'targetMenu' + }, + DATA: { + type: Scratch.ArgumentType.STRING + } + } + }, + { + opcode: 'receivedData', + blockType: Scratch.BlockType.REPORTER, + text: 'received data', + disableMonitor: true, + allowDropAnywhere: true } ], menus: { @@ -256,7 +287,7 @@ whenKeyAction(args, util) { const key = Scratch.Cast.toString(args.KEY_OPTION).toLowerCase(); - const pressed = util.ioQuery('keyboard', 'getKeyIsDown', [args.KEY_OPTION]); + const pressed = util.ioQuery('keyboard', 'getKeyIsDown', [key]); return (args.ACTION === 'released') ? !pressed : pressed; } @@ -264,24 +295,60 @@ if (!args.BROADCAST_OPTION) return; const broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg(args.BROADCAST_OPTION); if (!broadcastVar) return; + if (args.TARGET === '_stage_') { util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, runtime.getTargetForStage()); return; } + const spriteTarget = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); const cloneTargets = spriteTarget.sprite.clones; cloneTargets.forEach(model => util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, model)); util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, spriteTarget); } - broadcastAll(args, util) { - util.startHats('event_whenbroadcastreceived'); + broadcastData(args, util) { + if (!args.BROADCAST_OPTION) return; + const broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg(args.BROADCAST_OPTION); + if (!broadcastVar) return; + + const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}); + console.log(threads); + threads.forEach(thread => thread['emitedData'] = args.DATA); + } + + broadcastDataToTarget(args, util) { + if (!args.BROADCAST_OPTION) return; + const broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg(args.BROADCAST_OPTION); + if (!broadcastVar) return; + + const spriteTarget = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); + if(!spriteTarget) return; + const cloneTargets = spriteTarget.sprite.clones; + + if (args.TARGET === '_stage_') { + const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, runtime.getTargetForStage()); + threads.forEach(thread => thread['emitedData'] = args.DATA); + return; + } else { + cloneTargets.forEach(model => { + const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, model); + threads.forEach(thread => thread['emitedData'] = args.DATA); + }); + } + + const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, spriteTarget); + threads.forEach(thread => thread['emitedData'] = args.DATA); + } + + receivedData(args, util) { + const received = util.thread['emitedData']; + return (received) ? received : ''; } _getTargets() { const spriteNames = [{text: 'Stage', value: '_stage_'}]; const targets = Scratch.vm.runtime.targets; - const myself = Scratch.vm.runtime.getEditingTarget().getName(); for (let index = 1; index < targets.length; index++) { const target = targets[index]; if (target.isOriginal) { From dcd35912bfd803d2b9e994b599a63e2f4613b101 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 9 Aug 2023 05:38:54 +0100 Subject: [PATCH 33/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 129835c0e9..26bf4c033a 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -79,7 +79,7 @@ runtime.on('BEFORE_EXECUTE', () => { runtime.shouldExecuteStopClicked = false; runtime.startHats('lmsMoreEvents_forever'); - + runtime.startHats('lmsMoreEvents_whileTurboMode', { STATE: (runtime.turboMode) ? 'enabled' : 'disabled' }); @@ -323,7 +323,7 @@ if (!broadcastVar) return; const spriteTarget = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); - if(!spriteTarget) return; + if (!spriteTarget) return; const cloneTargets = spriteTarget.sprite.clones; if (args.TARGET === '_stage_') { From f06ebc9cbb2c44c4550c34986c4baa4a297cac00 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 9 Aug 2023 15:47:01 +0100 Subject: [PATCH 34/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 1 - 1 file changed, 1 deletion(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 26bf4c033a..1040df82cb 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -313,7 +313,6 @@ if (!broadcastVar) return; const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}); - console.log(threads); threads.forEach(thread => thread['emitedData'] = args.DATA); } From 928fe3d9c7724017b1cdb18258ed24dcac5200ad Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 9 Aug 2023 20:47:00 +0100 Subject: [PATCH 35/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 66 +++++++++++++++++------------------ 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 1040df82cb..8f00da785d 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -191,14 +191,14 @@ text: 'broadcast [BROADCAST_OPTION] to [TARGET]', arguments: { BROADCAST_OPTION: { - type: Scratch.ArgumentType.STRING, - menu: 'broadcastMenu' + type: Scratch.ArgumentType.STRING }, TARGET: { type: Scratch.ArgumentType.STRING, menu: 'targetMenu' } - } + }, + hideFromPalette: true }, { opcode: 'broadcastData', @@ -206,13 +206,13 @@ text: 'broadcast [BROADCAST_OPTION] with data [DATA]', arguments: { BROADCAST_OPTION: { - type: Scratch.ArgumentType.STRING, - menu: 'broadcastMenu' + type: Scratch.ArgumentType.STRING }, DATA: { type: Scratch.ArgumentType.STRING } - } + }, + hideFromPalette: true }, { opcode: 'broadcastDataToTarget', @@ -220,8 +220,7 @@ text: 'broadcast [BROADCAST_OPTION] to [TARGET] with data [DATA]', arguments: { BROADCAST_OPTION: { - type: Scratch.ArgumentType.STRING, - menu: 'broadcastMenu' + type: Scratch.ArgumentType.STRING }, TARGET: { type: Scratch.ArgumentType.STRING, @@ -230,7 +229,12 @@ DATA: { type: Scratch.ArgumentType.STRING } - } + }, + hideFromPalette: true + }, + { // Adding the broadcast argument to the blocks + blockType: Scratch.BlockType.XML, + xml: '' }, { opcode: 'receivedData', @@ -246,10 +250,6 @@ acceptReporters: true, items: '_getTargets' }, - broadcastMenu: { - acceptReporters: true, - items: '_getBroadcastMsgs' - }, keyboardButtons: { acceptReporters: true, items: validKeyboardInputs @@ -292,56 +292,54 @@ } broadcastToTarget(args, util) { - if (!args.BROADCAST_OPTION) return; - const broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg(args.BROADCAST_OPTION); - if (!broadcastVar) return; + const broadcast = Scratch.Cast.toString(args.BROADCAST_OPTION); + if (!broadcast) return; if (args.TARGET === '_stage_') { - util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, runtime.getTargetForStage()); + util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, runtime.getTargetForStage()); return; } const spriteTarget = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); const cloneTargets = spriteTarget.sprite.clones; - cloneTargets.forEach(model => util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, model)); - util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, spriteTarget); + cloneTargets.forEach(model => util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, model)); + util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, spriteTarget); } broadcastData(args, util) { - if (!args.BROADCAST_OPTION) return; - const broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg(args.BROADCAST_OPTION); - if (!broadcastVar) return; + const broadcast = Scratch.Cast.toString(args.BROADCAST_OPTION); + if (!broadcast) return; - const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}); - threads.forEach(thread => thread['emitedData'] = args.DATA); + const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}); + console.log(threads); + threads.forEach(thread => thread.receivedData = args.DATA); } broadcastDataToTarget(args, util) { - if (!args.BROADCAST_OPTION) return; - const broadcastVar = util.runtime.getTargetForStage().lookupBroadcastMsg(args.BROADCAST_OPTION); - if (!broadcastVar) return; + const broadcast = Scratch.Cast.toString(args.BROADCAST_OPTION); + if (!broadcast) return; const spriteTarget = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); if (!spriteTarget) return; const cloneTargets = spriteTarget.sprite.clones; if (args.TARGET === '_stage_') { - const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, runtime.getTargetForStage()); - threads.forEach(thread => thread['emitedData'] = args.DATA); + const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, runtime.getTargetForStage()); + threads.forEach(thread => thread.receivedData = args.DATA); return; } else { cloneTargets.forEach(model => { - const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, model); - threads.forEach(thread => thread['emitedData'] = args.DATA); + const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, model); + threads.forEach(thread => thread.receivedData = args.DATA); }); } - const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcastVar.name}, spriteTarget); - threads.forEach(thread => thread['emitedData'] = args.DATA); + const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, spriteTarget); + threads.forEach(thread => thread.receivedData = args.DATA); } receivedData(args, util) { - const received = util.thread['emitedData']; + const received = util.thread.receivedData; return (received) ? received : ''; } From a2f911e78cc1d5f7533a6ed60f196993dee95543 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Thu, 10 Aug 2023 05:57:37 +0100 Subject: [PATCH 36/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 8f00da785d..d2f90c819f 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -191,7 +191,7 @@ text: 'broadcast [BROADCAST_OPTION] to [TARGET]', arguments: { BROADCAST_OPTION: { - type: Scratch.ArgumentType.STRING + type: null, }, TARGET: { type: Scratch.ArgumentType.STRING, @@ -206,7 +206,7 @@ text: 'broadcast [BROADCAST_OPTION] with data [DATA]', arguments: { BROADCAST_OPTION: { - type: Scratch.ArgumentType.STRING + type: null, }, DATA: { type: Scratch.ArgumentType.STRING @@ -220,7 +220,7 @@ text: 'broadcast [BROADCAST_OPTION] to [TARGET] with data [DATA]', arguments: { BROADCAST_OPTION: { - type: Scratch.ArgumentType.STRING + type: null, }, TARGET: { type: Scratch.ArgumentType.STRING, From 9084770eb91f6ca5560dfb364c49752215a57e07 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 16 Aug 2023 18:05:00 +0100 Subject: [PATCH 37/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 40 ++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index d2f90c819f..4c10147ce8 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -79,6 +79,8 @@ runtime.on('BEFORE_EXECUTE', () => { runtime.shouldExecuteStopClicked = false; runtime.startHats('lmsMoreEvents_forever'); + runtime.startHats('lmsMoreEvents_whileTrueFalse'); + runtime.startHats('lmsMoreEvents_whenValueChanged'); runtime.startHats('lmsMoreEvents_whileTurboMode', { STATE: (runtime.turboMode) ? 'enabled' : 'disabled' @@ -118,10 +120,19 @@ } } }, + { + opcode: 'forever', + blockType: Scratch.BlockType.EVENT, + text: 'forever', + isEdgeActivated: false + }, + + '---', + { opcode: 'whenTrueFalse', blockType: Scratch.BlockType.HAT, - text: 'when [CONDITION] is [STATE]', + text: 'when [CONDITION] becomes [STATE]', isEdgeActivated: true, arguments: { CONDITION: { @@ -133,23 +144,32 @@ } } }, + { + opcode: 'whileTrueFalse', + blockType: Scratch.BlockType.HAT, + text: 'while [CONDITION] is [STATE]', + isEdgeActivated: false, + arguments: { + CONDITION: { + type: Scratch.ArgumentType.BOOLEAN + }, + STATE: { + type: Scratch.ArgumentType.STRING, + menu: 'boolean' + } + } + }, { opcode: 'whenValueChanged', blockType: Scratch.BlockType.HAT, text: 'when [INPUT] is changed', - isEdgeActivated: true, + isEdgeActivated: false, arguments: { INPUT: { type: Scratch.ArgumentType.STRING } } }, - { - opcode: 'forever', - blockType: Scratch.BlockType.HAT, - text: 'forever', - isEdgeActivated: false - }, '---', @@ -275,6 +295,10 @@ return (args.STATE === 'true') ? args.CONDITION : !args.CONDITION; } + whileTrueFalse(args) { + return (args.STATE === 'true') ? args.CONDITION : !args.CONDITION; + } + whenValueChanged(args, util) { const blockId = util.thread.peekStack(); if (!lastValues[blockId]) lastValues[blockId] = Scratch.Cast.toString(args.INPUT); From 2d0ee149acc66a97af3437456469f6edc05921a0 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 16 Aug 2023 18:53:23 +0100 Subject: [PATCH 38/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 4c10147ce8..9e8409cd99 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -81,10 +81,7 @@ runtime.startHats('lmsMoreEvents_forever'); runtime.startHats('lmsMoreEvents_whileTrueFalse'); runtime.startHats('lmsMoreEvents_whenValueChanged'); - - runtime.startHats('lmsMoreEvents_whileTurboMode', { - STATE: (runtime.turboMode) ? 'enabled' : 'disabled' - }); + runtime.startHats('lmsMoreEvents_whileKeyPressed'); }); runtime.on('PROJECT_STOP_ALL', () => { if (runtime.shouldExecuteStopClicked) @@ -191,14 +188,15 @@ } }, { - opcode: 'whileTurboMode', + opcode: 'whileKeyPressed', blockType: Scratch.BlockType.HAT, - text: 'while turbo mode is [STATE]', + text: 'while [KEY_OPTION] key pressed', isEdgeActivated: false, arguments: { - STATE: { + KEY_OPTION: { type: Scratch.ArgumentType.STRING, - menu: 'state' + defaultValue: 'space', + menu: 'keyboardButtons' } } }, @@ -315,6 +313,11 @@ return (args.ACTION === 'released') ? !pressed : pressed; } + whileKeyPressed(args, util) { + const key = Scratch.Cast.toString(args.KEY_OPTION).toLowerCase(); + return util.ioQuery('keyboard', 'getKeyIsDown', [key]); + } + broadcastToTarget(args, util) { const broadcast = Scratch.Cast.toString(args.BROADCAST_OPTION); if (!broadcast) return; From 9e22f658c3c8a2a71423b72c3de33602020339ba Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 16 Aug 2023 20:45:40 +0100 Subject: [PATCH 39/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 224 +++++++++++++++++++++++++++------- 1 file changed, 183 insertions(+), 41 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 9e8409cd99..6b677cf0e2 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -209,7 +209,7 @@ text: 'broadcast [BROADCAST_OPTION] to [TARGET]', arguments: { BROADCAST_OPTION: { - type: null, + type: null }, TARGET: { type: Scratch.ArgumentType.STRING, @@ -218,13 +218,31 @@ }, hideFromPalette: true }, + { + opcode: 'broadcastToTargetAndWait', + blockType: Scratch.BlockType.COMMAND, + text: 'broadcast [BROADCAST_OPTION] to [TARGET] and wait', + arguments: { + BROADCAST_OPTION: { + type: null + }, + TARGET: { + type: Scratch.ArgumentType.STRING, + menu: 'targetMenu' + } + }, + hideFromPalette: true + }, + + '---', + { opcode: 'broadcastData', blockType: Scratch.BlockType.COMMAND, text: 'broadcast [BROADCAST_OPTION] with data [DATA]', arguments: { BROADCAST_OPTION: { - type: null, + type: null }, DATA: { type: Scratch.ArgumentType.STRING @@ -233,16 +251,12 @@ hideFromPalette: true }, { - opcode: 'broadcastDataToTarget', + opcode: 'broadcastDataAndWait', blockType: Scratch.BlockType.COMMAND, - text: 'broadcast [BROADCAST_OPTION] to [TARGET] with data [DATA]', + text: 'broadcast [BROADCAST_OPTION] with data [DATA] and wait', arguments: { BROADCAST_OPTION: { - type: null, - }, - TARGET: { - type: Scratch.ArgumentType.STRING, - menu: 'targetMenu' + type: null }, DATA: { type: Scratch.ArgumentType.STRING @@ -250,9 +264,9 @@ }, hideFromPalette: true }, - { // Adding the broadcast argument to the blocks + { blockType: Scratch.BlockType.XML, - xml: '' + xml: '' }, { opcode: 'receivedData', @@ -260,6 +274,51 @@ text: 'received data', disableMonitor: true, allowDropAnywhere: true + }, + + '---', + + { + opcode: 'broadcastDataToTarget', + blockType: Scratch.BlockType.COMMAND, + text: 'broadcast [BROADCAST_OPTION] to [TARGET] with data [DATA]', + func: 'broadcastToTarget', + arguments: { + BROADCAST_OPTION: { + type: null + }, + TARGET: { + type: Scratch.ArgumentType.STRING, + menu: 'targetMenu' + }, + DATA: { + type: Scratch.ArgumentType.STRING + } + }, + hideFromPalette: true + }, + { + opcode: 'broadcastDataToTargetAndWait', + blockType: Scratch.BlockType.COMMAND, + text: 'broadcast [BROADCAST_OPTION] to [TARGET] with data [DATA] and wait', + func: 'broadcastToTargetAndWait', + arguments: { + BROADCAST_OPTION: { + type: null + }, + TARGET: { + type: Scratch.ArgumentType.STRING, + menu: 'targetMenu' + }, + DATA: { + type: Scratch.ArgumentType.STRING + } + }, + hideFromPalette: true + }, + { + blockType: Scratch.BlockType.XML, + xml: '' } ], menus: { @@ -284,6 +343,10 @@ state: { acceptReporters: false, items: ['enabled', 'disabled'] + }, + broadcasts: { + acceptReporters: true, + items: '_getBroadcastMsgs' } } }; @@ -319,50 +382,123 @@ } broadcastToTarget(args, util) { - const broadcast = Scratch.Cast.toString(args.BROADCAST_OPTION); - if (!broadcast) return; + const broadcastOption = Scratch.Cast.toString(args.BROADCAST_OPTION); + if (!broadcastOption) return; + + const data = Scratch.Cast.toString(args.DATA); + console.log(data); + + const cloneTargets = this._getTargetFromMenu(args.TARGET).sprite.clones; + let startedThreads = []; + + for (const clone of cloneTargets) { + startedThreads = [ + ...startedThreads, + ...util.startHats( + 'event_whenbroadcastreceived', { + BROADCAST_OPTION: broadcastOption + }, + clone + )]; + if (data) { + startedThreads.forEach(thread => thread.receivedData = args.DATA); + } + } + } - if (args.TARGET === '_stage_') { - util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, runtime.getTargetForStage()); - return; + broadcastToTargetAndWait(args, util) { + if (!util.stackFrame.broadcastVar) { + util.stackFrame.broadcastVar = Scratch.Cast.toString(args.BROADCAST_OPTION); } - const spriteTarget = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); + const spriteTarget = this._getTargetFromMenu(args.TARGET); + if (!spriteTarget) return; const cloneTargets = spriteTarget.sprite.clones; - cloneTargets.forEach(model => util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, model)); - util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, spriteTarget); + + const data = Scratch.Cast.toString(args.DATA); + + if (util.stackFrame.broadcastVar) { + const broadcastOption = util.stackFrame.broadcastVar; + if (!util.stackFrame.startedThreads) { + util.stackFrame.startedThreads = []; + for (const clone of cloneTargets) { + util.stackFrame.startedThreads = [ + ...util.stackFrame.startedThreads, + ...util.startHats( + 'event_whenbroadcastreceived', { + BROADCAST_OPTION: broadcastOption + }, + clone + )]; + if (data) { + util.stackFrame.startedThreads.forEach(thread => thread.receivedData = args.DATA); + } + } + if (util.stackFrame.startedThreads.length === 0) { + return; + } + } + + const waiting = util.stackFrame.startedThreads + .some(thread => runtime.threads.indexOf(thread) !== -1); + if (waiting) { + if ( + util.stackFrame.startedThreads + .every(thread => runtime.isWaitingThread(thread)) + ) { + util.yieldTick(); + } else { + util.yield(); + } + } + } } broadcastData(args, util) { const broadcast = Scratch.Cast.toString(args.BROADCAST_OPTION); if (!broadcast) return; - const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}); - console.log(threads); - threads.forEach(thread => thread.receivedData = args.DATA); - } + const data = Scratch.Cast.toString(args.DATA); - broadcastDataToTarget(args, util) { - const broadcast = Scratch.Cast.toString(args.BROADCAST_OPTION); - if (!broadcast) return; + let threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}); + threads.forEach(thread => thread.receivedData = data); + } - const spriteTarget = Scratch.vm.runtime.getSpriteTargetByName(args.TARGET); - if (!spriteTarget) return; - const cloneTargets = spriteTarget.sprite.clones; + broadcastDataAndWait(args, util) { + const data = Scratch.Cast.toString(args.DATA); - if (args.TARGET === '_stage_') { - const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, runtime.getTargetForStage()); - threads.forEach(thread => thread.receivedData = args.DATA); - return; - } else { - cloneTargets.forEach(model => { - const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, model); - threads.forEach(thread => thread.receivedData = args.DATA); - }); + if (!util.stackFrame.broadcastVar) { + util.stackFrame.broadcastVar = Scratch.Cast.toString(args.BROADCAST_OPTION); } - const threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}, spriteTarget); - threads.forEach(thread => thread.receivedData = args.DATA); + if (util.stackFrame.broadcastVar) { + const broadcastOption = util.stackFrame.broadcastVar; + if (!util.stackFrame.startedThreads) { + util.stackFrame.startedThreads = util.startHats( + 'event_whenbroadcastreceived', { + BROADCAST_OPTION: broadcastOption + }, + ); + if (util.stackFrame.startedThreads.length === 0) { + return; + } else { + util.stackFrame.startedThreads.forEach(thread => thread.receivedData = data); + } + } + + const waiting = util.stackFrame.startedThreads + .some(thread => runtime.threads.indexOf(thread) !== -1); + if (waiting) { + if ( + util.stackFrame.startedThreads + .every(thread => runtime.isWaitingThread(thread)) + ) { + util.yieldTick(); + } else { + util.yield(); + } + } + } } receivedData(args, util) { @@ -370,6 +506,12 @@ return (received) ? received : ''; } + _getTargetFromMenu (targetName) { + let target = Scratch.vm.runtime.getSpriteTargetByName(targetName); + if (targetName === '_stage_') target = runtime.getTargetForStage(); + return target; + } + _getTargets() { const spriteNames = [{text: 'Stage', value: '_stage_'}]; const targets = Scratch.vm.runtime.targets; @@ -398,7 +540,7 @@ .getVariablesOfType('broadcast_msg') .map(model => ({ text: model.name, - value: model.getId() + value: model.name })); if (broadcasts.length > 0) { return broadcasts; From 41f9633d3a250720c730134e3d0cd0ad452979d3 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 16 Aug 2023 21:22:58 +0100 Subject: [PATCH 40/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 6b677cf0e2..26148b68ae 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -107,7 +107,7 @@ blocks: [ { opcode: 'whenStopClicked', - blockType: Scratch.BlockType.HAT, + blockType: Scratch.BlockType.EVENT, text: 'when [STOP] clicked', isEdgeActivated: false, arguments: { From 87da5bca78712195c876285145ba6f7c53d0016c Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Thu, 17 Aug 2023 01:17:54 +0100 Subject: [PATCH 41/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 53 ++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 26148b68ae..b0b1c5bbc7 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -71,19 +71,27 @@ ]; var lastValues = {}; + var runTimer = 0; class MoreEvents { constructor() { // Stop Sign Clicked contributed by @CST1229 runtime.shouldExecuteStopClicked = true; runtime.on('BEFORE_EXECUTE', () => { + runTimer++; runtime.shouldExecuteStopClicked = false; + runtime.startHats('lmsMoreEvents_forever'); runtime.startHats('lmsMoreEvents_whileTrueFalse'); runtime.startHats('lmsMoreEvents_whenValueChanged'); + runtime.startHats('lmsMoreEvents_everyDuration'); runtime.startHats('lmsMoreEvents_whileKeyPressed'); }); + runtime.on('PROJECT_START', () => { + runTimer = 0; + }); runtime.on('PROJECT_STOP_ALL', () => { + runTimer = 0; if (runtime.shouldExecuteStopClicked) queueMicrotask(() => runtime.startHats('lmsMoreEvents_whenStopClicked')); }); @@ -156,6 +164,9 @@ } } }, + + '---', + { opcode: 'whenValueChanged', blockType: Scratch.BlockType.HAT, @@ -167,6 +178,18 @@ } } }, + { + opcode: 'everyDuration', + blockType: Scratch.BlockType.HAT, + text: 'every [DURATION] frames', + isEdgeActivated: false, + arguments: { + DURATION: { + type: Scratch.ArgumentType.NUMBER, + defaultValue: 3 + } + } + }, '---', @@ -343,10 +366,6 @@ state: { acceptReporters: false, items: ['enabled', 'disabled'] - }, - broadcasts: { - acceptReporters: true, - items: '_getBroadcastMsgs' } } }; @@ -370,6 +389,11 @@ return false; } + everyDuration(args, util) { + const duration = Math.max(Math.round(Scratch.Cast.toNumber(args.DURATION)), 0); + return !!((runTimer % duration) === 0); + } + whenKeyAction(args, util) { const key = Scratch.Cast.toString(args.KEY_OPTION).toLowerCase(); const pressed = util.ioQuery('keyboard', 'getKeyIsDown', [key]); @@ -438,7 +462,7 @@ return; } } - + const waiting = util.stackFrame.startedThreads .some(thread => runtime.threads.indexOf(thread) !== -1); if (waiting) { @@ -485,7 +509,7 @@ util.stackFrame.startedThreads.forEach(thread => thread.receivedData = data); } } - + const waiting = util.stackFrame.startedThreads .some(thread => runtime.threads.indexOf(thread) !== -1); if (waiting) { @@ -531,23 +555,6 @@ return [{text: "", value: 0}]; //this should never happen but it's a failsafe } } - - _getBroadcastMsgs() { - // @ts-expect-error - Blockly not typed yet - // eslint-disable-next-line no-undef - const broadcasts = typeof Blockly === 'undefined' ? [] : Blockly.getMainWorkspace() - .getVariableMap() - .getVariablesOfType('broadcast_msg') - .map(model => ({ - text: model.name, - value: model.name - })); - if (broadcasts.length > 0) { - return broadcasts; - } else { - return [{ text: "", value: 0 }]; - } - } } Scratch.extensions.register(new MoreEvents()); From 47ebf54a558f420ca33d8edc689e9234430168ae Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Thu, 17 Aug 2023 01:20:17 +0100 Subject: [PATCH 42/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index b0b1c5bbc7..17a81ede7c 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -462,7 +462,7 @@ return; } } - + const waiting = util.stackFrame.startedThreads .some(thread => runtime.threads.indexOf(thread) !== -1); if (waiting) { @@ -509,7 +509,7 @@ util.stackFrame.startedThreads.forEach(thread => thread.receivedData = data); } } - + const waiting = util.stackFrame.startedThreads .some(thread => runtime.threads.indexOf(thread) !== -1); if (waiting) { From 03548261dfa5202a558d8efdc9f4e21be785df45 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Thu, 17 Aug 2023 04:42:44 +0100 Subject: [PATCH 43/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 17a81ede7c..1bfa34f83f 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -174,7 +174,10 @@ isEdgeActivated: false, arguments: { INPUT: { - type: Scratch.ArgumentType.STRING + // Intentional: + // Encourages people to place a block + // (as opposed to typing a value) + type: null } } }, From 7148788a83be9c0a18f33e613255e12cca5d4ec3 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Mon, 21 Aug 2023 01:06:11 +0100 Subject: [PATCH 44/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 1bfa34f83f..31b218b7e7 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -1,3 +1,7 @@ +// Name: More Events +// ID: lmsMoreEvents +// Description: Start your scripts in new ways. + (function (Scratch) { 'use strict'; From f19914eae51e2c5fd29ba0d57ad88242274c55a3 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Mon, 21 Aug 2023 01:06:28 +0100 Subject: [PATCH 45/47] Delete index.ejs --- website/index.ejs | 816 ---------------------------------------------- 1 file changed, 816 deletions(-) delete mode 100644 website/index.ejs diff --git a/website/index.ejs b/website/index.ejs deleted file mode 100644 index 42fd33669f..0000000000 --- a/website/index.ejs +++ /dev/null @@ -1,816 +0,0 @@ - - - - - - TurboWarp Extension Gallery - - - - - - -
-

- -
TurboWarp Extension Gallery
-

- -

Unlike custom extensions on other websites, these aren't limited by the extension sandbox, so they are a lot more powerful. All extensions are reviewed for safety.

-

- <% if (mode === 'desktop') { %> - To use these extensions in TurboWarp Desktop, hover over the extension and press the add button. - <% } else { %> - To use multiple of these extensions in TurboWarp, hover over the extension and press the button to copy its URL. Then go to the editor, open the extension chooser, then choose the "Custom Extension" option at the bottom, and enter the URL. - <% } %> -

- -
-
These extensions are not compatible with Scratch.
- Projects that use these extensions can't be uploaded to the Scratch website. - They can, however, be used in the packager. -
- -
- <% if (mode === 'desktop') { %> -
Some extensions may be outdated or missing.
- <% - const now = new Date(); - const date = `${now.getFullYear()}-${(now.getMonth() + 1).toString().padStart(2, '0')}-${now.getDate().toString().padStart(2, '0')}`; - %> - For compatibility, security, and offline support, TurboWarp Desktop includes an offline copy of extensions.turbowarp.org from this update's release date (<%= date %>). - Compared to the live website, some extensions may be missing or outdated. - <% } else { %> -
Some extensions may not work in TurboWarp Desktop.
- For compatibility, security, and offline support, each TurboWarp Desktop update contains an offline copy of these extensions from its release date, so some extensions may be outdated or missing. - Use the latest update for best results. - <% } %> -
-
- - <% - const getLinkToRun = (extensionPath) => `https://turbowarp.org/editor?extension=${host}${extensionPath}`; - %> - - <% if (mode === "development") { %> -
-
-

Development Server Tools

-

- Most recently modified extensions: - <% for (const extension of mostRecentExtensions) { %> - <%= extension %> - <% } %> -

-
-
- <% } %> - - - - <% if (mode === 'desktop') { %> - - <% } %> - - <% - const banner = (extensionFile, options = {}) => { - if (extensionFile.endsWith('.js')) { - return `Do not add .js when calling banner(): ${extensionFile}`; - } - const imageSource = extensionImages[extensionFile] ? `images/${extensionImages[extensionFile]}` : 'images/unknown.svg'; - const imageClasses = ["extension-image"]; - if (options.invertDark) imageClasses.push("invert-dark"); - return ` -
- -
- - ${mode === "desktop" ? (` - - `) : (` - Open Extension - `)} -
-
` - }; - - const img = (extensionFile) => { - if (extensionImages[extensionFile]) return `images/${extensionImages[extensionFile]}`; - return 'images/unknown.svg'; - }; - %> - -
-
-
- <%- banner('lab/text') %> -

Animated Text

-

An easy way to display and animate text. Compatible with Scratch Lab's Animated Text experiment.

-
- -
- <%- banner('stretch') %> -

Stretch

-

Stretch sprites horizontally or vertically.

-
- -
- <%- banner('gamepad') %> -

Gamepad

-

Directly access gamepads instead of just mapping buttons to keys.

-
- -
- <%- banner('box2d') %> -

Box2D Physics

-

Two dimensional physics. Originally created by griffpatch.

-
- -
- <%- banner('files') %> -

Files

-

Read and download files.

-
- -
- <%- banner('pointerlock') %> -

Pointerlock

-

Adds blocks for mouse locking. Mouse x & y blocks will report the change since the previous frame while the pointer is locked. Replaces the pointerlock experiment.

-
- -
- <%- banner('cursor') %> -

Mouse Cursor

-

Use custom cursors or hide the cursor. Also allows replacing the cursor with any costume image.

-
- -
- <%- banner('runtime-options') %> -

Runtime Options

-

Get and modify turbo mode, framerate, interpolation, clone limit, stage size, and more.

-
- -
- <%- banner('fetch') %> -

Fetch

-

Make requests to the broader internet.

-
- -
- <%- banner('text') %> -

Text

-

Manipulate characters and text. Originally created by CST1229.

-
- -
- <%- banner('local-storage') %> -

Local Storage

-

Store data persistently. Like cookies, but better.

-
- -
- <%- banner('true-fantom/base') %> -

Base

-

Convert numbers between bases. Created by TrueFantom.

-
- -
- <%- banner('bitwise') %> -

Bitwise

-

Blocks that operate on the binary representation of numbers in computers. Modified by TrueFantom.

-
- -
- <%- banner('Skyhigh173/bigint') %> -

BigInt

-

Math blocks that work on infinitely large integers (no decimals). Created by Skyhigh173.

-
- -
- <%- banner('utilities') %> -

Utilities

-

A bunch of interesting blocks. Originally created by Sheep_maker.

-
- -
- <%- banner('sound') %> -

Sound

-

Play sounds from URLs.

-
- -
- <%- banner('Xeltalliv/clippingblending') %> -

Clipping & Blending

-

Clipping outside of a specified rectangular area and additive color blending. Created by Vadik1.

-
- -
- <%- banner('clipboard') %> -

Clipboard

-

Read and write from the system clipboard.

-
- -
- <%- banner('penplus') %> -

Pen Plus

-

Advanced rendering capabilities. Created by ObviousAlexC.

-
- -
- <%- banner('Lily/Skins') %> -

Skins

-

Have your sprites render as other images or costumes. Created by LilyMakesThings.

-
- -
- <%- banner('obviousAlexC/SensingPlus') %> -

Sensing Plus

-

An extension to the sensing category. Created by ObviousAlexC.

-
- -
- <%- banner('Lily/ClonesPlus') %> -

Clones Plus

-

Expansion of Scratch's clone features. Created by LilyMakesThings.

-
- -
- <%- banner('Lily/LooksPlus') %> -

Looks Plus

-

Expands upon the looks category, allowing you to show/hide, get costume data and edit SVG skins on sprites. Created by LilyMakesThings.

-
- -
- <%- banner('Lily/MoreEvents') %> -

More Events

-

Start your scripts in new ways. Created by LilyMakesThings.

-
- -
- <%- banner('NexusKitten/moremotion') %> -

More Motion

-

More motion-related blocks. Created by NamelessCat.

-
- -
- <%- banner('navigator') %> -

Navigator

-

Details about the user's browser and operating system.

-
- -
- <%- banner('battery') %> -

Battery

-

Access information about the battery of phones or laptops. May not work on all devices and browsers.

-
- -
- <%- banner('TheShovel/CustomStyles') %> -

Custom Styles

-

Customize the appearance of variable monitors and prompts in your project. Created by TheShovel.

-
- -
- <%- banner('mdwalters/notifications') %> -

Notifications

-

Display notifications.

-
- -
- <%- banner('XeroName/Deltatime') %> -

Deltatime

-

Precise delta timing blocks. Created by XeroName.

-
- -
- <%- banner('ar') %> -

Augmented Reality

-

Shows image from camera and performs motion tracking, allowing 3D projects to correctly overlay virtual objects on real world. Created by Vadik1.

-
- -
- <%- banner('encoding') %> -

Encoding

-

Encode and decode strings into their unicode numbers, base 64, or URLs. Created by -SIPC-.

-
- -
- <%- banner('Lily/TempVariables2') %> -

Temporary Variables

-

Create disposable runtime or thread variables. Created by LilyMakesThings.

-
- -
- <%- banner('Lily/MoreTimers') %> -

More Timers

-

Control several timers at once. Created by LilyMakesThings.

-
- -
- <%- banner('clouddata-ping') %> -

Ping Cloud Data

-

Determine whether a cloud variable server is probably up. Originally created by TheShovel.

-
- -
- <%- banner('cloudlink') %> -

Cloudlink

-

Powerful WebSocket extension for Scratch 3. Created by MikeDEV.

-
- -
- <%- banner('true-fantom/network') %> -

Network

-

Various blocks for interacting with the network. Created by TrueFantom.

-
- -
- <%- banner('true-fantom/math') %> -

Math

-

A lot of operators blocks, from exponentiation to trigonometric functions. Created by TrueFantom.

-
- -
- <%- banner('true-fantom/regexp') %> -

RegExp

-

Full interface for working with Regular Expressions. Created by TrueFantom.

-
- -
- <%- banner('true-fantom/couplers') %> -

Couplers

-

A few adapter blocks. Created by TrueFantom.

-
- -
- <%- banner('Lily/AllMenus') %> -

All Menus

-

Special category with every menu from every Scratch category and extensions. Created by LilyMakesThings

-
- -
- <%- banner('Lily/Cast') %> -

Cast

-

Convert values between types. Created by LilyMakesThings

-
- -
- <%- banner('-SIPC-/time') %> -

Time

-

Blocks for interacting with unix timestamps and other date strings. Created by -SIPC-.

-
- -
- <%- banner('-SIPC-/consoles') %> -

Consoles

-

Blocks that interact the JavaScript console built in to your browser's developer tools. Created by -SIPC-.

-
- -
- <%- banner('ZXMushroom63/searchApi') %> -

Search Params

-

Interact with URL search parameters: the part of the URL after a question mark. Created by ZXMushroom63.

-
- -
- <%- banner('TheShovel/ShovelUtils') %> -

ShovelUtils

-

A bunch of miscellaneous blocks. Created by TheShovel.

-
- -
- <%- banner('Skyhigh173/json') %> -

JSON

-

Handle JSON strings and arrays. Created by Skyhigh173.

-
- -
- <%- banner('cs2627883/numericalencoding') %> -

Numerical Encoding

-

Encode strings as numbers for cloud variables. Created by cs2627883.

-
- -
- <%- banner('DT/cameracontrols') %> -

Camera Controls

-

Move the visible part of the stage. Created by DT.

-
- -
- <%- banner('TheShovel/CanvasEffects') %> -

Canvas Effects

-

Apply visual effects to the entire stage. Created by TheShovel.

-
- -
- <%- banner('Longboost/color_channels') %> -

RGB Channels

-

Only render or stamp certain RGB channels.

-
- -
- <%- banner('CST1229/zip') %> -

Zip

-

Create and edit .zip format files, including .sb3 files. Created by CST1229.

-
- -
- <%- banner('TheShovel/LZ-String') %> -

LZ Compress

-

Compress and decompress text using lz-string.

-
- -
- <%- banner('0832/rxFS2') %> -

rxFS

-

Blocks for interacting with a virtual in-memory filesystem. Created by 0832.

-
- -
- <%- banner('NexusKitten/sgrab') %> -

S-Grab

-

Get information about Scratch projects and Scratch users. Created by NamelessCat.

-
- -
- <%- banner('NOname-awa/graphics2d') %> -

Graphics 2D

-

Blocks to compute lengths, angles, and areas in two dimensions. Created by NOname-awa.

-
- -
- <%- banner('NOname-awa/more-comparisons') %> -

More Comparisons

-

More comparison blocks. Created by NOname-awa.

-
- -
- <%- banner('JeremyGamer13/tween') %> -

Tween

-

Easing methods for smooth animations. Created by JeremyGamer13

-
- -
- <%- banner('rixxyx') %> -

RixxyX

-

Various utility blocks. Created by RixTheTyrunt.

-
- -
- <%- banner('qxsck/data-analysis') %> -

Data Analysis

-

Blocks to compute means, medians, maximums, minimums, variances, and modes. Created by qxsck.

-
- -
- <%- banner('qxsck/var-and-list') %> -

Variable and list

-

More blocks related to variables and lists. Created by qxsck.

-
- -
- <%- banner('vercte/dictionaries') %> -

Dictionaries

-

Use the power of dictionaries in your project. Created by Vercte.

-
- -
- <%- banner('godslayerakp/http') %> -

HTTP

-

Comprehensive extension for interacting with external websites. Created by RedMan13.

-
- -
- <%- banner('Lily/CommentBlocks') %> -

Comment Blocks

-

Annotate your scripts. Created by LilyMakesThings.

-
- -
- <%- banner('veggiecan/LongmanDictionary') %> -

Longman Dictionary

-

Get the definitions of words from the Longman Dictionary in your projects. Created by veggiecan0419

-
- -
- <%- banner('CubesterYT/TurboHook') %> -

TurboHook

-

Allows you to use webhooks. Created by CubesterYT.

-
- -
- <%- banner('Alestore/nfcwarp') %> -

NFCWarp

-

Allows reading data from NFC (NDEF) devices. Only works in Chrome on Android. Created by Alestore Games.

-
- -
- <%- banner('itchio') %> -

itch.io

-

Blocks that interact with the itch.io website. Unofficial. Created by softed.

-
- -
- <%- banner('gamejolt') %> -

GameJolt

-

Blocks that allow games to interact with the GameJolt API. Unofficial. Created by softed.

-
- -
- <%- banner('obviousAlexC/newgroundsIO') %> -

Newgrounds

-

Blocks that allow games to interact with the Newgrounds API. Unofficial. Created by ObviousAlexC.

-
- -
- <%- banner('Lily/McUtils') %> -

McUtils

-

Helpful utilities for any fast food employee. Created by LilyMakesThings.

-
-
-
- - - - From 4bde9a6a87e50e7f2ca3895d3ea426ba64a09c8a Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Mon, 21 Aug 2023 01:07:46 +0100 Subject: [PATCH 46/47] Update extensions.json --- extensions/extensions.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/extensions.json b/extensions/extensions.json index 7ec0ffa91d..50eade405e 100644 --- a/extensions/extensions.json +++ b/extensions/extensions.json @@ -22,6 +22,7 @@ "obviousAlexC/SensingPlus", "Lily/ClonesPlus", "Lily/LooksPlus", + "Lily/MoreEvents", "NexusKitten/moremotion", "navigator", "battery", @@ -69,4 +70,4 @@ "gamejolt", "obviousAlexC/newgroundsIO", "Lily/McUtils" -] \ No newline at end of file +] From 36a3bc05f2cf7d1e29583ca10dde64edd3ff00f0 Mon Sep 17 00:00:00 2001 From: LilyMakesThings <127533508+LilyMakesThings@users.noreply.github.com> Date: Wed, 23 Aug 2023 03:55:52 +0100 Subject: [PATCH 47/47] Update MoreEvents.js --- extensions/Lily/MoreEvents.js | 454 ++++++++++++++++++---------------- 1 file changed, 240 insertions(+), 214 deletions(-) diff --git a/extensions/Lily/MoreEvents.js b/extensions/Lily/MoreEvents.js index 31b218b7e7..525d93e3de 100644 --- a/extensions/Lily/MoreEvents.js +++ b/extensions/Lily/MoreEvents.js @@ -3,75 +3,76 @@ // Description: Start your scripts in new ways. (function (Scratch) { - 'use strict'; + "use strict"; const vm = Scratch.vm; const runtime = vm.runtime; - const stopIcon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAQlBMVEUAAAC/UFC8Q0OzTU24SEi4SEi3SEi4R0e4SEi4SEi4SEi4SEi7SUm8SUnMTk7MT0/OT0/PT0/gVVXiVVXsWVn///+CoOd2AAAAC3RSTlMAEBMUu7zLz9D8/dIXnJwAAAABYktHRBXl2PmjAAAAxklEQVRIx+3WwRKDIBAD0JWqVEOtWv7/W3twOqKwELzW3N9wYhORMMYiztgZUZMUAKxqmh5Kno/MG256nzI59Z2mB+BWH+XzUt5RhWoyQjFZkTQFkTBFERlCnAwlDoYUgaHFblpaeL86AK0MvNjMIABmT2cGIAAWniw3ucm/k9ovduEjXzgXtUfJmtrTt9VZzYH9FSB/xvfKZMsiLFmuko61zBTfucjL9RpXf6nEU2MhPxXS86J+kORmjz6V6seViOnG8oT7ApMcjsYZwhXCAAAAAElFTkSuQmCC'; + const stopIcon = + "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAMAAAAp4XiDAAAAQlBMVEUAAAC/UFC8Q0OzTU24SEi4SEi3SEi4R0e4SEi4SEi4SEi4SEi7SUm8SUnMTk7MT0/OT0/PT0/gVVXiVVXsWVn///+CoOd2AAAAC3RSTlMAEBMUu7zLz9D8/dIXnJwAAAABYktHRBXl2PmjAAAAxklEQVRIx+3WwRKDIBAD0JWqVEOtWv7/W3twOqKwELzW3N9wYhORMMYiztgZUZMUAKxqmh5Kno/MG256nzI59Z2mB+BWH+XzUt5RhWoyQjFZkTQFkTBFERlCnAwlDoYUgaHFblpaeL86AK0MvNjMIABmT2cGIAAWniw3ucm/k9ovduEjXzgXtUfJmtrTt9VZzYH9FSB/xvfKZMsiLFmuko61zBTfucjL9RpXf6nEU2MhPxXS86J+kORmjz6V6seViOnG8oT7ApMcjsYZwhXCAAAAAElFTkSuQmCC"; // Source: // https://github.com/TurboWarp/scratch-vm/blob/develop/src/io/keyboard.js // https://github.com/TurboWarp/scratch-blocks/blob/develop/blocks_vertical/event.js const validKeyboardInputs = [ // Special Inputs - { text: 'space', value: 'space' }, - { text: 'up arrow', value: 'up arrow' }, - { text: 'down arrow', value: 'down arrow' }, - { text: 'right arrow', value: 'right arrow' }, - { text: 'left arrow', value: 'left arrow' }, - { text: 'enter', value: 'enter' }, + { text: "space", value: "space" }, + { text: "up arrow", value: "up arrow" }, + { text: "down arrow", value: "down arrow" }, + { text: "right arrow", value: "right arrow" }, + { text: "left arrow", value: "left arrow" }, + { text: "enter", value: "enter" }, // TW: Extra Special Inputs - { text: 'backspace', value: 'backspace' }, - { text: 'delete', value: 'delete' }, - { text: 'shift', value: 'shift' }, - { text: 'caps lock', value: 'caps lock' }, - { text: 'scroll lock', value: 'scroll lock' }, - { text: 'control', value: 'control' }, - { text: 'escape', value: 'escape' }, - { text: 'insert', value: 'insert' }, - { text: 'home', value: 'home' }, - { text: 'end', value: 'end' }, - { text: 'page up', value: 'page up' }, - { text: 'page down', value: 'page down' }, + { text: "backspace", value: "backspace" }, + { text: "delete", value: "delete" }, + { text: "shift", value: "shift" }, + { text: "caps lock", value: "caps lock" }, + { text: "scroll lock", value: "scroll lock" }, + { text: "control", value: "control" }, + { text: "escape", value: "escape" }, + { text: "insert", value: "insert" }, + { text: "home", value: "home" }, + { text: "end", value: "end" }, + { text: "page up", value: "page up" }, + { text: "page down", value: "page down" }, // Letter Keyboard Inputs - { text: 'a', value: 'a' }, - { text: 'b', value: 'b' }, - { text: 'c', value: 'c' }, - { text: 'd', value: 'd' }, - { text: 'e', value: 'e' }, - { text: 'f', value: 'f' }, - { text: 'g', value: 'g' }, - { text: 'h', value: 'h' }, - { text: 'i', value: 'i' }, - { text: 'j', value: 'j' }, - { text: 'k', value: 'k' }, - { text: 'l', value: 'l' }, - { text: 'm', value: 'm' }, - { text: 'n', value: 'n' }, - { text: 'o', value: 'o' }, - { text: 'p', value: 'p' }, - { text: 'q', value: 'q' }, - { text: 'r', value: 'r' }, - { text: 's', value: 's' }, - { text: 't', value: 't' }, - { text: 'u', value: 'u' }, - { text: 'v', value: 'v' }, - { text: 'w', value: 'w' }, - { text: 'x', value: 'x' }, - { text: 'y', value: 'y' }, - { text: 'z', value: 'z' }, + { text: "a", value: "a" }, + { text: "b", value: "b" }, + { text: "c", value: "c" }, + { text: "d", value: "d" }, + { text: "e", value: "e" }, + { text: "f", value: "f" }, + { text: "g", value: "g" }, + { text: "h", value: "h" }, + { text: "i", value: "i" }, + { text: "j", value: "j" }, + { text: "k", value: "k" }, + { text: "l", value: "l" }, + { text: "m", value: "m" }, + { text: "n", value: "n" }, + { text: "o", value: "o" }, + { text: "p", value: "p" }, + { text: "q", value: "q" }, + { text: "r", value: "r" }, + { text: "s", value: "s" }, + { text: "t", value: "t" }, + { text: "u", value: "u" }, + { text: "v", value: "v" }, + { text: "w", value: "w" }, + { text: "x", value: "x" }, + { text: "y", value: "y" }, + { text: "z", value: "z" }, // Number Keyboard Inputs - { text: '0', value: '0' }, - { text: '1', value: '1' }, - { text: '2', value: '2' }, - { text: '3', value: '3' }, - { text: '4', value: '4' }, - { text: '5', value: '5' }, - { text: '6', value: '6' }, - { text: '7', value: '7' }, - { text: '8', value: '8' }, - { text: '9', value: '9' }, + { text: "0", value: "0" }, + { text: "1", value: "1" }, + { text: "2", value: "2" }, + { text: "3", value: "3" }, + { text: "4", value: "4" }, + { text: "5", value: "5" }, + { text: "6", value: "6" }, + { text: "7", value: "7" }, + { text: "8", value: "8" }, + { text: "9", value: "9" }, ]; var lastValues = {}; @@ -81,29 +82,31 @@ constructor() { // Stop Sign Clicked contributed by @CST1229 runtime.shouldExecuteStopClicked = true; - runtime.on('BEFORE_EXECUTE', () => { + runtime.on("BEFORE_EXECUTE", () => { runTimer++; runtime.shouldExecuteStopClicked = false; - runtime.startHats('lmsMoreEvents_forever'); - runtime.startHats('lmsMoreEvents_whileTrueFalse'); - runtime.startHats('lmsMoreEvents_whenValueChanged'); - runtime.startHats('lmsMoreEvents_everyDuration'); - runtime.startHats('lmsMoreEvents_whileKeyPressed'); + runtime.startHats("lmsMoreEvents_forever"); + runtime.startHats("lmsMoreEvents_whileTrueFalse"); + runtime.startHats("lmsMoreEvents_whenValueChanged"); + runtime.startHats("lmsMoreEvents_everyDuration"); + runtime.startHats("lmsMoreEvents_whileKeyPressed"); }); - runtime.on('PROJECT_START', () => { + runtime.on("PROJECT_START", () => { runTimer = 0; }); - runtime.on('PROJECT_STOP_ALL', () => { + runtime.on("PROJECT_STOP_ALL", () => { runTimer = 0; if (runtime.shouldExecuteStopClicked) - queueMicrotask(() => runtime.startHats('lmsMoreEvents_whenStopClicked')); + queueMicrotask(() => + runtime.startHats("lmsMoreEvents_whenStopClicked") + ); }); - runtime.on('AFTER_EXECUTE', () => { + runtime.on("AFTER_EXECUTE", () => { runtime.shouldExecuteStopClicked = true; }); const originalGreenFlag = vm.greenFlag; - vm.greenFlag = function() { + vm.greenFlag = function () { runtime.shouldExecuteStopClicked = false; originalGreenFlag.call(this); }; @@ -111,284 +114,285 @@ getInfo() { return { - id: 'lmsMoreEvents', - name: 'More Events', - color1: '#FFBF00', - color2: '#E6AC00', - color3: '#CC9900', + id: "lmsMoreEvents", + name: "More Events", + color1: "#FFBF00", + color2: "#E6AC00", + color3: "#CC9900", blocks: [ { - opcode: 'whenStopClicked', + opcode: "whenStopClicked", blockType: Scratch.BlockType.EVENT, - text: 'when [STOP] clicked', + text: "when [STOP] clicked", isEdgeActivated: false, arguments: { STOP: { type: Scratch.ArgumentType.IMAGE, - dataURI: stopIcon - } - } + dataURI: stopIcon, + }, + }, }, { - opcode: 'forever', + opcode: "forever", blockType: Scratch.BlockType.EVENT, - text: 'forever', - isEdgeActivated: false + text: "forever", + isEdgeActivated: false, }, - '---', + "---", { - opcode: 'whenTrueFalse', + opcode: "whenTrueFalse", blockType: Scratch.BlockType.HAT, - text: 'when [CONDITION] becomes [STATE]', + text: "when [CONDITION] becomes [STATE]", isEdgeActivated: true, arguments: { CONDITION: { - type: Scratch.ArgumentType.BOOLEAN + type: Scratch.ArgumentType.BOOLEAN, }, STATE: { type: Scratch.ArgumentType.STRING, - menu: 'boolean' - } - } + menu: "boolean", + }, + }, }, { - opcode: 'whileTrueFalse', + opcode: "whileTrueFalse", blockType: Scratch.BlockType.HAT, - text: 'while [CONDITION] is [STATE]', + text: "while [CONDITION] is [STATE]", isEdgeActivated: false, arguments: { CONDITION: { - type: Scratch.ArgumentType.BOOLEAN + type: Scratch.ArgumentType.BOOLEAN, }, STATE: { type: Scratch.ArgumentType.STRING, - menu: 'boolean' - } - } + menu: "boolean", + }, + }, }, - '---', + "---", { - opcode: 'whenValueChanged', + opcode: "whenValueChanged", blockType: Scratch.BlockType.HAT, - text: 'when [INPUT] is changed', + text: "when [INPUT] is changed", isEdgeActivated: false, arguments: { INPUT: { // Intentional: // Encourages people to place a block // (as opposed to typing a value) - type: null - } - } + type: null, + }, + }, }, { - opcode: 'everyDuration', + opcode: "everyDuration", blockType: Scratch.BlockType.HAT, - text: 'every [DURATION] frames', + text: "every [DURATION] frames", isEdgeActivated: false, arguments: { DURATION: { type: Scratch.ArgumentType.NUMBER, - defaultValue: 3 - } - } + defaultValue: 3, + }, + }, }, - '---', + "---", { - opcode: 'whenKeyAction', + opcode: "whenKeyAction", blockType: Scratch.BlockType.HAT, - text: 'when [KEY_OPTION] key [ACTION]', + text: "when [KEY_OPTION] key [ACTION]", isEdgeActivated: true, arguments: { KEY_OPTION: { type: Scratch.ArgumentType.STRING, - defaultValue: 'space', - menu: 'keyboardButtons' + defaultValue: "space", + menu: "keyboardButtons", }, ACTION: { type: Scratch.ArgumentType.STRING, - menu: 'action' - } - } + menu: "action", + }, + }, }, { - opcode: 'whileKeyPressed', + opcode: "whileKeyPressed", blockType: Scratch.BlockType.HAT, - text: 'while [KEY_OPTION] key pressed', + text: "while [KEY_OPTION] key pressed", isEdgeActivated: false, arguments: { KEY_OPTION: { type: Scratch.ArgumentType.STRING, - defaultValue: 'space', - menu: 'keyboardButtons' - } - } + defaultValue: "space", + menu: "keyboardButtons", + }, + }, }, - '---', + "---", { - opcode: 'broadcastToTarget', + opcode: "broadcastToTarget", blockType: Scratch.BlockType.COMMAND, - text: 'broadcast [BROADCAST_OPTION] to [TARGET]', + text: "broadcast [BROADCAST_OPTION] to [TARGET]", arguments: { BROADCAST_OPTION: { - type: null + type: null, }, TARGET: { type: Scratch.ArgumentType.STRING, - menu: 'targetMenu' - } + menu: "targetMenu", + }, }, - hideFromPalette: true + hideFromPalette: true, }, { - opcode: 'broadcastToTargetAndWait', + opcode: "broadcastToTargetAndWait", blockType: Scratch.BlockType.COMMAND, - text: 'broadcast [BROADCAST_OPTION] to [TARGET] and wait', + text: "broadcast [BROADCAST_OPTION] to [TARGET] and wait", arguments: { BROADCAST_OPTION: { - type: null + type: null, }, TARGET: { type: Scratch.ArgumentType.STRING, - menu: 'targetMenu' - } + menu: "targetMenu", + }, }, - hideFromPalette: true + hideFromPalette: true, }, - '---', + "---", { - opcode: 'broadcastData', + opcode: "broadcastData", blockType: Scratch.BlockType.COMMAND, - text: 'broadcast [BROADCAST_OPTION] with data [DATA]', + text: "broadcast [BROADCAST_OPTION] with data [DATA]", arguments: { BROADCAST_OPTION: { - type: null + type: null, }, DATA: { - type: Scratch.ArgumentType.STRING - } + type: Scratch.ArgumentType.STRING, + }, }, - hideFromPalette: true + hideFromPalette: true, }, { - opcode: 'broadcastDataAndWait', + opcode: "broadcastDataAndWait", blockType: Scratch.BlockType.COMMAND, - text: 'broadcast [BROADCAST_OPTION] with data [DATA] and wait', + text: "broadcast [BROADCAST_OPTION] with data [DATA] and wait", arguments: { BROADCAST_OPTION: { - type: null + type: null, }, DATA: { - type: Scratch.ArgumentType.STRING - } + type: Scratch.ArgumentType.STRING, + }, }, - hideFromPalette: true + hideFromPalette: true, }, { blockType: Scratch.BlockType.XML, - xml: '' + xml: '', }, { - opcode: 'receivedData', + opcode: "receivedData", blockType: Scratch.BlockType.REPORTER, - text: 'received data', + text: "received data", disableMonitor: true, - allowDropAnywhere: true + allowDropAnywhere: true, }, - '---', + "---", { - opcode: 'broadcastDataToTarget', + opcode: "broadcastDataToTarget", blockType: Scratch.BlockType.COMMAND, - text: 'broadcast [BROADCAST_OPTION] to [TARGET] with data [DATA]', - func: 'broadcastToTarget', + text: "broadcast [BROADCAST_OPTION] to [TARGET] with data [DATA]", + func: "broadcastToTarget", arguments: { BROADCAST_OPTION: { - type: null + type: null, }, TARGET: { type: Scratch.ArgumentType.STRING, - menu: 'targetMenu' + menu: "targetMenu", }, DATA: { - type: Scratch.ArgumentType.STRING - } + type: Scratch.ArgumentType.STRING, + }, }, - hideFromPalette: true + hideFromPalette: true, }, { - opcode: 'broadcastDataToTargetAndWait', + opcode: "broadcastDataToTargetAndWait", blockType: Scratch.BlockType.COMMAND, - text: 'broadcast [BROADCAST_OPTION] to [TARGET] with data [DATA] and wait', - func: 'broadcastToTargetAndWait', + text: "broadcast [BROADCAST_OPTION] to [TARGET] with data [DATA] and wait", + func: "broadcastToTargetAndWait", arguments: { BROADCAST_OPTION: { - type: null + type: null, }, TARGET: { type: Scratch.ArgumentType.STRING, - menu: 'targetMenu' + menu: "targetMenu", }, DATA: { - type: Scratch.ArgumentType.STRING - } + type: Scratch.ArgumentType.STRING, + }, }, - hideFromPalette: true + hideFromPalette: true, }, { blockType: Scratch.BlockType.XML, - xml: '' - } + xml: '', + }, ], menus: { // Targets have acceptReporters: true targetMenu: { acceptReporters: true, - items: '_getTargets' + items: "_getTargets", }, keyboardButtons: { acceptReporters: true, - items: validKeyboardInputs + items: validKeyboardInputs, }, // Attributes have acceptReporters: false action: { acceptReporters: false, - items: ['hit', 'released'] + items: ["hit", "released"], }, boolean: { acceptReporters: false, - items: ['true', 'false'] + items: ["true", "false"], }, state: { acceptReporters: false, - items: ['enabled', 'disabled'] - } - } + items: ["enabled", "disabled"], + }, + }, }; } whenTrueFalse(args) { - return (args.STATE === 'true') ? args.CONDITION : !args.CONDITION; + return args.STATE === "true" ? args.CONDITION : !args.CONDITION; } whileTrueFalse(args) { - return (args.STATE === 'true') ? args.CONDITION : !args.CONDITION; + return args.STATE === "true" ? args.CONDITION : !args.CONDITION; } whenValueChanged(args, util) { const blockId = util.thread.peekStack(); - if (!lastValues[blockId]) lastValues[blockId] = Scratch.Cast.toString(args.INPUT); + if (!lastValues[blockId]) + lastValues[blockId] = Scratch.Cast.toString(args.INPUT); if (lastValues[blockId] !== Scratch.Cast.toString(args.INPUT)) { lastValues[blockId] = Scratch.Cast.toString(args.INPUT); return true; @@ -397,19 +401,22 @@ } everyDuration(args, util) { - const duration = Math.max(Math.round(Scratch.Cast.toNumber(args.DURATION)), 0); - return !!((runTimer % duration) === 0); + const duration = Math.max( + Math.round(Scratch.Cast.toNumber(args.DURATION)), + 0 + ); + return !!(runTimer % duration === 0); } whenKeyAction(args, util) { const key = Scratch.Cast.toString(args.KEY_OPTION).toLowerCase(); - const pressed = util.ioQuery('keyboard', 'getKeyIsDown', [key]); - return (args.ACTION === 'released') ? !pressed : pressed; + const pressed = util.ioQuery("keyboard", "getKeyIsDown", [key]); + return args.ACTION === "released" ? !pressed : pressed; } whileKeyPressed(args, util) { const key = Scratch.Cast.toString(args.KEY_OPTION).toLowerCase(); - return util.ioQuery('keyboard', 'getKeyIsDown', [key]); + return util.ioQuery("keyboard", "getKeyIsDown", [key]); } broadcastToTarget(args, util) { @@ -426,20 +433,24 @@ startedThreads = [ ...startedThreads, ...util.startHats( - 'event_whenbroadcastreceived', { - BROADCAST_OPTION: broadcastOption + "event_whenbroadcastreceived", + { + BROADCAST_OPTION: broadcastOption, }, - clone - )]; + clone + ), + ]; if (data) { - startedThreads.forEach(thread => thread.receivedData = args.DATA); + startedThreads.forEach((thread) => (thread.receivedData = args.DATA)); } } } broadcastToTargetAndWait(args, util) { if (!util.stackFrame.broadcastVar) { - util.stackFrame.broadcastVar = Scratch.Cast.toString(args.BROADCAST_OPTION); + util.stackFrame.broadcastVar = Scratch.Cast.toString( + args.BROADCAST_OPTION + ); } const spriteTarget = this._getTargetFromMenu(args.TARGET); @@ -456,13 +467,17 @@ util.stackFrame.startedThreads = [ ...util.stackFrame.startedThreads, ...util.startHats( - 'event_whenbroadcastreceived', { - BROADCAST_OPTION: broadcastOption + "event_whenbroadcastreceived", + { + BROADCAST_OPTION: broadcastOption, }, - clone - )]; + clone + ), + ]; if (data) { - util.stackFrame.startedThreads.forEach(thread => thread.receivedData = args.DATA); + util.stackFrame.startedThreads.forEach( + (thread) => (thread.receivedData = args.DATA) + ); } } if (util.stackFrame.startedThreads.length === 0) { @@ -470,12 +485,14 @@ } } - const waiting = util.stackFrame.startedThreads - .some(thread => runtime.threads.indexOf(thread) !== -1); + const waiting = util.stackFrame.startedThreads.some( + (thread) => runtime.threads.indexOf(thread) !== -1 + ); if (waiting) { if ( - util.stackFrame.startedThreads - .every(thread => runtime.isWaitingThread(thread)) + util.stackFrame.startedThreads.every((thread) => + runtime.isWaitingThread(thread) + ) ) { util.yieldTick(); } else { @@ -491,38 +508,47 @@ const data = Scratch.Cast.toString(args.DATA); - let threads = util.startHats('event_whenbroadcastreceived', {BROADCAST_OPTION: broadcast}); - threads.forEach(thread => thread.receivedData = data); + let threads = util.startHats("event_whenbroadcastreceived", { + BROADCAST_OPTION: broadcast, + }); + threads.forEach((thread) => (thread.receivedData = data)); } broadcastDataAndWait(args, util) { const data = Scratch.Cast.toString(args.DATA); if (!util.stackFrame.broadcastVar) { - util.stackFrame.broadcastVar = Scratch.Cast.toString(args.BROADCAST_OPTION); + util.stackFrame.broadcastVar = Scratch.Cast.toString( + args.BROADCAST_OPTION + ); } if (util.stackFrame.broadcastVar) { const broadcastOption = util.stackFrame.broadcastVar; if (!util.stackFrame.startedThreads) { util.stackFrame.startedThreads = util.startHats( - 'event_whenbroadcastreceived', { - BROADCAST_OPTION: broadcastOption - }, + "event_whenbroadcastreceived", + { + BROADCAST_OPTION: broadcastOption, + } ); if (util.stackFrame.startedThreads.length === 0) { return; } else { - util.stackFrame.startedThreads.forEach(thread => thread.receivedData = data); + util.stackFrame.startedThreads.forEach( + (thread) => (thread.receivedData = data) + ); } } - const waiting = util.stackFrame.startedThreads - .some(thread => runtime.threads.indexOf(thread) !== -1); + const waiting = util.stackFrame.startedThreads.some( + (thread) => runtime.threads.indexOf(thread) !== -1 + ); if (waiting) { if ( - util.stackFrame.startedThreads - .every(thread => runtime.isWaitingThread(thread)) + util.stackFrame.startedThreads.every((thread) => + runtime.isWaitingThread(thread) + ) ) { util.yieldTick(); } else { @@ -534,17 +560,17 @@ receivedData(args, util) { const received = util.thread.receivedData; - return (received) ? received : ''; + return received ? received : ""; } - _getTargetFromMenu (targetName) { + _getTargetFromMenu(targetName) { let target = Scratch.vm.runtime.getSpriteTargetByName(targetName); - if (targetName === '_stage_') target = runtime.getTargetForStage(); + if (targetName === "_stage_") target = runtime.getTargetForStage(); return target; } _getTargets() { - const spriteNames = [{text: 'Stage', value: '_stage_'}]; + const spriteNames = [{ text: "Stage", value: "_stage_" }]; const targets = Scratch.vm.runtime.targets; for (let index = 1; index < targets.length; index++) { const target = targets[index]; @@ -552,14 +578,14 @@ const targetName = target.getName(); spriteNames.push({ text: targetName, - value: targetName + value: targetName, }); } } if (spriteNames.length > 0) { return spriteNames; } else { - return [{text: "", value: 0}]; //this should never happen but it's a failsafe + return [{ text: "", value: 0 }]; //this should never happen but it's a failsafe } } }