(Redirected from Comment (block))

This article is about the comment attachable to a script. For the kind of comment seen below projects, in the "Comments" section of studios, and on profiles, see Comment (website feature).
The current type of comment in 3.0.

Comments in the Scratch program are adjustable textboxes that can be attached to blocks, or left floating. The comment boxes can be adjusted both horizontally and vertically, dragged around the Code Area, minimized, and deleted. They are used to provide information about a script, a sprite, to credit someone for their work and more.

History

Archive.png This article or section documents something not included in the current version of Scratch (3.0). It is only useful from a historical perspective.
The old comment block from the Scratch 1.2 beta.

The Scratch 1.2 beta introduced a comment block as a Control block that could be placed inside a script as one of its blocks. This grey block could have text entered like a normal comment but was a block instead of the side-attached comments seen today, and still featured mini-comment and full-comment modes. It made no change to the script, as it only held text — however, newer users grew confused about it, causing it to be removed in the official Scratch 1.2 release.

The offline player will treat the comment block as an obsolete block, and as such, stop the script that contains the comment. This can be a problem for old projects that contain the comment block. While users who were active around the time of removal would have removed it, those who did not would see issues with the project.

Both the Scratch Team and the Scratch community wanted the ability to add comments to scripts in order to improve their readability. Scratch 1.3 introduced the modern comments that are still used today. Since Scratch 1.4, comments can be stuck to a block so that comments remain attached when a script is dragged around. The font used with the comment block, also used in drop-down menus, was changed to Verdana with Scratch 1.3.

A comment in Scratch 2.0
The comment from the Scratch 3.0 public beta.

Scratch 3.0 has changed the appearance of comments. Comments still act the same as it did in Scratch 2.0, and the creation of comments is still the same as it was in Scratch 2.0. Scratch 2.0 projects loaded in Scratch 3.0 will automatically switch to using the Scratch 3.0 comment.

Adding Comments

The right click menu for a block.

To add a comment to a block, a Scratcher can right-click it, and in the drop-down menu choose "Add Comment". This will add a yellow box in where they can type their comment. Comments can be added anywhere in the Code Area the same way.

Use

A main use for comments is to explain how a script is working. An example is below:

when flag clicked
switch costume to (costume1 v)//Preparing the project...
set [variable v] to [0]
go to x: (0) y: (0)
forever
if <touching color [#372080]?> then//Gameplay.
change [variable v] by (1)
end
if <touching color [#00bb03]?> then
change [variable v] by (-1)
end
end
Note Note: The comments are attached to the blocks with a line a pixel thick, which may be hard to see on this wiki or anywhere else with a white background.

Another purpose of the comment feature is to provide some hidden info the user wishes to not share in the Notes and Credits.[1]

Shapes

The two comment types. The top one is a mini comment and the bottom one is a full comment.

Comments can be shaped in two ways — a full comment or a mini comment. The type can be changed by clicking the gray triangle at the upper-left of a comment.

In 2.0 and later versions, comments are created by right-clicking. If one right-clicks on a block, the comment will be connected by a 1 pixel thick line to that block. If they right-click on the code area, the comment will not be connected to anything. One can edit a comment by clicking on it and delete it using the delete button on the top right.

Mini comments are one line long and hold the amount of characters that will fit on one width of the comment. Change from Mini to Full by clicking the triangle at the top left of the comment. Full comments display all text entered into it, which can extend infinitely.

The width and height of comments can be altered by clicking (the parallel lines at) the bottom right-hand corner of the comment and dragging to the desired size. This can also be extended infinitely and is particularly useful if the mini comment is too narrow to display a sufficient amount of characters.

Blocks Plugin

To use comments in the blocks plugin, simply add add two slashes (//) after the block to be commented, and add the annotation after that. This syntax is derived from comments in most high-level languages. Comments in the Block Plugin look like:

move (10) steps // This is a comment attached to a block.
move (10) steps // This is a comment attached to a block.
//This is a stray comment.
//This is a stray comment.

References

Cookies help us deliver our services. By using our services, you agree to our use of cookies.