tosh help / blocks

You should be familiar with the all the blocks from Scratch, but here's a complete list of examples just in case. Have a look at the full guide for more about syntax.

If a block has lots of menu options, more than one example may be given.

Motion

top ↑

move 10 steps
turn cw 15 degrees
turn ccw 15 degrees

point in direction 90
point towards mouse-pointer
point towards "Sprite1"

go to x: 0 y: 0
go to mouse-pointer
glide 1 secs to x: 0 y: 0

change x by 10
set x to 0
change y by 10
set y to 0

if on edge, bounce

set rotation style left-right
set rotation style don't rotate
set rotation style all around

  (x position)
  (y position)
  (direction)

Looks

top ↑

say "Hello!" for 2 secs
say "Hello!"
think "Hmm..." for 2 secs
think "Hmm..."

show
hide

switch costume to "costume2"
next costume
switch backdrop to "backdrop1"
switch backdrop to "backdrop1" and wait         // [Stage only]
next backdrop                                   // [Stage only]

change color effect by 25
set color effect to 0
clear graphic effects

change size by 10
set size to 100%

go to front
go back 1 layers

  (costume #)
  (backdrop name)
  (size)
  (backdrop #)                                    // [Stage only]

Sound

top ↑

play sound "pop"
play sound "pop" until done
stop all sounds

play drum 1 for 0.2 beats
rest for 0.2 beats

play note 60 for 0.5 beats
set instrument to 1

change volume by 10
set volume to 100%
  (volume)

change tempo by 20
set tempo to 60 bpm
  (tempo)

Pen

top ↑

clear

stamp

pen down
pen up

set pen color to #ff00ff
change pen color by 10
set pen color to 0

change pen shade by 10
set pen shade to 50

change pen size by 1
set pen size to 1

Data

top ↑

set score to "0"
change score by 1
show variable score
hide variable score

  (score)
add "thing" to groceries
delete 1 of groceries
insert "thing" at 1 of groceries
replace item 1 of groceries with "thing"

  (item 1 of groceries)
  (length of groceries)
  <groceries contains "thing"?>

show list groceries
hide list groceries

  (groceries)

Events

top ↑

when flag clicked
when space key pressed
when this sprite clicked
when backdrop switches to "backdrop1"

when loudness > 10

when I receive "message1"
broadcast "message1"
broadcast "message1" and wait

Control

top ↑

wait 1 secs

repeat 10
	...
end

forever
	...
end

if <> then
	...
end

if <> then
	...
else
	...
end

wait until <>

repeat until <>
	...
end

stop all
stop this script
stop other scripts in sprite
stop other scripts in stage						// [Stage only]

when I start as a clone
create clone of myself
create clone of "Sprite1"
delete this clone

Sensing

top ↑

  <touching mouse-pointer?>
  <touching edge?>
  <touching "Sprite1"?>
  <touching color #ff00ff?>
  <color #ff00ff is touching #00ff00?>
  (distance to mouse-pointer)
  (distance to "Sprite1")

ask "What's your name?" and wait
  (answer)

  <key space pressed?>
  <mouse down?>
  (mouse x)
  (mouse y)

  (loudness)

  (video motion on Stage)
  (video direction on this sprite)
turn video off
turn video on
turn video on-flipped
set video transparency to 50%

  (timer)
reset timer

  (x position of "Sprite2")
  (y position of "Sprite2")
  (direction of "Sprite2")
  (costume # of "Sprite2")
  (costume name of "Sprite2")
  (size of "Sprite2")
  (volume of "Sprite2")
  (backdrop # of Stage)
  (backdrop name of Stage)
  (volume of Stage)

  (current year)
  (current month)
  (current date)
  (current day of week)
  (current hour)
  (current minute)
  (current second)
  (days since 2000)
  (username)

Operators

top ↑

  (2 + 2)
  (2 - 2)
  (2 * 2)
  (2 / 2)

  (pick random 1 to 10)

  <_ < _>
  <_ = _>
  <_ > _>

  <<> and <>>
  <<> or <>>
  <not <>>

  (join "hello " "world")
  (join (x position) (y position))
  (letter 1 of "world")
  (length of "world")

  (10 mod 3)
  (round 3.14)

  (sqrt of 9)
  (abs of 9)
  (floor of 9)
  (ceiling of 9)
  (sin of 9)
  (cos of 9)
  (tan of 9)
  (asin of 9)
  (acos of 9)
  (atan of 9)
  (ln of 9)
  (log of 9)
  (e ^ of 9)
  (10 ^ of 9)

Custom

top ↑

define dance (number) [string] <boolean>
...

dance 42 "Hello world!" 0=1