From 5973e2d305bdf3762001bee94de4326c77572ede Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Mon, 22 May 2017 15:18:48 -0400 Subject: [PATCH] Add reporting for block params --- src/engine/blocks.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/engine/blocks.js b/src/engine/blocks.js index a65e4ac13..c05951711 100644 --- a/src/engine/blocks.js +++ b/src/engine/blocks.js @@ -267,6 +267,25 @@ class Blocks { } } + /** + * Serialize block fields and input fields for reporting new monitors + * @param {!object} block Block to be paramified. + * @return {!object} object of param key/values. + */ + getBlockParams (block) { + const params = {}; + for (const key in block.fields) { + params[key] = block.fields[key].value; + } + for (const inputKey in block.inputs) { + const inputBlock = this._blocks[block.inputs[inputKey].block]; + for (const key in inputBlock.fields) { + params[key] = inputBlock.fields[key].value; + } + } + return params; + } + /** * Block management: change block field values * @param {!object} args Blockly change event to be processed @@ -297,6 +316,7 @@ class Blocks { // @todo(vm#564) this will collide if multiple sprites use same block id: block.id, opcode: block.opcode, + params: this.getBlockParams(block), // @todo(vm#565) for numerical values with decimals, some countries use comma value: '' });