Package: scratch-python
PyScratchA framework for creating scratch blocks and projects with python.Explore the docs »Scratch Home Page·Report Bug·Request FeatureTable of ContentsAbout The ProjectBuilt WithGetting StartedPrerequisitesInstallationUsageRoadmapContributingLicenseContactAcknowledgmentsAbout The ProjectBuilt WithPythonLark(back to top)Getting StartedPyScratch is easy to get up and running!Installation with Pippippipinstallscratch-pythonCopy the latest build environment fromreleasesand unzip.Navigate to the build environmentcdProjectInstallation from SourceClone the Repogitclonehttps://github.com/IfanSnek/PyScratch.gitNavigate to the installation directorycdPyScratchInstall the packagepythonsetup.pyinstall(back to top)UsageHere is basic usage for the ScratchText language.// Currently, there is only support for single line comments

// Import the other file
include module.st

// USe a function from the other file
back walk (10) steps

// Start a new stack
when green flag pressed

// Variables can be set like this. Note that any parameter must be surrounded by parenthesis.
set (health) to (10)

// Blocks are typed as they are seen in Scratch
move (10) steps // Just remember to use parentheses for values.

// You can also put variable randomly. They will start at 0.
move (health) steps

// You can even call an undefined variable and it will start at 0
move (my variable) steps // Note that the parser ignores spaces, so the variable will become 'myvariable'

// Loops are made with brackets
repeat (2) {
    // Indentation is not required but it is good for visibility.
    turn right (-5) degrees
}

// If-else statement use two sets of brackets
if ((2) equals (2)) then {
    turn right (1) degrees
} else {
    turn left (1) degrees
}

// Loops can be stacked infinitely
repeat(2) {
    repeat(2) {
        repeat(2) {
            turn right (4) degrees
        }
    }
}

// So can operators
turn left (add (add (add (add (add (add (1) and (1)) and (1)) and (1)) and (1)) and (1)) and (1)) degrees

// Custom functions can be created with the 'def' keyword.
def do (this) thing { // DO NOT USE PARAMETERS THAT ARE GLOBAL VARIABLES.
    // Indentation is not required but it is good for visibility.
    turn right (this) degrees
}

// The function can then be called like this
do (2) thing

// Dropdown blocks need to have their value explicitly stated
stop ("all")  // Strings still need parenthesis.Write this intoscript.stand run:scratchtextscript.stYou can now openScratch, Go toFile > Load from your computerand
chose the generatedProject.sb3.For more examples, please refer to theDocumentation(back to top)RoadmapCreate a block-generating framework.Create a basic scripting language.Add a Pip package.Add function and script importing support.Make operators easier to type (ega = 10instead ofset (a) to (10)).Add the rest of the Scratch blocks.Instant Scratch GUI project loading.PotentialScratchBlocksintegration.See theopen issuesfor a full list of proposed features (and known
issues).(back to top)ContributingContributions are what make the open source community such an amazing place to learn, inspire, and create. Any
contributions you make aregreatly appreciated.If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also
simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!Fork the ProjectCreate your Feature Branch (git checkout -b feature/AmazingFeature)Commit your Changes (git commit -m 'Add some AmazingFeature')Push to the Branch (git push origin feature/AmazingFeature)Open a Pull Request(back to top)LicenseDistributed under the MIT License. SeeLICENSE.txtfor more information.(back to top)ContactEthan Porcaro -ethan@ethanporcaro.comProject Link:https://github.com/IfanSnek/PyScratch/(back to top)AcknowledgmentsScratch Wikifor useful information on the .sb3 format.(back to top)