Discuss Scratch

LogicQ_Dev2
Scratcher
23 posts

Scratch Python Projects & Docs

Hey! This thread is for projects made in Scratch Python and also a short doc on it's functions and bugs.

Syntax + Functions

The majority of the syntaxes follow that of Python. Each of the following functions requires an input arg(), even if it will be empty. Functions cannot be used within other functions, (e.g. print(len(“example”)) ). Functions marked with * require modules that can be imported through import module_name. The current modules are: turtle, sound

Functions that support concatenation: (concatenation with integers or integer variables will perform a math operation)

print(“example” + example) - display's a message to output.
input(4 + 6) - asks the user the input, if a variable is not defined, it will store to the answer variable.

Functions that support inputs: (all of the following inputs support strings, integers, and variables)

len(“example”) - outputs the length of an input
rand(x, y) - outputs a random number from x to y
pow(x, y) - outputs x^y
show() and hide() - hides or shows the sprite

*goto(x, y) - sends turtle to that relative position
*setx(x) and *sety(y) - sets the turtles x or y position
*penup() - brings pen up
*pendown() - brings pen down
*clear() - erases the board
*pensize(x) - sets the pen size

*playsound(“example”) - plays a sound from the sys sprite (current available sounds are: beep, win, error)
*volume(x) - sets the volume (1-100)

Variables:

When the program is compiled, all previous variables are erased*, and only excepts ones that are defined prior to its reading.
Because the program is interpretive, it will only know variables that have already been defined.

* Default variables include: answer, username, pi, mousex, mousey, xpos, and ypos. The position variables are updated every .5 seconds and provide the positioning relative to the pen area.

A variable can be defined through:

var = “example”, var = example, var = 123

The first example, shows a string variable (defined by quotations on either side), special characters can be used in strings (e.g. math operations and parentheses), but will be ignored by the program.

The second example shows a variable is being set to another variable, named example. Do not use function names as variable names. (e.g. print = “don't do this”)

The final example shows a variable being set to an integer value. Using math operations will work while setting variables (e.g. var = 4 * 4). Keep in mind, when setting variables to function outputs, do not use math operations simultaneously (e.g. var = 4 + rand(1,3) ).

If Statements:

If statements may not work properly 100% when using Scratch due to how heavy they currently are. You can run the project faster through a program like TurboWarp or Phosphorus.

Syntax of an if statement:

if answer = 10 + 5 [
print(“example”) ]

They are opened and closed through . Unlike the example, multiple lines can be put under an if statement. Else and elif statements have not been added yet.

Bugs & Notes:

The program is still being actively worked on, and was only started a few days ago, so there are still lots of bugs and glitches to be fixed. The most notable issue can be found in concatenation. If you are only using a single input in concatenation, use a + sign anyways. This is likely to have been patched by the time of your reading this, but should be kept in mind either way. (e.g. use print(“test” +) instead of print(“test”) ).

Please let me know what you think on this forum thread, possibly with more ideas, bug reports, and of course whatever cool projects you can come up with. Thanks for reading this through, keep on scratching!
LogicQ_Dev2
Scratcher
23 posts

Scratch Python Projects & Docs

I forgot to mention this in the post: all of the controls for managing the inputs and such can be found in the notes of the project, I will work on a better look for the project once it is useable.
nampinanathali
Scratcher
1000+ posts

Scratch Python Projects & Docs

Wow, really cool!

Powered by DjangoBB