diff --git a/src/lib/extensions.js b/src/lib/extensions.js index ec4ca0ea..02a16677 100644 --- a/src/lib/extensions.js +++ b/src/lib/extensions.js @@ -295,5 +295,13 @@ export default [ banner: "mariocraft987/randomlyBlocksBanner.svg", creator: "mariocraft987", isGithub: true, + }, + { + name: "Better Math", + description: "Add more math evaluators.", + code: "bruh-9000/betterMath.js", + banner: "bruh-9000/betterMath.png", + creator: "bruh-9000", + isGithub: true, } ]; diff --git a/static/extensions/bruh-9000/betterMath.js b/static/extensions/bruh-9000/betterMath.js new file mode 100644 index 00000000..29ba04a1 --- /dev/null +++ b/static/extensions/bruh-9000/betterMath.js @@ -0,0 +1,90 @@ +class BetterMath { + getInfo() { + return { + id: 'bettermath', + name: 'Better Math', + blocks: [ + { + opcode: 'degreeToRadian', + blockType: Scratch.BlockType.REPORTER, + text: 'convert [degree] to a radian', + arguments: { + degree: { + type: Scratch.ArgumentType.NUMBER + } + } + }, + { + opcode: 'radianToDegree', + blockType: Scratch.BlockType.REPORTER, + text: 'convert [radian] to a degree', + arguments: { + radian: { + type: Scratch.ArgumentType.NUMBER + } + } + }, + { + opcode: 'signOfNumber', + blockType: Scratch.BlockType.REPORTER, + text: 'sign of [number]', + arguments: { + number: { + type: Scratch.ArgumentType.NUMBER + } + } + }, + { + opcode: 'maximum', + blockType: Scratch.BlockType.REPORTER, + text: '[num1] maximum [num2]', + arguments: { + num1: { + type: Scratch.ArgumentType.NUMBER + }, + num2: { + type: Scratch.ArgumentType.NUMBER + } + } + }, + { + opcode: 'minimum', + blockType: Scratch.BlockType.REPORTER, + text: '[num1] minimum [num2]', + arguments: { + num1: { + type: Scratch.ArgumentType.NUMBER + }, + num2: { + type: Scratch.ArgumentType.NUMBER + } + } + } + ] + }; + } + + degreeToRadian(args) { + return args.degree*0.01745329251; + } + radianToDegree(args) { + return args.radian*57.2957795131; + } + signOfNumber(args) { + if (args.number > 0) { + return 1; + } else if (args.number < 0) { + return -1; + } else { + return 0; + } + } + maximum(args) { + return args.num1 > args.num2 ? args.num1 : args.num2; + } + minimum(args) { + return args.num1 < args.num2 ? args.num1 : args.num2; + } +} + +Scratch.extensions.register(new BetterMath()); \ No newline at end of file diff --git a/static/images/bruh-9000/betterMath.png b/static/images/bruh-9000/betterMath.png new file mode 100644 index 00000000..a13c608c Binary files /dev/null and b/static/images/bruh-9000/betterMath.png differ diff --git a/static/images/bruh-9000/temp.md b/static/images/bruh-9000/temp.md new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/static/images/bruh-9000/temp.md @@ -0,0 +1 @@ +