From 02578ecd799842ef2927d66c63a3760328987de5 Mon Sep 17 00:00:00 2001 From: MaelkMark <110915409+MaelkMark@users.noreply.github.com> Date: Fri, 10 May 2024 01:35:30 +0200 Subject: [PATCH] true-fantom/math: add x < y < z blocks (#1430) Co-authored-by: Muffin --- extensions/true-fantom/math.js | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/extensions/true-fantom/math.js b/extensions/true-fantom/math.js index e516b265ab..569ba24301 100644 --- a/extensions/true-fantom/math.js +++ b/extensions/true-fantom/math.js @@ -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, @@ -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)); }