Skip to content

Commit

Permalink
Merge pull request #2896 from entrylabs/issue/8642
Browse files Browse the repository at this point in the history
issue 8642
  • Loading branch information
leunge authored Jan 7, 2025
2 parents a5e27b0 + 8c2436e commit a82ce6d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions extern/util/static.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ EntryStatic.getAllBlocks = function () {
'repeat_inf',
'repeat_while_true',
'stop_repeat',
'continue_repeat',
'_if',
'if_else',
'wait_until_true',
Expand Down
24 changes: 24 additions & 0 deletions src/playground/blocks/block_flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,30 @@ module.exports = {
},
syntax: { js: [], py: ['break'] },
},
continue_repeat: {
color: EntryStatic.colorSet.block.default.FLOW,
outerLine: EntryStatic.colorSet.block.darken.FLOW,
skeleton: 'basic',
statements: [],
params: [
{
type: 'Indicator',
img: 'block_icon/flow_icon.svg',
size: 11,
},
],
events: {},
def: {
params: [null],
type: 'continue_repeat',
},
class: 'repeat',
isNotFor: [],
func(sprite, script) {
return this.executor.continueLoop();
},
syntax: { js: [], py: ['continue'] },
},
_if: {
color: EntryStatic.colorSet.block.default.FLOW,
outerLine: EntryStatic.colorSet.block.darken.FLOW,
Expand Down
14 changes: 14 additions & 0 deletions src/playground/executors.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,20 @@ class Executor {
return Entry.STATIC.PASS;
}

continueLoop() {
if (this._callStack.length) {
this.scope = this._callStack.pop();
}
while (this._callStack.length) {
const schema = Entry.block[this.scope.block.type];
if (schema.class === 'repeat') {
continue;
}
this.scope = this._callStack.pop();
}
return Entry.STATIC.CONTINUE;
}

end() {
Entry.dispatchEvent('blockExecuteEnd', this.scope.block && this.scope.block.view);
this.scope.block = null;
Expand Down

0 comments on commit a82ce6d

Please sign in to comment.