From 1decd331ad2001540341fb0ce88df71b676e554f Mon Sep 17 00:00:00 2001 From: Muffin Date: Wed, 23 Aug 2023 14:50:42 -0500 Subject: [PATCH] Alow LOOP and CONDITION blocks to use startBranch in interpreter and remove rounding --- src/engine/execute.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/engine/execute.js b/src/engine/execute.js index 6bcf6da8..7e94ee9a 100644 --- a/src/engine/execute.js +++ b/src/engine/execute.js @@ -85,11 +85,8 @@ const handleReport = function (resolvedValue, sequencer, thread, blockCached, la // Predicate returned false: do not allow script to run sequencer.retireThread(thread); } - } else if (isConditional) { - const branch = Math.round(resolvedValue); - sequencer.stepToBranch(thread, branch, false); - } else if (isLoop && cast.toBoolean(resolvedValue)) { - sequencer.stepToBranch(thread, 1, true); + } else if ((isConditional || isLoop) && typeof resolvedValue !== 'undefined') { + sequencer.stepToBranch(thread, cast.toNumber(resolvedValue), isLoop); } else { // In a non-hat, report the value visually if necessary if // at the top of the thread stack.