Skip to content

Commit

Permalink
Cast 'create clone' argument to string. Resolves scratchfoundationGH-974
Browse files Browse the repository at this point in the history
  • Loading branch information
thisandagain committed Apr 26, 2018
1 parent cde801b commit 218725d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/blocks/scratch3_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 218725d

Please sign in to comment.