added API: "switchTo"

snap7
jmoenig 2021-11-16 14:40:25 +01:00
rodzic 50e0242181
commit 72c3e87ad1
1 zmienionych plików z 10 dodań i 1 usunięć

Wyświetl plik

@ -39,7 +39,8 @@
*/
/*global modules, IDE_Morph, isString, Map, List, world, isNil, Project*/
/*global modules, IDE_Morph, isString, Map, List, world, isNil, Project,
detect*/
/*jshint esversion: 6*/
@ -78,6 +79,14 @@ IDE_Morph.prototype.getCurrentScene = function () {
return this.scene.name;
};
IDE_Morph.prototype.switchTo = function (sceneName) {
var scene = detect(this.scenes.itemsArray(), scn => scn.name === sceneName);
if (scene === null) {
throw new Error('cannot find scene ' + sceneName);
}
this.switchToScene(scene);
};
IDE_Morph.prototype.broadcast = function(message, callback) {
// same as using the broadcast block - launch all scripts
// in the current project reacting to the specified message,