Code cleanup and refactoring, and getting scratch3_event broadcast functionality to look up the variable name instead of getting it ad-hoc.

This commit is contained in:
Karishma Chadha 2017-11-28 22:33:27 -05:00
parent 0a15190b85
commit b674a0c047
4 changed files with 30 additions and 31 deletions
src/engine

View file

@ -169,17 +169,8 @@ const execute = function (sequencer, thread) {
// Add all fields on this block to the argValues.
for (const fieldName in fields) {
if (!fields.hasOwnProperty(fieldName)) continue;
if (fieldName === 'VARIABLE' || fieldName === 'LIST') {
argValues[fieldName] = fields[fieldName].id;
} else if (fieldName === 'BROADCAST_OPTION') {
// TODO KARISHMA (scratch-blocks #1258) this will change when we
// upstream blockly issue #1395 is fixed.
// we need both the id and the name here, because
// this object eventually gets passed to scratch3_event.broadcast
// which will create the message for the first time if one with the
// given id doesn't exist
// (e.g. default broadcast message, 'message1')
if (fieldName === 'VARIABLE' || fieldName === 'LIST' ||
fieldName === 'BROADCAST_OPTION') {
argValues[fieldName] = {
id: fields[fieldName].id,
name: fields[fieldName].value