Skip to content

Commit

Permalink
rerun flowBLock functions
Browse files Browse the repository at this point in the history
rerun flowBLock functions connected to "pitchHertz" / "currentPitch"
  • Loading branch information
sksum committed Aug 26, 2020
1 parent 30477c0 commit 8e922e9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions js/logo.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class Logo {

this.temperamentSelected = [];
this.customTemperamentDefined = false;
this.specialArgs = [];

if (_THIS_IS_MUSIC_BLOCKS_) {
// Load the default synthesizer
Expand Down Expand Up @@ -1521,6 +1522,10 @@ class Logo {
)
);
}
if (logo.turtles.ithTurtle(turtle).singer.inNoteBlock.length > 0 &&
["pitchinhertz","currentpitch"].indexOf(logo.blocks.blockList[logo.blocks.blockList[blk].connections[i]].name) !== -1) {
logo.specialArgs.push([args, logo, turtle, blk, receivedArg, null, isflow]); //redo after noteBlock Ends
}
}
}

Expand Down
41 changes: 41 additions & 0 deletions js/turtle-singer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2066,6 +2066,47 @@ class Singer {

if (last(tur.singer.inNoteBlock) !== null) {
__playnote();

if (logo.specialArgs.length > 0) {
let runAgainBlockParam = logo.specialArgs.pop()
let _ar = runAgainBlockParam
let blockN = _ar[3];

//update args for pitch in hertz and current pitch and then redo the flow block they are attatched to(print/storein etc).

let args = [];
for (let i = 1; i <= logo.blocks.blockList[blockN].protoblock.args; i++) {
if (logo.blocks.blockList[blockN].protoblock.dockTypes[i] === "in") {
if (logo.blocks.blockList[blockN].connections[i] == null) {
console.debug("skipping inflow args");
} else {
args.push(logo.blocks.blockList[blockN].connections[i]);
}
} else {
args.push(
logo.parseArg(
logo,
_ar[2],
logo.blocks.blockList[blockN].connections[i],
blockN,
_ar[4]
)
);
}
}
//args, logo, turtle, blk, receivedArg, null, isflow
if (typeof logo.blocks.blockList[blockN].protoblock.flow === "function") {
logo.blocks.blockList[blockN].protoblock.flow(
args,
_ar[1],
_ar[2],
_ar[3],
_ar[4],
_ar[5],
_ar[6]
);
}
}
}
}

Expand Down

0 comments on commit 8e922e9

Please sign in to comment.