Skip to content

Commit

Permalink
Change logic compare block to eject mismatched blocks.
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilFraser committed Jan 29, 2015
1 parent 193c474 commit 69294d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
21 changes: 12 additions & 9 deletions blocks/logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,15 +312,18 @@ Blockly.Blocks['logic_compare'] = {
}
var blockA = this.getInputTargetBlock('A');
var blockB = this.getInputTargetBlock('B');
if (blockA) {
this.getInput('B').setCheck(blockA.outputConnection.check_);
}
if (blockB) {
this.getInput('A').setCheck(blockB.outputConnection.check_);
}
if (!blockA && !blockB) {
this.getInput('A').setCheck(null);
this.getInput('B').setCheck(null);
// Keep track of which block was added second
// (so the first block may be ejected upon mismatch).
if (blockA && !blockB) {
this.blockAPriority_ = false;
} else if (!blockA && blockB) {
this.blockAPriority_ = true;
} else if (blockA && blockB &&
!blockA.outputConnection.checkType_(blockB.outputConnection)) {
// Mismatch between two inputs. Disconnect one and bump it away.
var child = this.blockAPriority_ ? blockB : blockA;
child.setParent(null);
child.bumpNeighbours_();
}
}
};
Expand Down
4 changes: 2 additions & 2 deletions blocks_compressed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 69294d8

Please sign in to comment.