Merge pull request #1087 from thisandagain/bugfix/974

Cast 'create clone' argument to string
This commit is contained in:
Andrew Sliwinski 2018-04-26 14:57:32 -04:00 committed by GitHub
commit 1ed5d57c98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -144,15 +144,21 @@ class Scratch3ControlBlocks {
}
createClone (args, util) {
// Cast argument to string
args.CLONE_OPTION = Cast.toString(args.CLONE_OPTION);
// Set clone target
let cloneTarget;
if (args.CLONE_OPTION === '_myself_') {
cloneTarget = util.target;
} else {
cloneTarget = this.runtime.getSpriteTargetByName(args.CLONE_OPTION);
}
if (!cloneTarget) {
return;
}
// If clone target is not found, return
if (!cloneTarget) return;
// Create clone
const newClone = cloneTarget.makeClone();
if (newClone) {
this.runtime.targets.push(newClone);