Skip to content

Syntax ‐ How to Write in ScratchText

B1j2754 edited this page Dec 15, 2024 · 3 revisions

Guide to writing in ScratchText

Table of Contents

  1. Hat Blocks
  2. Stack Blocks
  3. C Blocks
  4. Cap Blocks
  5. Reporter Blocks
  6. Values
  7. Internal Blocks

Hat Blocks

Hat blocks are blocks that start a stack, and generally are what are used to create code. These blocks contain other blocks below them, creating stacks.
These blocks are used as such:

Hat_name (arguments if any) {
    ...
}

Stack Blocks

Stack blocks are what make up the bulk of projects. These are equivalent to what other programming languages call "commands" or "functions". They take (sometimes) arguments in, and do something with them.
These blocks are used as such:

stack_block_name(arguments if any)

C Blocks

Generic C blocks:

C blocks are blocks that contain other blocks inside of them for some processing. C blocks include "if" "forever" and "for" blocks, among many others. They allow you to put blocks inside others, similar to any other programming language.
These blocks are used as such:

c_name (arguments if any) {
    ...
}

If-else Blocks

A subset of C blocks, if else blocks are a little special, having 2 ways to write them in ScratchText.

1st way

if(condition) {
    ...
} else {
    ...
}

2nd way

if(condition) {
    ...
}
else {
    ...
}

Cap Blocks

Cap blocks are blocks that end a stack off. No blocks can be added underneath them, as they end it. These blocks look similar to stack blocks, and include blocks such as "stop("all scripts")", "deleteClone" and a few others.
These blocks are used as such:

cap_block(arguments if any)

Reporter Blocks

Reporter blocks are blocks that return values, or get values, and can be used as arguments in any block that accepts arguments. For instance, "mouse()" gets the value of the mouse [whether or not it is being currently clicked] and can be used to detect mouse down.
These blocks can be used inside the "input" arguments for any block containing them. They are used as such:

Reporter inside C block

c_name (reporter_name(arguments if any)) {
    ...
}

Reporter inside hat block

hat_name (reporter_name(arguments if any)) {
    ...
}

Reporter inside stack block

stack_block_name (reporter_name(arguments if any))

Values

Values are either a string or number, (both processed the same in Scratch), and are usually used similarly to reporter blocks.

Internal Blocks

Internal blocks are a block that the program uses internally, and should not be used when writing code. For most purposes, it is safe to ignore these blocks. For those who understand the SB3 json file format on a very deep level, there is potential to make hacked blocks with them.