Cast 'create clone' argument to string. Resolves GH-974

This commit is contained in:
Andrew Sliwinski 2018-04-26 10:29:29 -04:00
parent cde801bc17
commit 218725d771

View file

@ -144,15 +144,21 @@ class Scratch3ControlBlocks {
} }
createClone (args, util) { createClone (args, util) {
// Cast argument to string
args.CLONE_OPTION = Cast.toString(args.CLONE_OPTION);
// Set clone target
let cloneTarget; let cloneTarget;
if (args.CLONE_OPTION === '_myself_') { if (args.CLONE_OPTION === '_myself_') {
cloneTarget = util.target; cloneTarget = util.target;
} else { } else {
cloneTarget = this.runtime.getSpriteTargetByName(args.CLONE_OPTION); 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(); const newClone = cloneTarget.makeClone();
if (newClone) { if (newClone) {
this.runtime.targets.push(newClone); this.runtime.targets.push(newClone);