Skip to content

Commit bef49fb

Browse files
committed
extendable and/or blocks
1 parent 4ef44f0 commit bef49fb

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/blocks/scratch3_operators.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class Scratch3OperatorsBlocks {
2929
operator_gt: this.gt,
3030
operator_and: this.and,
3131
operator_or: this.or,
32+
operator_and_extendable: this.andExtendable,
33+
operator_or_extendable: this.orExtendable,
3234
operator_not: this.not,
3335
operator_random: this.random,
3436
operator_join: this.join,
@@ -103,6 +105,16 @@ class Scratch3OperatorsBlocks {
103105
return Cast.toBoolean(args.OPERAND1) || Cast.toBoolean(args.OPERAND2);
104106
}
105107

108+
andExtendable (args, util) {
109+
const arr = util.extendableToArray(args, 'OPERANDS', 'OPERAND');
110+
return !arr.some(input => !Cast.toBoolean(input));
111+
}
112+
113+
orExtendable (args, util) {
114+
const arr = util.extendableToArray(args, 'OPERANDS', 'OPERAND');
115+
return arr.some(Cast.toBoolean);
116+
}
117+
106118
not (args) {
107119
return !Cast.toBoolean(args.OPERAND);
108120
}

src/compiler/compat-blocks.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ const inputs = [
3737
'motion_xscroll',
3838
'motion_yscroll',
3939
'operator_add_extendable',
40+
'operator_and_extendable',
4041
'operator_divide_extendable',
4142
'operator_join_extendable',
4243
'operator_multiply_extendable',
44+
'operator_or_extendable',
4345
'operator_subtract_extendable',
4446
'sensing_loud',
4547
'sensing_loudness',

0 commit comments

Comments
 (0)