Set the cloud provider and request updates to the cloud var when updating the variable through blocks.

This commit is contained in:
Karishma Chadha 2018-10-29 00:59:06 -04:00
parent 4959ab9ff3
commit aa200e6df3
2 changed files with 15 additions and 1 deletions

View file

@ -45,6 +45,10 @@ class Scratch3DataBlocks {
const variable = util.target.lookupOrCreateVariable(
args.VARIABLE.id, args.VARIABLE.name);
variable.value = args.VALUE;
if (variable.isCloud) {
util.ioQuery('cloud', 'requestUpdateVariable', [variable.name, args.VALUE]);
}
}
changeVariableBy (args, util) {
@ -52,7 +56,12 @@ class Scratch3DataBlocks {
args.VARIABLE.id, args.VARIABLE.name);
const castedValue = Cast.toNumber(variable.value);
const dValue = Cast.toNumber(args.VALUE);
variable.value = castedValue + dValue;
const newValue = castedValue + dValue;
variable.value = newValue;
if (variable.isCloud) {
util.ioQuery('cloud', 'requestUpdateVariable', [variable.name, newValue]);
}
}
changeMonitorVisibility (id, visible) {

View file

@ -218,6 +218,10 @@ class VirtualMachine extends EventEmitter {
this.runtime.ioDevices.video.setProvider(videoProvider);
}
setCloudProvider (cloudProvider) {
this.runtime.ioDevices.cloud.setProvider(cloudProvider);
}
/**
* Tell the specified extension to scan for a peripheral.
* @param {string} extensionId - the id of the extension.
@ -463,6 +467,7 @@ class VirtualMachine extends EventEmitter {
this.emitTargetsUpdate();
this.emitWorkspaceUpdate();
this.runtime.setEditingTarget(this.editingTarget);
this.runtime.ioDevices.cloud.setStage(this.runtime.getTargetForStage());
});
}