Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better Math #136

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/lib/extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
];
90 changes: 90 additions & 0 deletions static/extensions/bruh-9000/betterMath.js
Original file line number Diff line number Diff line change
@@ -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());
Binary file added static/images/bruh-9000/betterMath.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions static/images/bruh-9000/temp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@