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

Create CommentPlus.js #1200

Closed
wants to merge 17 commits into from
372 changes: 372 additions & 0 deletions extensions/MYTAditya/CommentPlus.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,372 @@
// Name: Comment Plus
// ID: mytacomments
// Description: More Comment Blocks.
// By: Mastered YT Aditya <https://mastered-yt-aditya.github.io/>
// Original: LilyMakesThings <https://scratch.mit.edu/users/LilyMakesThings/>

(function (Scratch) {
"use strict";

class CommentPlus {
getInfo() {
return {
id: "mytacomments",
name: "Comment Plus",
color1: "#a9e43a",
color2: "#84b02b",
color3: "#567419",
blocks: [
{
opcode: "commentHat",
blockType: Scratch.BlockType.HAT,
text: "// [COMMENT]",
isEdgeActivated: false,
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
},
},
{
opcode: "commentCommand",
blockType: Scratch.BlockType.COMMAND,
text: "// [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
},
},
{
opcode: "commentC",
blockType: Scratch.BlockType.CONDITIONAL,
text: "// [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
},
},
{
opcode: "commentReporter",
blockType: Scratch.BlockType.REPORTER,
text: "[INPUT] // [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
INPUT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "",
},
},
},
{
opcode: "commentBoolean",
blockType: Scratch.BlockType.BOOLEAN,
text: "[INPUT] // [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
INPUT: {
type: Scratch.ArgumentType.BOOLEAN,
},
},
},
{
opcode: "commentReporterPPP",
blockType: Scratch.BlockType.REPORTER,
text: "// [COMMENT] [INPUT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
INPUT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "",
},
},
},
{
opcode: "commentBooleanPPP",
blockType: Scratch.BlockType.BOOLEAN,
text: "// [COMMENT] [INPUT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
INPUT: {
type: Scratch.ArgumentType.BOOLEAN,
},
},
},
{
opcode: "commentReporterPPPP",
blockType: Scratch.BlockType.REPORTER,
text: "// [COMMENT] [INPUT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
INPUT: {
type: Scratch.ArgumentType.BOOLEAN,
},
},
},
{
opcode: "commentBooleanPPPP",
blockType: Scratch.BlockType.BOOLEAN,
text: "// [COMMENT] [INPUT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
INPUT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "",
},
},
},
{
opcode: "commentBooleanPlus",
blockType: Scratch.BlockType.BOOLEAN,
text: "// [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment"
},
},
},
{
opcode: "commentReporterPlus",
blockType: Scratch.BlockType.REPORTER,
text: "// [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment"
},
},
},
{
opcode: "commentCap",
blockType: Scratch.BlockType.COMMAND,
isTerminal: true,
text: "// [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment"
},
},
},
{
opcode: "commentCPlus",
blockType: Scratch.BlockType.CONDITIONAL,
isTerminal: true,
text: "// [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
},
},
{
opcode: "commentReporterPlusPlus",
blockType: Scratch.BlockType.REPORTER,
text: "[INPUT] // [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
INPUT: {
type: Scratch.ArgumentType.BOOLEAN,
},
},
},
{
opcode: "commentBooleanPlusPlus",
blockType: Scratch.BlockType.BOOLEAN,
text: "[INPUT] // [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
INPUT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "",
},
},
},
{
opcode: "commentReporterP6",
blockType: Scratch.BlockType.REPORTER,
text: "[COLOR] // [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
COLOR: {
type: Scratch.ArgumentType.COLOR,
defaultValue: "#037b03",
},
},
},
{
opcode: "commentBooleanP6",
blockType: Scratch.BlockType.BOOLEAN,
text: "[COLOR] // [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
COLOR: {
type: Scratch.ArgumentType.COLOR,
defaultValue: "#037b03",
},
},
},
{
opcode: "commentReporterP7",
blockType: Scratch.BlockType.REPORTER,
text: "// [COMMENT] [COLOR]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
COLOR: {
type: Scratch.ArgumentType.COLOR,
defaultValue: "#037b03",
},
},
},
{
opcode: "commentBooleanP7",
blockType: Scratch.BlockType.BOOLEAN,
text: "// [COMMENT] [COLOR]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
COLOR: {
type: Scratch.ArgumentType.COLOR,
defaultValue: "#037b03",
},
},
},
{
opcode: "commentCPlusPlus",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you specify what the point of a double-branch comment block is? As stated previously, the second branch doesn't even run because of how you return the function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that block is just pointless, but I created that for the blocks put in first branch would work (like previous ones) and next branch wouldn't work. If you can, please write and comment me the code where both branches would work in the same block.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not going to write this extension for you as a block like that shouldn't exist to begin with

blockType: Scratch.BlockType.CONDITIONAL,
branchCount: 2,
text: "// [COMMENT]",
arguments: {
COMMENT: {
type: Scratch.ArgumentType.STRING,
defaultValue: "comment",
},
},
},
],
};
}

commentHat() {
// no-op
}

commentCommand() {
// no-op
}

commentC(args, util) {
return true;
}

commentReporter(args) {
return args.INPUT;
}

commentBoolean(args) {
return args.INPUT || false;
}

commentReporterPPP(args) {
return args.INPUT;
}

commentBooleanPPP(args) {
return args.INPUT || false;
}

commentReporterPPPP(args) {
return args.INPUT || false;
}

commentBooleanPPPP(args) {
return args.INPUT;
}

commentBooleanPlus(args) {
MYTAditya marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't mark issues as resolved unless they are actually resolved. This still does not return anything. That is a bug. Please fix it

// no-op
}

commentReporterPlus(args) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still doesn't return anything; reporters cannot return nothing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't mark issues as resolved unless they are actually resolved. This still does not return anything. That is a bug. Please fix it

// no-op
}

commentCap() {
MYTAditya marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove your unused functions

// no-op
}

commentCPlus(args, util) {
return true;
}

commentReporterPlusPlus(args) {
return args.INPUT || false;
MYTAditya marked this conversation as resolved.
Show resolved Hide resolved
}

commentBooleanPlusPlus(args) {
return args.INPUT;
}

commentReporterP6(args) {
return args.COLOR;
}

commentBooleanP6(args) {
return args.COLOR;
}

commentReporterP7(args) {
return args.COLOR;
}

commentBooleanP7(args) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand where or why you'd need a color input inside of a boolean.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right because reporters could do that. You can say, I just created it for Boolean shaped block. If you say, I would remove Booleans which had colors strings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In an ideal world you'd just remove all of the color blocks

return args.COLOR;
}

commentCPlusPlus(args, util) {
return true;
MYTAditya marked this conversation as resolved.
Show resolved Hide resolved
}
}
Scratch.extensions.register(new CommentPlus());
})(Scratch);
Binary file added images/MYTAditya/CommentPlus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading