FANDOM


This article is a list of block workarounds, which are scripts that recreate the effect of a block without using the block. They can be used to better understand how blocks work and to recreate a block in another programming language.

Event BlocksEdit

Block Workaround
<sb>when green flag clicked</sb> <scratchblocks>

when I receive [Scratch-StartClicked v] . . . </scratchblocks> Note: Only works offline in Scratch 1.x <scratchblocks> when [timer v] > (-1) // This is a block that can not be stopped if <<((mouse y) = [180]) and <mouse down?>> or <(clicked) = [0]>> then set [clicked v] to [1] . . . </scratchblocks>

<sb>when [space v] key pressed</sb> <scratchblocks>when [timer v] > (-1) // This is a block that can not be stopped, therefore you can make a workaround that does not require the green flag to be clicked

forever wait until <key [space v] pressed?> . . .</scratchblocks>

<sb>when this sprite clicked</sb> <scratchblocks>

when [timer v] > (-1) // This is a block that can not be stopped, therefore you can make a workaround that does not require the green flag to be clicked forever

 wait until <<touching [mouse-pointer v]?> and <mouse down?>> //This is not an exact workaround, because you could, first, while not touching the Sprite, hold down your mouse, then, still holding down your mouse, move it over to the sprite. This will not activate the true block but will activate this.
 . . .

</scratchblocks> or <scratchblocks> when [timer v] > (-1) // This is a block that can not be stopped, therefore you can make a workaround that does not require the green flag to be clicked forever if <<mouse down> and <not<touching [mouse pointer v]>>> then set [down? v] to [1] wait until <not<mouse down>> set [down? v] to [0] end end // This makes sure the script will not activate if you are holding down the mouse and then move it onto the sprite.

when [timer v] > (-1) // This is a block that can not be stopped, therefore you can make a workaround that does not require the green flag to be clicked forever if <<touching [mouse pointer v]> and <<mouse down> and <(down) = [0]>>> then . . . end </scratchblocks>

<sb>when [loudness v] > (10)</sb> <scratchblocks>

when gf clicked // You can not use the greater than block to work around the green flag, because the greater than block is the block you want to work around forever

 wait until <(loudness) > (10)>
 . . .

</scratchblocks>

<sb>broadcast [message v]</sb> <scratchblocks>

when gf clicked set [broadcasted? v] to [0] . . . set [broadcasted? v] to [1]

when gf clicked forever wait until <(broadcasted?) = [1]> . . . set [broadcasted? v] to [0] end </scratchblocks> or <scratchblocks> broadcast [broadcast v] and wait when I receive [broadcast v] . . . // whatever comes after the broadcast, in addition to the receive block you would have </scratchblocks>

<sb>broadcast [message v] and wait</sb> <scratchblocks>

when gf clicked set [broadcasted? v] to [0] set [wait v] to [0] . . . set [broadcasted? v] to [1] set [wait v] to [1] wait until <(wait) = [0]> . . .

when gf clicked forever wait until <(broadcasted?) = [1]> . . . set [broadcasted? v] to [0] set [wait v] to [0] end </scratchblocks> or <scratchblocks> set [wait v] to [3] // however many receive blocks you have for that particular broadcast broadcast [broadcast v] when I receive [broadcast v] . . . change [wait v] by (-1) // be sure to but this right before any "stop script" blocks, too! </scratchblocks>

Control BlocksEdit

Block Workaround
<sb>wait (1) secs</sb> <scratchblocks>

rest for (((tempo) / (60)) * (1)) beats </scratchblocks> or <scratchblocks> reset timer repeat until <not <(timer) < [1]>> // Put no blocks here. end // If you are using other scripts that involve the timer, this might mess them up</scratchblocks>

<sb>forever</sb> <scratchblocks>repeat until <> // Put no boolean in the block or put a boolean that will always equals false (1=2).

. . . end</scratchblocks> or <scratchblocks> when I receive [forever v] . . . broadcast [forever v] </scratchblocks> or <scratchblocks> repeat ([10^ v] of (309) . . . </scratchblocks>

<sb>repeat (10)</sb> <scratchblocks>

set [counter v] to [0] repeat until <(counter) = [10]> change [counter v] by (1) . . . end </scratchblocks> or <scratchblocks> define loop (n) if <(n) > [0]> then

 . . .
 loop ((n) - (1))

end

loop (10) </scratchblocks>

<sb>if <> then</sb> <scratchblocks>

if <. . .> then . . . else // Put no blocks here. end </scratchblocks>
or
<scratchblocks> when gf clicked forever wait until <. . .> . . . //That assumes a forever loop around the if </scratchblocks>

<sb>if <> then else </sb> <scratchblocks>

if <> then . . . end if <not <>> then . . . end </scratchblocks>
or
<scratchblocks> define if <boolean> if <boolean> then . . .//whatever would be in if stop [this script v] end when gf clicked . . . if <. . .> then . . .//whatever would be in else //that assumes the if/else is the last block </scratchblocks>

<sb>wait until <></sb> <scratchblocks>repeat until < . . . >

// Put no blocks here. end </scratchblocks>

<sb>stop [ v]</sb> this script:

<scratchblocks>wait until <> // Put no boolean in the block.</scratchblocks> or <scratchblocks>wait ([10^ v] of (309)) secs // Those do not actually *stop* the script, the blocks only start and don't end</scratchblocks> or <scratchblocks> forever //Put no blocks here. </scratchblocks> all: <scratchblocks>when I receive [stop all v] stop [other scripts in sprite v] // It must be put in every sprite and the Stage.</scratchblocks>

Motion BlocksEdit

Block Workaround
<sb>(direction)</sb> <scratchblocks>([direction v] of [wanted sprite v])</scratchblocks>
<sb>(x position)</sb> <scratchblocks>([x position v] of [wanted sprite v])</scratchblocks>
<sb>(y position)</sb> <scratchblocks>([y position v] of [wanted sprite v])</scratchblocks>
<sb>go to [wanted sprite v]</sb> <scratchblocks>go to x: (mouse x) y: (mouse y)</scratchblocks>

<scratchblocks>go to x: ([x position v] of [wanted sprite v]) y: ([y position v] of [wanted sprite v])</scratchblocks> <scratchblocks>set x to: ([x position v] of [wanted sprite v]) set y to: ([y position v] of [wanted sprite v]) </scratchblocks>

<sb>go to x: () y: ()</sb> <scratchblocks>set x to (x value)

set y to (y value)</scratchblocks> or <scratchblocks>glide (0) secs to x: () y: ()</scratchblocks>

<sb>point towards [ v]</sb> <scratchblocks>

set [delta_x v] to (([x position v] of [wanted sprite v]) - (x position)) set [delta_y v] to (([y position v] of [wanted sprite v]) - (y position)) if<(delta_y) = [0]> then if<(delta_x) < [0]> then point in direction (-90 v) else point in direction (90 v) end else if<(delta_y) < [0]> then point in direction ((180) + ([atan v] of ((delta_x) / (delta_y)))) else point in direction ([atan v] of ((delta_x) / (delta_y))) end end </scratchblocks>

<sb>point in direction (90 v)</sb> <scratchblocks>

turn cw ((90) - (direction)) degrees </scratchblocks> or <scratchblocks> turn ccw ((-1) * ((90) - (direction))) degrees </scratchblocks>

<sb>turn right (15) degrees</sb> <scratchblocks>

point in direction ((direction) + (15)) </scratchblocks>

<sb>turn left (15) degrees</sb> <scratchblocks>

point in direction ((direction) - (15)) </scratchblocks>

<sb>move (10) steps</sb> <scratchblocks>

go to x: ((x position) + (([sin v] of (direction)) * (10))) y: ((y position) + (([cos v] of (direction)) * (10))) </scratchblocks> or <scratchblocks> change x by (([sin v] of (direction)) * (10)) change y by (([cos v] of (direction)) * (10)) </scratchblocks>

<sb>change x by (10)</sb> <scratchblocks>set x to ((x position) + (10))</scratchblocks>
<sb>change y by (10)</sb> <scratchblocks>set y to ((y position) + (10))</scratchblocks>
<sb>set x to (0)</sb> <scratchblocks>change x by ((wanted x) - (x position))</scratchblocks>

<scratchblocks>change x by (((x position) * (-1)) + (wanted x))</scratchblocks> <scratchblocks>go to x: (wanted x) y: (y position)</scratchblocks>

<sb>set y to (0)</sb> <scratchblocks>change y by ((wanted y) - (y position))</scratchblocks>

<scratchblocks>change y by (((y position) * (-1)) + (wanted y))</scratchblocks> <scratchblocks>go to x: (x position) y: (wanted y)</scratchblocks>

Motor BlocksEdit

Block Workaround
<sb>turn motor on for (1) secs :: extension</sb> <scratchblocks>motor on :: extension

wait (number) secs motor off :: extension</scratchblocks>

<sb>motor off :: extension</sb> <scratchblocks>turn motor on for (0) secs :: extension</scratchblocks>

or <scratchblocks>set motor power (0) :: extension</scratchblocks>

Looks BlocksEdit

Block Workaround
<sb>switch costume to [ v]</sb>

<scratchblocks> repeat until <(wanted costume #) = (costume #)> next costume end </scratchblocks>

<sb>next costume</sb> <scratchblocks>switch costume to ((costume #) + (1))</scratchblocks>
<sb>switch backdrop to [ v]</sb>

<scratchblocks> repeat until <(wanted backdrop #) = (backdrop #)> next backdrop end </scratchblocks>

<sb>next backdrop</sb> <scratchblocks>switch backdrop to ((backdrop #) + (1))</scratchblocks>

or <scratchblocks>switch backdrop to [next backdrop v]</scratchblocks>

<sb>(costume #)</sb> <scratchblocks>([costume # v] of [wanted sprite v])</scratchblocks>
<sb>(backdrop #)</sb> <scratchblocks>([backdrop # v] of [Stage v])</scratchblocks>
<sb>(backdrop name)</sb> <scratchblocks>([backdrop name v] of [Stage v])</scratchblocks>
<sb>say [] for () secs</sb> <scratchblocks>

say (text) wait (amount) secs say [] </scratchblocks>

<sb>think [] for () secs</sb> <scratchblocks>

think (text) wait (amount) secs think [] </scratchblocks>

<sb>clear graphic effects</sb> <scratchblocks>

set [color v] effect to (0) set [fisheye v] effect to (0) set [whirl v] effect to (0) set [pixelate v] effect to (0) set [mosaic v] effect to (0) set [brightness v] effect to (0) set [ghost v] effect to (0) </scratchblocks>

<sb>(size)</sb> <scratchblocks>

([size v] of [wanted sprite v]) </scratchblocks>

<sb>change size by ()</sb> <scratchblocks>

set size to ((size) + (amount))% </scratchblocks>

<sb>set size to () %</sb> <scratchblocks>

change size by ((wanted size) - (size)) </scratchblocks>

<sb>go to front</sb> <scratchblocks>

go back ((-1) * ([10^ v] of (309))) layers </scratchblocks>

<sb>hide</sb> <scratchblocks>set [ghost v] effect to (100)</scratchblocks>

or

<scratchblocks>switch costume to [invisible costume v] </scratchblocks>

Sound BlocksEdit

Block Workaround
<sb>play sound [ v]</sb> <scratchblocks>

. . . broadcast [continue script v] play sound [wanted sound v] until done

when I receive [continue script v] . . . </scratchblocks>

<sb>play sound [ v] until done</sb> <scratchblocks>play sound [wanted sound v]

wait (length of sound) secs</scratchblocks>

<sb>rest for () beats</sb> <scratchblocks> wait (((60) / (tempo)) * (beats)) secs</scratchblocks>
<sb>change volume by ()</sb> <scratchblocks>set volume to ((volume) + (amount))%</scratchblocks>
<sb>set volume to () %</sb> <scratchblocks>change volume by ((amount) - (volume))</scratchblocks>
<sb>(volume)</sb> <scratchblocks>([volume v] of [wanted sprite v])</scratchblocks>
<sb>change tempo by ()</sb> <scratchblocks>set tempo to ((tempo) + (amount)) bpm</scratchblocks>
<sb>set tempo to () bpm</sb> <scratchblocks>change tempo by ((amount) - (tempo))</scratchblocks>

Operators BlocksEdit

Block Workaround
<sb>(() + ())</sb> <scratchblocks>((a) - ((b) * (-1)))</scratchblocks>

or <scratchblocks>((a) - ((0) - (b)))</scratchblocks> or <scratchblocks> set [answer v] to (a) change [answer v] by (b) </scratchblocks>

<sb>(() - ())</sb> <scratchblocks>((a) + ((b) * (-1)))</scratchblocks>

or <scratchblocks>((a) + ((b) / (-1)))</scratchblocks> or <scratchblocks>((a) + (join [-](b)))</scratchblocks> or <scratchblocks> set [answer v] to () change [answer v] by ((-1) * ()) </scratchblocks> The third workarounds only works with positive b; --3 for example is evaluated by Scratch to be 0.

<sb>(() * ())</sb>
<scratchblocks>delete (all v) of [num1 numbers v] //setup

delete (all v) of [num2 numbers v] delete (all v) of [product digits v] set [product v] to [0] set [dec pos 1 v] to [0] set [dec pos 2 v] to [0] if <(answer) < [0]> then set [count v] to [1] set [no 1 negative v] to [y] else set [count v] to [0] set [no 1 negative v] to [n] end repeat (length of ()) change [count v] by (1) if <not <(letter (count) of ()) = [.]>> then add (letter (count) of ()) to [num1 numbers v] else set [dec pos 1 v] to ((length of (answer)) - (count)) end end if <() < [0]> then set [count v] to [1] set [no 2 negative v] to [y] else set [count v] to [0] set [no 2 negative v] to [n] end repeat (length of ()) change [count v] by (1) if <not <(letter (count) of ()) = [.]>> then add (letter (count) of ()) to [num2 numbers v] else set [dec pos 2 v] to ((length of (answer)) - (count)) end end set [num1 v] to (num1 numbers) set [num2 v] to (num2 numbers) repeat (num1) //start change [product v] by (num2) end set [decimal position v] to ((dec pos 1) + (dec pos 2)) set [count v] to [0] repeat (length of (product)) change [count v] by (1) add (letter (count) of (product)) to [product digits v] end if <not <(decimal position) = [0]>> then insert [.] at ((length of [product digits v]) - ((decimal position) - (1))) of [product digits v] end if <<<(no 1 negative) = [y]> or <(no 2 negative) = [y]>> and <not <<(no 1 negative) = [y]> and <(no 2 negative) = [y]>>>> then insert [-] at (1 v) of [product digits v] end

set [product v] to (product digits)</scratchblocks>

or <scratchblocks>((a) / ((1) / (b))) // the product of "a" and "b" </scratchblocks> or <scratchblocks> if <(a) < [0]> then repeat ([abs v] of (a)) change [product v] by ((0) - (b)) end else set [product v] to [0] repeat (a) change [product v] by (b) end end </scratchblocks>

<sb>(() / ())</sb>
<scratchblocks>

delete (all v) of [dividend digits v] delete (all v) of [quotient v] set [divident dev v] to [0] set [dividend v] to () set [divisor v] to ([abs v] of ()) set [no2 neg v] to <() < [0] > if <(dividend) < [0] > then

  set [count v] to [1]

else

  set [count v] to [0]

end set [no1 neg v] to <(dividend) < [0] > repeat (length of (dividend))

  change [count v] by (1)
  if <(letter (count) of (dividend)) = [.]> then
     set [dividend dec v] to ((length of (dividend)) - (count))
  else
     add (letter (count) of (dividend)) to [dividend digits v]
  end

end repeat ((10) - (dividend dec))

  add [0] to [dividend digits v]

end if <(round (divisor)) = (divisor)> then

  set [dec pos v] to [0]

else

  set [count v] to [0]
  repeat until <(letter (count) of (dividend)) = [.]>
     change [count v] by (1)
  end
  set [dec pos v] to ((length of (divisor)) - (count))
  set [dividend v] to ((dividend) * ([10^ v] of (dec pos)))
  set [divisor v] to (round ((divisor) * ([10^ v] of (dec pos))))

end set [count v] to [0] set [currently solving v] to [] //That's an empty input, not a space. repeat (length of [dividend digits v])

  change [count v] by (1)
  set [currently solving v] to (join (currently solving) (item (count) of [dividend digits v]))
  set [times v] to [9]
  repeat until <((divisor) * (times)) < ((currently solving) + (1))>
     change [times v] by (-1)
  add [times v] to [quotient v]
  set [currently solving v] to ((currently solving) - ((divisor) * (times)))

end insert [.] at ((length of [quotient v]) - (8)) of [quotient v] repeat until <not <<(item (last v) of [quotient v]) = [.]> or <<<(item (last v) of [quotient v]) = [0]> and <(round (quotient)) = (quotient)>> and <[quotient v] contains [.]>>>>

  delete (last v) of [quotient v]

repeat until <<not <(item (1 v) of [quotient v]) = [0]>> or <(item (2 v) of [quotient v]) = [.]>>

  delete (1 v) of [quotient v]
</scratchblocks>

or

<scratchblocks> if <(b) < (0)> then

 set [result v] to (((a) * ([e^ v] of ((-1) * ([ln v] of ((-1) * (b)))))) * (-1))

else

 set [result v] to ((a) * ([e^ v] of ((-1) * ([ln v] of (b)))))

end </scratchblocks>

<sb>([] > [])</sb> <scratchblocks>

<<not <(a) < (b)>> and <not <(a) = (b)>>> </scratchblocks>

<sb>([] < [])</sb> <scratchblocks>

<<not <(a) > (b)>> and <not <(a) = (b)>>> </scratchblocks>

<sb>([] = [])</sb> <scratchblocks>

<<not <(a) < (b)>> and <not <(a) > (b)>>> </scratchblocks> or <scratchblocks> delete (all v) of [list v] //case sensitive add (a) to [list v] if <[list v] contains (b)> then

 . . .

end </scratchblocks>

<sb><<> and <>></sb> <scratchblocks>

if <. . .> then if <. . .> then . . . end end </scratchblocks> or <scratchblocks> <not <<not <. . .>> or <not <. . .>>>> </scratchblocks> or <scratchblocks> set [var v] to [0] repeat until <(var) = [1]> . . . // your block here, C-blocks loop inside if <> then set [var v] to [1] end // this works for all current boolean-accepting blocks </scratchblocks> or <scratchblocks> if <> then if <> then set [return v] to [true] else set [return v] to [false] end else set [return v] to [false] </scratchblocks>

<sb><<> or <>></sb> <scratchblocks>

if <. . .> then . . . else if <. . .> then . . . end end </scratchblocks> or <scratchblocks> <not <<not <. . .>> and <not <. . .>>>> </scratchblocks> or <scratchblocks> if <> then set [return v] to [true] else if <> then set [return v] to [true] else set [return v] to [false </scratchblocks>

<sb><not <>></sb> <scratchblocks><(. . .) = [false]></scratchblocks>

or <scratchblocks> if <> then //Put no blocks here. else . . . </scratchblocks>

<sb>(join [][])</sb> <scratchblocks>set [count v] to [0]

set [final v] to [] repeat (length of (a)) // a is the first input change [count v] by (1) add (letter (count) of (a)) to [final v] end set [count v] to (0) repeat (length of (b)) // b is the second input change [count v] by (1) add (letter (count) of (b)) to [final v] end set [final v] to (final) // This is the final string </scratchblocks> or <scratchblocks> // this only works if they're both whole numbers and b is positive set [return v] to [] repeat (length of ()) set [return v] to ((return) * (10)) end change [return v] by () </scratchblocks>

<sb>(letter (1) of [])</sb> <scratchblocks>// Only works for whole numbers and the letter you're looking for must be 1

if <[] > [0]> then set [return v] to [] repeat ((length of ()) - (1)) set [return v] to ([floor v] of ((return) / (10))) end else set [return v] to [-] end // all that's needed is a way to cut off the front digits. </scratchblocks>

<sb>(length of ())</sb> <scratchblocks>set [return v] to [1]

repeat until <(letter ((return) + (1)) of ()) = []> change [return v] by (1) end</scratchblocks>

<sb>(() mod ())</sb> <scratchblocks>

if <(round ((a) / (b))) > ((a) / (b))> then set [remainder v] to ((a) - ((round (((a) / (b)) - (0.5))) * (b))) else set [remainder v] to ((a) - ((round ((a) / (b))) * (b))) end </scratchblocks>

<sb>(round ())</sb> <scratchblocks>set [report v] to []

set [count v] to [1] repeat until <<(letter (count) of (num)) = [.]> or <(count) = (length of (num))>> set [report v] to (join (report) (letter (count) of (num))) change [count v] by (1) end if <<(letter (count) of (num)) = [.]> and <(letter ((count) + (1)) of (num)) > (4)>> then change [report v] by (1) end</scratchblocks> or <scratchblocks>set [return v] to [0] set [b v] to [] repeat until <([abs v] of (b)) < (1)> if <[] < [0]> then change [return v] by (1) change [b v] by (-1) else change [return v] by (-1) change [b v] by (1) end end</scratchblocks> or <scratchblocks> define round (#) set [count v] to [1] repeat until <(letter (count) of (#))=[.] change [count v] by [1] end change [count v] by [1] if <(letter (count) of (#))=[5]> then set [round v] to ([ceiling v] of (#)) else if <(letter (count) of (#))>[5]> then set [round v] to ([ceiling v] of (#)) else if <(letter (count) of (#))<[5]> then set [round v] to ([floor v] of (#) end end end </scratchblocks>

<sb>([10^ v] of ())</sb>

abs (absolute value): <scratchblocks> set [output v] to (number) if<(output) < (0)> then set [output v] to ((-1) * (output)) end </scratchblocks> or <scratchblocks> set [output v] to (([sqrt v] of ((input) * (input))) + (0)) </scratchblocks> sqrt (square root): <scratchblocks> set [output v] to (input) repeat until <(output) = (input)> set [output v] to ((((output) * (output)) + (input)) / ((2) * (output))) end </scratchblocks> or <scratchblocks> set [output v] to ([e^ v] of ((0.5) * ([ln v] of (input)))) </scratchblocks> ln (natural log): <scratchblocks> set [output v] to (([log v] of (input)) / ([log v] of ([e^ v] of (1)))) </scratchblocks> e^: <scratchblocks> set [output v] to ([10^ v] of ((input) * (2.718281828459))) </scratchblocks> log (base 10): <scratchblocks> set [output v] to (([ln v] of (input)) / ([ln v] of (10))) </scratchblocks> 10^: <scratchblocks> set [output v] to ([e^ v] of ((input) * ([ln v] of (10)))) </scratchblocks> floor: <scratchblocks> set [output v] to (round ((input) - (.5))) </scratchblocks> ceil: <scratchblocks> set [output v] to (round ((input) + (.49999999))) </scratchblocks> sin: <scratchblocks> set [output v] to ([cos v] of ((90) - (input))) </scratchblocks> cos: <scratchblocks> set [output v] to ([sin v] of ((90) - (input))) </scratchblocks> tan: <scratchblocks> set [output v] to (([sin v] of (input)) / ([cos v] of (input))) </scratchblocks>

Pen BlocksEdit

Block Workaround

<sb>stamp</sb>

<scratchblocks> set [stamping? v] to [true] create clone of [myself v] set [stamping? v] to [false]

when I start as a clone // and any other hat blocks if <(stamping?) = [true]> then stop [this script v] end </scratchblocks> // Note: Will contribute to the 300 clone limit and also will be removed with "delete this clone" blocks

Sensing BlocksEdit

Block Workaround
<sb>ask [] and wait</sb> <scratchblocks>say (question)

delete (all v) of [answer v] set [count v] to [0] repeat until <<touching [mouse-pointer v]?> and <mouse down?>> if <key [a v] pressed?> then change [count v] by (1) insert [A] at (count) of [answer v] end if <key [b v] pressed?> then change [count v] by (1) insert [B] at (count) of [answer v] end if <key [c v] pressed?> then change [count v] by (1) insert [C] at (count) of [answer v] end if <key [d v] pressed?> then change [count v] by (1) insert [D] at (count) of [answer v] end if <key [e v] pressed?> then change [count v] by (1) insert [E] at (count) of [answer v] end if <key [f v] pressed?> then change [count v] by (1) insert [F] at (count) of [answer v] end if <key [g v] pressed?> then change [count v] by (1) insert [G] at (count) of [answer v] end if <key [h v] pressed?> then change [count v] by (1) insert [H] at (count) of [answer v] end if <key [i v] pressed?> then change [count v] by (1) insert [I] at (count) of [answer v] end if <key [j v] pressed?> then change [count v] by (1) insert [J] at (count) of [answer v] end if <key [k v] pressed?> then change [count v] by (1) insert [K] at (count) of [answer v] end if <key [l v] pressed?> then change [count v] by (1) insert [L] at (count) of [answer v] end if <key [m v] pressed?> then change [count v] by (1) insert [M] at (count) of [answer v] end if <key [n v] pressed?> then change [count v] by (1) insert [N] at (count) of [answer v] end if <key [o v] pressed?> then change [count v] by (1) insert [O] at (count) of [answer v] end if <key [p v] pressed?> then change [count v] by (1) insert [P] at (count) of [answer v] end if <key [q v] pressed?> then change [count v] by (1) insert [Q] at (count) of [answer v] end if <key [r v] pressed?> then change [count v] by (1) insert [R] at (count) of [answer v] end if <key [s v] pressed?> then change [count v] by (1) insert [S] at (count) of [answer v] end if <key [t v] pressed?> then change [count v] by (1) insert [T] at (count) of [answer v] end if <key [u v] pressed?> then change [count v] by (1) insert [U] at (count) of [answer v] end if <key [v v] pressed?> then change [count v] by (1) insert [V] at (count) of [answer v] end if <key [w v] pressed?> then change [count v] by (1) insert [W] at (count) of [answer v] end if <key [x v] pressed?> then change [count v] by (1) insert [X] at (count) of [answer v] end if <key [y v] pressed?> then change [count v] by (1) insert [Y] at (count) of [answer v] end if <key [z v] pressed?> then change [count v] by (1) insert [Z] at (count) of [answer v] end if <key [0 v] pressed?> then change [count v] by (1) insert [0] at (count) of [answer v] end if <key [1 v] pressed?> then change [count v] by (1) insert [1] at (count) of [answer v] end if <key [2 v] pressed?> then change [count v] by (1) insert [2] at (count) of [answer v] end if <key [3 v] pressed?> then change [count v] by (1) insert [3] at (count) of [answer v] end if <key [4 v] pressed?> then change [count v] by (1) insert [4] at (count) of [answer v] end if <key [5 v] pressed?> then change [count v] by (1) insert [5] at (count) of [answer v] end if <key [6 v] pressed?> then change [count v] by (1) insert [6] at (count) of [answer v] end if <key [7 v] pressed?> then change [count v] by (1) insert [7] at (count) of [answer v] end if <key [8 v] pressed?> then change [count v] by (1) insert [8] at (count) of [answer v] end if <key [9 v] pressed?> then change [count v] by (1) insert [9] at (count) of [answer v] end if <key [right arrow v] pressed?> then change [count v] by (1) end if <key [left arrow v] pressed?> then change [count v] by (-1) end if <key [space v] pressed?> then change [count v] by (1) insert [] at (count) of [answer v] end wait (0.001) secs end</scratchblocks>

<sb>(distance to [sprite v])</sb>
<scratchblocks>([sqrt v] of (((([x position v] of [wanted sprite v]) - (x position)) * (([x position v] of [wanted sprite v]) - (x position))) + ((([y position v] of [wanted sprite v]) - (y position)) * (([y position v] of [wanted sprite v]) - (y position)))))</scratchblocks>
<sb>(mouse x)</sb> <scratchblocks>

forever

go to [mouse-pointer v]
set [Mouse Position v] to (x position)

</scratchblocks>

<sb>(mouse y)</sb> <scratchblocks>

forever

go to [mouse-pointer v]
set [Mouse Position v] to (y position)

</scratchblocks>

<sb>(days since 2000)</sb>

Where d = days since 2000: <scratchblocks>set [d v] to ((((367) * (year)) - ([floor v] of (((7) * ((year) + ([floor v] of (((month) + (9)) / (12))))) / (4)))) + ((([floor v] of (((275) * (month)) / (9))) + (day)) - (730530))) if <(d) < [-36435]> then

   change [d v] by (1)

end if <(d) < [-72990]> then

   change [d v] by (1)

end if <(d) > [36585]> then

   change [d v] by (-1)

end change [d v] by (-1) </scratchblocks> Correct from 1800-2199.

PicoBoard BlocksEdit

Block Workaround
<sb><sensor [A connected? v]</sb> <scratchblocks><([resistance A v] sensor value) < [10]>//resistance A through D</scratchblocks>

Data BlocksEdit

Variables BlocksEdit

Block Workaround
<sb>(variable)</sb> <scratchblocks>([public variable v] of [Stage v])</scratchblocks>

<scratchblocks>([personal variable v] of [Sprite1 v])</scratchblocks>

<sb>set [ v] to ()</sb> <scratchblocks>change [variable v] by (((variable) * (-1)) + (amount))</scratchblocks>

Note: Only works with numbers.

<sb>change [ v] by ()</sb> <scratchblocks>set [variable v] to ((variable) + (amount))</scratchblocks>

List BlocksEdit

Block Workaround
<sb>(list) // category=lists</sb> <scratchblocks>set [count v] to [0]

set [all are 1 v] to [true] repeat until <<(all are 1) = [false]> or <(count) > (length of [list v])>> change [count v] by (1) if <(length of (item (count) of [list v])) > [1]> then set [all are 1 v] to [false] end end if <(all are 1) = [true]> then set [report v] to [] set [count v] to [0] repeat (length of [list v]) change [count v] by (1) set [report v] to (join (report) (item (count) of [list v])) end else set [report v] to (item (1 v) of [list v]) set [count v] to [1] repeat ((length of [list v]) - (1)) change [count v] by (1) set [report v] to (join (report) (join [] (item (count) of [list v]))) end end</scratchblocks>

<sb>replace item (0 v) of [ v] with []</sb> <scratchblocks>delete (position) of [List v]

insert (item) at (position) of [List v]</scratchblocks>

<sb>([ v] contains [])</sb> <scratchblocks>set [report v] to [false]

set [count v] to [0] repeat (length of [list v]) change [count v] by (1) if <(item (count) of [list v]) = (thing)> then set [report v] to [true] stop [this script v] end end</scratchblocks>

<sb>(length of [list v])</sb> <scratchblocks>(length of (list))</scratchblocks>
<sb>add [] to [ v]</sb> <scratchblocks>insert [thing] at (last v) of [List v]</scratchblocks>

Removed BlocksEdit

Block Workaround
<sb>start scene [scene1 v] :: control</sb> <scratchblocks>

broadcast [scene1 v] </scratchblocks>

When () is True <scratchblocks>

when gf clicked forever

 if <. . .> then
   . . .
 end

end </scratchblocks>

<sb>forever if <> :: control</sb> <scratchblocks>

forever if <. . .> then . . . end </scratchblocks>

All at Once <scratchblocks>

define all at once // run without screen refresh . . . </scratchblocks>

<sb>create clone :: control</sb> <scratchblocks>create clone of [myself v]</scratchblocks>
<sb>change costume by (1) :: looks</sb> <scratchblocks>switch costume to ((costume #) + (1))</scratchblocks>
<sb>change background by (1) :: looks</sb> <scratchblocks>switch backdrop to ((backdrop #) + (1))</scratchblocks>
<sb>say nothing :: looks</sb> <scratchblocks>say []</scratchblocks>

or <scratchblocks>think []</scratchblocks>

<sb>hide all sprites :: looks</sb> <scratchblocks>broadcast [hide all sprites v]</scratchblocks>

and <scratchblocks> when I receive [hide all sprites v] // put this in every sprite hide </scratchblocks>

<sb>stamp transparent (50) :: pen</sb> <scratchblocks>

set [ghost v] effect to (...) stamp set [ghost v] effect to (0) </scratchblocks>

<sb>(abs () :: operators)</sb> <scratchblocks>([abs v] of ())</scratchblocks>

or see Operators Blocks

<sb>(sqrt () :: operators)</sb> <scratchblocks>([sqrt v] of ())</scratchblocks>

or see Operators Blocks

<sb><loud? :: sensing></sb> <scratchblocks><(loudness) > [30]></scratchblocks>
Scratch Days <scratchblocks>((days since 2000) - (2692))</scratchblocks>
<sb>(user id :: sensing)</sb> <scratchblocks>when gf clicked

if <not <[☁ users v] contains (username)>> then

add (username) to [☁ users v]

end repeat until <(item (check user id) of [☁ users v]) = (username)>

change [check user id v] by (1)

end </scratchblocks> then use <scratchblocks>say (join [Your User ID is ] (check user id))</scratchblocks> or <scratchblocks> if <(check user id) = [insert User ID number you want here]> then

. . .

end </scratchblocks> depending on what you want to make. Template:Note

Comment <scratchblocks>//Right Click anywhere on scripts area -> "add comment"</scratchblocks>

Experimental BlocksEdit

Block Workaround
<sb>(camera motion)</sb> <scratchblocks>(video [motion v] on [this sprite v])</scratchblocks>
<sb>(camera direction)</sb> <scratchblocks>(video [direction v] on [this sprite v])</scratchblocks>
<sb>(counter)</sb> <scratchblocks>(counter) // Using a variable</scratchblocks>
<sb>incr counter :: control</sb> <scratchblocks>change [counter v] by (1)</scratchblocks>
<sb>clear counter :: control</sb> <scratchblocks>set [counter v] to [0]</scratchblocks>
While () <scratchblocks>

repeat until <not <. . .>> . . . end </scratchblocks>

For Each () in () <scratchblocks>

set [i v] to [0] repeat (...) change [i v] by (1) . . . end </scratchblocks>

Non-Existent BlocksEdit

Block Workaround
<sb><[ v] received? :: events></sb> <scratchblocks>

when I receive [something v] set [something received v] to [true] . . . set [something received v] to [false] </scratchblocks> or <scratchblocks> when I receive [something v] set [something received v] to [true] wait (0.5) secs set [something received v] to [false] </scratchblocks> then <scratchblocks> if <(something received) = [true]> then . . . </scratchblocks> The reason this is not existent is for too much ambiguity. The two above is a workaround for the version when the message is done running and/or where it is only "true" for half a second. Below is one that is true if it was received it since the green flag was clicked. <scratchblocks> when gf clicked set [something received v] to [false]

when I receive [something v] set [something received v] to [true] </scratchblocks> and then simply use <scratchblocks> <(something received) = [true]> </scratchblocks> as the block you want to work around. Below is one that returns false when another broadcast is received <scratchblocks> when I receive [EVERYOTHERBROADCAST (duplicate and replace) v] set [something received v] to [false] </scratchblocks> and the variable is the same. There is one more thing you can do, since the project was created, but you'll need to be a Scratcher in order to use it. Delete the first block on the second workaround, and make the variable a cloud variable

<sb>stop [all and press green flag v]</sb> <scratchblocks>broadcast [Scratch-StartClicked v]</scratchblocks>

Note: Only works offline in Scratch 1.x

Repeat () Secs <scratchblocks>

reset timer repeat until <(timer) > [1]> . . . end </scratchblocks> or <scratchblocks> set [timer offset v] to ((timer) + (1)) repeat until <(timer) > (timer offset)> . . . end </scratchblocks>

Spawn <scratchblocks>

when I receive [Spawn v] . . .

broadcast [Spawn v] </scratchblocks>

<sb><clone? :: control></sb> <scratchblocks>

when I start as a clone set [clone? v] to [true] // create a variable for this sprite only, non-clones are set to false </scratchblocks> or <scratchblocks> set [clone? v] to [true] create clone of [myself v] set [clone? v] to [false] </scratchblocks>

<sb>change by x: () y: () :: motion</sb> <scratchblocks>go to x: ((x position) + (X)) y: ((y position) + (Y))</scratchblocks>

or <scratchblocks> change x by (X) change y by (Y) </scratchblocks>

<sb>glide () secs by x: () y: () :: motion</sb> <scratchblocks>glide (seconds) secs to x: ((x position) + (X)) y: ((y position) + (Y))</scratchblocks>
<sb>glide () secs () steps :: motion</sb> <scratchblocks>glide (seconds) secs to x: ((x position) + (([sin v] of (direction)) * (steps))) y: ((y position) + (([cos v] of (direction)) * (steps)))</scratchblocks>
<sb>point towards x: () y: () :: motion</sb> <scratchblocks>point in direction (([atan v] of (((X) - (x position)) / ((Y) - (y position)))) + (<(y position) > (Y)> * (180)))</scratchblocks>
<sb>(distance to x: () y: () :: sensing)</sb>
<scratchblocks>([sqrt v] of ((((x position) - (wanted x)) * ((x position) - (wanted x))) + (((y position) - (wanted y)) * ((y position) - (wanted y)))))</scratchblocks>
<sb><ask in progress? :: sensing></sb> <scratchblocks>

set [ask in progress? v] to [true] ask [...] and wait set [ask in progress? v] to [false] </scratchblocks>

<sb><sprite clicked? :: sensing></sb> <scratchblocks>

when this sprite clicked set [sprite clicked? v] to [true] wait until <not <<mouse down?> and <touching [mouse-pointer v]?>>> set [sprite clicked? v] to [false] </scratchblocks>

<sb>show all sprites :: looks</sb> <scratchblocks>broadcast [show all sprites v]</scratchblocks>

and <scratchblocks> when I receive [show all sprites v] // put this in every sprite show </scratchblocks>

<sb>previous costume :: looks</sb> <scratchblocks>switch costume to ((costume #) - (1))</scratchblocks>
<sb>previous backdrop :: looks</sb> <scratchblocks>switch backdrop to ((backdrop #) - (1))</scratchblocks>

or <scratchblocks>switch backdrop to [previous backdrop v]</scratchblocks>

<sb>(costume name :: looks)</sb> <scratchblocks>([costume name v] of [wanted sprite v])</scratchblocks>
<sb>go to back :: looks</sb> <scratchblocks>go back ([10 ^ v] of (309)) layers</scratchblocks>

Or Put <scratchblocks>when green flag clicked change [sprites v] by (1)</scratchblocks> in every sprite and put <scratchblocks>go back ((sprites)- (1)) layers</scratchblocks>

<sb>(() ^ ():: operators)</sb> <scratchblocks>([10 ^ v] of ((power) * ([log v] of (base))))

</scratchblocks> or <scratchblocks> ([e ^ v] of ((power) * ([ln v] of (base)))) </scratchblocks> Template:Note

<sb><true :: sensing></sb> <scratchblocks><not <>> // Put no boolean in the not block.</scratchblocks>

or <scratchblocks><[0] = [0]> // Same input on both slots.</scratchblocks>

<sb><false :: sensing></sb> <scratchblocks><not <not <>>> // Put no boolean in the second not block.</scratchblocks>

or <scratchblocks><<> and <>> // Put no booleans in the and block.</scratchblocks> or <scratchblocks><<> or <>> // Put no booleans in the or block.</scratchblocks> or <scratchblocks><[0] = [1]></scratchblocks>

<sb><[] ≠ [] :: operators></sb> <scratchblocks><not <[] = []>></scratchblocks>
<sb><[] ≥ [] :: operators></sb> <scratchblocks><not <[] < []>></scratchblocks>

or <scratchblocks><<(input 1) > (input 2)> or <(input 1) = (input 2)>></scratchblocks>

<sb><[] ≤ [] :: operators></sb> <scratchblocks><not <[] > []>></scratchblocks>

or <scratchblocks><<(input 1) < (input 2)> or <(input 1) = (input 2)>></scratchblocks>

<sb>(if <> then [] else [] :: operators)</sb> <scratchblocks>

if <condition :: sensing> then set [report v] to (true) else set [report v] to (false) </scratchblocks> or <scratchblocks>(((true) * <condition :: sensing>) + ((false) * <not <condition :: sensing>>))</scratchblocks> Template:Note

<sb>(letters () through () of [] :: operators)</sb> <scratchblocks>set [report v] to []

set [count v] to (a) // a is the first letter repeat until <(count) = ((b) + (1))> // b is the last letter set [report v] to (join (report) (letter (count) of (text))) change [count v] by (1) end </scratchblocks>

<sb>(digit () of () :: operators)</sb> <scratchblocks>(([floor v] of ((number) / ([10 ^ v] of (([floor v] of (digit)) - (1))))) mod (10))</scratchblocks>
<sb>(round () to the nearest () :: operators)</sb> <scratchblocks>((round ((round what) / (to the nearest))) * (to the nearest))</scratchblocks>

or <scratchblocks>((round ((number) * ([10^ v] of (number of places)))) / ([10^ v] of (number of places)))</scratchblocks>

<sb>([ v] effect :: looks)</sb> <scratchblocks>

forever set [color v] effect to (effect) </scratchblocks>

<sb><sound [ v] playing? :: sound></sb> <scratchblocks>

set [playing v] to [true] play sound [wanted sound v] until done set [playing v] to [false] </scratchblocks>

<sb>play sound [ v] for (1) beats :: sound</sb> <scratchblocks>

play sound [wanted sound v] rest for (1) beats stop all sounds </scratchblocks>

<sb>(instrument :: sound)</sb> <scratchblocks>

forever set instrument to (instrument) </scratchblocks>

<sb>change item (1 v) of [ v] by (1) :: list</sb> <scratchblocks>replace item (1 v) of [wanted list v] with ((item (1 v) of [wanted list v]) + (1))</scratchblocks>

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.