Skip to content

Commit

Permalink
true-fantom/math: add x < y < z blocks (#1430)
Browse files Browse the repository at this point in the history
Co-authored-by: Muffin <[email protected]>
  • Loading branch information
MaelkMark and GarboMuffin authored May 9, 2024
1 parent cc9f503 commit 02578ec
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions extensions/true-fantom/math.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,47 @@
extensions: ["colours_operators"],
},
"---",
{
opcode: "between_or_equal",
blockType: Scratch.BlockType.BOOLEAN,
text: "[A] ≤ [B] ≤ [C]",
arguments: {
A: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "0",
},
B: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "50",
},
C: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "100",
},
},
extensions: ["colours_operators"],
},
{
opcode: "between",
blockType: Scratch.BlockType.BOOLEAN,
text: "[A] < [B] < [C]",
arguments: {
A: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "0",
},
B: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "50",
},
C: {
type: Scratch.ArgumentType.NUMBER,
defaultValue: "100",
},
},
extensions: ["colours_operators"],
},
"---",
{
opcode: "nand_block",
blockType: Scratch.BlockType.BOOLEAN,
Expand Down Expand Up @@ -569,6 +610,12 @@
xnor_block({ A, B }) {
return cast.toBoolean(A) === cast.toBoolean(B);
}
between_or_equal({ A, B, C }) {
return cast.compare(A, B) <= 0 && cast.compare(B, C) <= 0;
}
between({ A, B, C }) {
return cast.compare(A, B) < 0 && cast.compare(B, C) < 0;
}
exactly_cont_block({ A, B }) {
return cast.toString(A).includes(cast.toString(B));
}
Expand Down

0 comments on commit 02578ec

Please sign in to comment.