From 2d736f2b871fdcec1c6cd9c063be3d72956db933 Mon Sep 17 00:00:00 2001 From: Tim Mickel Date: Thu, 22 Sep 2016 17:00:38 -0400 Subject: [PATCH] "Wait until" implementation (#210) --- src/blocks/scratch3_control.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/blocks/scratch3_control.js b/src/blocks/scratch3_control.js index 5f3370895..eab6c1a0f 100644 --- a/src/blocks/scratch3_control.js +++ b/src/blocks/scratch3_control.js @@ -19,6 +19,7 @@ Scratch3ControlBlocks.prototype.getPrimitives = function() { 'control_repeat_until': this.repeatUntil, 'control_forever': this.forever, 'control_wait': this.wait, + 'control_wait_until': this.waitUntil, 'control_if': this.if, 'control_if_else': this.ifElse, 'control_stop': this.stop, @@ -76,6 +77,14 @@ Scratch3ControlBlocks.prototype.repeatUntil = function(args, util) { } }; +Scratch3ControlBlocks.prototype.waitUntil = function(args, util) { + var condition = Cast.toBoolean(args.CONDITION); + // Only execute once per frame. + if (!condition) { + util.yieldFrame(); + } +}; + Scratch3ControlBlocks.prototype.forever = function(args, util) { // Only execute once per frame. // When the branch finishes, `forever` will be executed again and