From 8e922e93afc0777d8215464608c34a416b750021 Mon Sep 17 00:00:00 2001 From: sksum <55449862+sksum@users.noreply.github.com> Date: Thu, 27 Aug 2020 04:47:45 +0530 Subject: [PATCH] rerun flowBLock functions rerun flowBLock functions connected to "pitchHertz" / "currentPitch" --- js/logo.js | 5 +++++ js/turtle-singer.js | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/js/logo.js b/js/logo.js index 372607ea89..1328fb8308 100644 --- a/js/logo.js +++ b/js/logo.js @@ -169,6 +169,7 @@ class Logo { this.temperamentSelected = []; this.customTemperamentDefined = false; + this.specialArgs = []; if (_THIS_IS_MUSIC_BLOCKS_) { // Load the default synthesizer @@ -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 + } } } diff --git a/js/turtle-singer.js b/js/turtle-singer.js index b6e58ef12e..ced0625acd 100644 --- a/js/turtle-singer.js +++ b/js/turtle-singer.js @@ -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] + ); + } + } } }