<ScratchLang()>Docs

About

ScratchLang is a non-visual programming language written in Python and Shell based on Scratch. You can contribute on the Github Repository.

Documentation

Setup

Windows & Linux Setup

If you are a Windows user, install MSYS2.

Install Dependencies (list below)

Clone the repo:

git clone https://github.com/ScratchLang/ScratchLang.git
cd ScratchLang/mainscripts

Start the project with

python3 scratchlang.py

If you have a ScratchLang command, start the project with

scratchlang

If you want to test out the decompiler, run python3 scratchlang.py -4 and select the .sb3 every-block-+-pen.sb3 which is in the resources folder. You get to see it decompile all the blocks added so far.

To code, edit the .ss(es) in ScratchLang's editor, which you can run with

python3 editor.py path/to/project_folder


To add assets, put them in the assets folder for the chosen sprite (or stage)

You don't need ScratchLang to program ScratchScript (.ss) files, you can use a text editor. You just need ScratchLang to compile your project so it can run in Scratch.

To check the stable blocks, just decompile the every-block-+-pen.sb3 which is in the resources folder. You will get an unknown block error for blocks that the decompiler can't read yet. Every other block is most likely a stable block

Mac & Chrome OS

Mac and Chrome OS can run ScratchLang. Just find a way to install Python onto it. (For Chrome OS, you're going to have to enable the developer linux terminal.)

Code Reference

Data


set [var] to ("string")

Assign something to a variable.



change [var] by ("num")

Add "num" to a variable.



show variable [var]

Show a variable.



hide variable [var]

Hide a variable.



add ("thing") to [list]

Add an item to a list.



delete ("num") of [list]

Remove item "num" from a list.



delete all of [list]

Delete all items from a list.



insert ("thing") at ("num") of [list]

Insert an item into index "num" of a list.



replace item ("num") of [list] with ("thing")

Replace element "num" of a list with something else.



(item ("num") of [list])

Returns item "num" from a list.



(item # of ("thing") of [list])

Returns the index of an item from a list.



(length of [list])

Returns the amount of elements in a list.



<[list] contains ("thing")?>

Returns true if a list contains an item, else false.



show list [list]

Show a list on the stage



hide list [list]

Hide a list on the stage



Control Scripts

wait ("num") seconds

Waits "num" seconds.



repeat("num"){

}

Repeats the code inside the curly braces "num" times.



forever{

}

Executes everything inside the braces forever.



if <INPUT> {

}

Runs code inside the braces if <INPUT> is true.



if <INPUT> {

} else {

}

Runs code inside the braces if <INPUT> is true, and runs the code under the else braces if <INPUT> is false.



wait until <INPUT>

Waits until <INPUT> is true.



repeat until <INPUT> {

}

Repeats the loop until <INPUT> is true.



while <INPUT> {

}

Repeats the loop until <INPUT> is NOT true.



for each [var] in ("num") {

}

Repeats "num" times while also increasing the variable.



stop [all]

Stops something depending on the value in the brackets. "all" can be replaced with "this script" or "other scripts in sprite".



when I start as a clone

Script runs when sprite is cloned.



create a clone of ("sprite")

Create a clone of "sprite".



delete this clone

Delete the clone.



How to Add More Blocks

This section probably won't be written soon.

Credits

The repository is owned, maintained, and programmed by 0K9090 and other contributors.

This site is developed and maintained by Stan-Solov and 0K9090.

None of this would be possible without the amazing people at MIT, who created the Scratch programming site.

ScratchLang is developed by the ScratchLang Organization under the MIT license.