From 18107cde7b26ffe954e5a98ffc86e9ec655ec6c6 Mon Sep 17 00:00:00 2001 From: Christopher Willis-Ford Date: Mon, 13 Feb 2017 14:35:50 -0800 Subject: [PATCH] Reverse target iteration in `allScriptsDo` The `allStacksAndOwnersDo` function in Scratch 2.0 runtime iterates targets in reverse and projects sometimes rely on that for correct initialization. If, for example, each sprite runs a "go back 999 layers" or "go to front" block as its first action, the order of execution will determine the ordering of the layers. This change makes Scratch 3.0 match the Scratch 2.0 execution order. --- src/engine/runtime.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index fc3b17a06..d9e59d36a 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -414,7 +414,7 @@ Runtime.prototype.allScriptsDo = function (f, optTarget) { if (optTarget) { targets = [optTarget]; } - for (var t = 0; t < targets.length; t++) { + for (var t = targets.length - 1; t >= 0; t--) { var target = targets[t]; var scripts = target.blocks.getScripts(); for (var j = 0; j < scripts.length; j++) {