Skip to content

Commit f9a5371

Browse files
true-fantom/math: Add "sign" block (#1981)
continuation of #1980, everything from there applies except: - ctrl + f replace every time I said "normalize" with "sign of" - block code was changed a bit because apparently there's a math function to get sign (how am i just now learning of this) ![chrome_uiOoLW48ex](https://github.com/user-attachments/assets/b880379d-8a5d-4848-b84f-69948ee2500a) --------- Co-authored-by: DangoCat[bot] <[email protected]>
1 parent 18df62f commit f9a5371

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

extensions/true-fantom/math.js

+15
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,18 @@
384384
extensions: ["colours_operators"],
385385
},
386386
"---",
387+
{
388+
opcode: "sign_of",
389+
blockType: Scratch.BlockType.REPORTER,
390+
text: Scratch.translate("sign of [A]"),
391+
arguments: {
392+
A: {
393+
type: Scratch.ArgumentType.NUMBER,
394+
defaultValue: 0.1,
395+
},
396+
},
397+
extensions: ["colours_operators"],
398+
},
387399
{
388400
opcode: "clamp_block",
389401
blockType: Scratch.BlockType.REPORTER,
@@ -646,6 +658,9 @@
646658
exactly_cont_block({ A, B }) {
647659
return cast.toString(A).includes(cast.toString(B));
648660
}
661+
sign_of({ A }) {
662+
return Math.sign(cast.toNumber(A));
663+
}
649664
clamp_block({ A, B, C }) {
650665
if (cast.compare(A, B) < 0) {
651666
return B;

0 commit comments

Comments
 (0)