mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-05-17 17:01:02 -04:00
Set the cloud provider and request updates to the cloud var when updating the variable through blocks.
This commit is contained in:
parent
4959ab9ff3
commit
aa200e6df3
2 changed files with 15 additions and 1 deletions
src
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue