From eede8105d1ecca28464f26e8d1436069376c22ad Mon Sep 17 00:00:00 2001
From: sjhuang26 <sjhuang26@gmail.com>
Date: Fri, 1 Dec 2017 20:06:55 -0500
Subject: [PATCH] Clear answer on green flag

---
 src/blocks/scratch3_sensing.js |  5 +++++
 src/engine/runtime.js          | 10 ++++++++++
 2 files changed, 15 insertions(+)

diff --git a/src/blocks/scratch3_sensing.js b/src/blocks/scratch3_sensing.js
index 19357c88e..b23fe740e 100644
--- a/src/blocks/scratch3_sensing.js
+++ b/src/blocks/scratch3_sensing.js
@@ -21,6 +21,7 @@ class Scratch3SensingBlocks {
         this._questionList = [];
 
         this.runtime.on('ANSWER', this._onAnswer.bind(this));
+        this.runtime.on('PROJECT_START', this._resetAnswer.bind(this));
         this.runtime.on('PROJECT_STOP_ALL', this._clearAllQuestions.bind(this));
     }
 
@@ -73,6 +74,10 @@ class Scratch3SensingBlocks {
         }
     }
 
+    _resetAnswer () {
+        this._answer = '';
+    }
+
     _enqueueAsk (question, resolve, target, wasVisible, wasStage) {
         this._questionList.push([question, resolve, target, wasVisible, wasStage]);
     }
diff --git a/src/engine/runtime.js b/src/engine/runtime.js
index 8131bdd86..a8e044e37 100644
--- a/src/engine/runtime.js
+++ b/src/engine/runtime.js
@@ -317,6 +317,15 @@ class Runtime extends EventEmitter {
         return 'BLOCK_GLOW_OFF';
     }
 
+    /**
+     * Event name when the project is started (threads may not necessarily be
+     * running).
+     * @const {string}
+     */
+    static get PROJECT_START () {
+        return 'PROJECT_START';
+    }
+
     /**
      * Event name when threads start running.
      * Used by the UI to indicate running status.
@@ -1057,6 +1066,7 @@ class Runtime extends EventEmitter {
      */
     greenFlag () {
         this.stopAll();
+        this.emit(Runtime.PROJECT_START);
         this.ioDevices.clock.resetProjectTimer();
         this.clearEdgeActivatedValues();
         // Inform all targets of the green flag.