From Test-Scratch-Wiki
(Redirected from Eng:List of Workarounds)
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 Blocks
Block | Workaround |
---|---|
when green flag clicked
|
when I receive [Scratch-StartClicked v] . . . Note: Only works offline in Scratch 1.x 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] . . . |
when [space v] key pressed
|
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?> . . . |
when this sprite clicked
|
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. . . . or 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 |
when [loudness v] > (10)
|
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)> . . . |
broadcast [message v]
|
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 or broadcast [broadcast v] and wait when I receive [broadcast v] . . . // whatever comes after the broadcast, in addition to the receive block you would have |
broadcast [message v] and wait
|
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 or 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! |
Control Blocks
Block | Workaround |
---|---|
wait (1) secs
|
rest for <((tempo) / (60)) * (1)> beats or 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 |
forever
|
repeat until <> // Put no boolean in the block or put a boolean that will always equals false (1=2). . . . end or when I receive [forever v] . . . broadcast [forever v] or repeat ([10^ v] of (309) . . . |
repeat (10)
|
set [counter v] to [0] repeat until <(counter) = [10]> change [counter v] by (1) . . . end or define repeatloop . . . change [Count v] by (1) if <(Count) < (10)> then repeatloop end set [Count v] to [0] // This is for setting it up repeatloop |
if <> then
|
if <. . .> then . . . else // Put no blocks here. end
when gf clicked forever wait until <. . .> . . . //That assumes a forever loop around the if |
if <> then
else
|
if <> then . . . end if <not <>> then . . . end
define if <boolean> if <boolean> then . . .//whatever would be in if stop [this script v] end when gf clicked . . . if <. . .> . . .//whatever would be in else //that assumes the if/else is the last block |
wait until <>
|
repeat until < . . . > // Put no blocks here. end |
stop [ v]
|
this script:
wait until <> // Put no boolean in the block. or wait ([10^ v] of (309)) secs // Those do not actually *stop* the script, the blocks only start and don't end or forever //Put no blocks here. all: when I receive [stop all v] stop [other scripts in sprite v] // It must be put in every sprite and the Stage. |
Motion Blocks
Block | Workaround |
---|---|
(direction)
|
([direction v] of [wanted sprite v]) |
(x position)
|
([x position v] of [wanted sprite v]) |
(y position)
|
([y position v] of [wanted sprite v]) |
go to [wanted sprite v]
|
go to x: (mouse x) y: (mouse y) go to x: ([x position v] of [wanted sprite v]) y: ([y position v] of [wanted sprite v]) set x to: ([x position v] of [wanted sprite v]) set y to: ([y position v] of [wanted sprite v]) |
go to x: () y: ()
|
set x to (x value) set y to (y value) or glide (0) secs to x: () y: () |
point towards [ v]
|
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 |
point in direction (90 v)
|
turn cw ((90) - (direction)) degrees or turn ccw ((-1) * ((90) - (direction))) degrees |
turn right (15) degrees
|
point in direction ((direction) + (15)) |
turn left (15) degrees
|
point in direction ((direction) - (15)) |
move (10) steps
|
go to x: ((x position) + (([sin v] of (direction)) * (10))) y: ((y position) + (([cos v] of (direction)) * (10))) or change x by (([sin v] of (direction)) * (10)) change y by (([cos v] of (direction)) * (10)) |
change x by (10)
|
set x to ((x position) + (10)) |
change y by (10)
|
set y to ((y position) + (10)) |
set x to (0)
|
change x by ((wanted x) - (x position)) change x by (((x position) * (-1)) + (wanted x)) go to x: (wanted x) y: (y position) |
set y to (0)
|
change y by ((wanted y) - (y position)) change y by (((y position) * (-1)) + (wanted y)) go to x: (x position) y: (wanted y) |
Motor Blocks
Block | Workaround |
---|---|
turn motor on for (1) secs
|
motor on wait (number) secs motor off |
turn motor off
|
turn motor on for (0) secs or set motor power (0) |
Looks Blocks
Block | Workaround |
---|---|
switch to costume [ v]
|
repeat until <(wanted costume #) = (costume #)> next costume end |
next costume
|
switch to costume ((costume #) + (1)) |
switch backdrop to [ v]
|
repeat until <(wanted backdrop #) = (backdrop #)> next backdrop end |
next backdrop
|
switch backdrop to ((backdrop #) + (1)) or switch backdrop to [next backdrop v] |
(costume #)
|
([costume # v] of [wanted sprite v]) |
(backdrop #)
|
([backdrop # v] of [Stage v]) |
(backdrop name)
|
([backdrop name v] of [Stage v]) |
say [] for () secs
|
say (text) wait (amount) secs say [] |
think [] for () secs
|
think (text) wait (amount) secs think [] |
clear graphic effects
|
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) |
(size)
|
([size v] of [wanted sprite v]) |
change size by ()
|
set size to ((size) + (amount))% |
set size to () %
|
change size by ((wanted size) - (size)) |
go to front
|
go back ((-1) * ([10^ v] of (309))) layers |
hide
|
set [ghost v] effect to (100) or switch costume to [invisible costume v] |
Sound Blocks
Block | Workaround |
---|---|
play sound [ v]
|
. . . broadcast [continue script v] play sound [wanted sound v] until done when I receive [continue script v] . . . |
play sound [ v] until done
|
play sound [wanted sound v] wait (length of sound) secs |
rest for () beats
|
wait (((60) / (tempo)) * (beats)) secs |
change volume by ()
|
set volume to ((volume) + (amount))% |
set volume to () %
|
change volume by ((amount) - (volume)) |
(volume)
|
([volume v] of [wanted sprite v]) |
change tempo by ()
|
set tempo to ((tempo) + (amount)) bpm |
set tempo to () bpm
|
change tempo by ((amount) - (tempo)) |
Operators Blocks
Block | Workaround |
---|---|
(() + ())
|
((a) - ((b) * (-1))) or ((a) - ((0) - (b))) or set [answer v] to (a) change [answer v] by (b) |
(() - ())
|
((a) + ((b) * (-1))) or ((a) + ((b) / (-1))) or ((a) + (join [-](b))) or set [answer v] to () change [answer v] by ((-1) * ()) The third workarounds only works with positive b; --3 for example is evaluated by Scratch to be 0. |
(() * ())
|
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) or ((a) / ((1) / (b))) // the product of "a" and "b" or 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 |
(() / ())
|
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] or 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 |
([] > [])
|
<<not <(a) < (b)>> and <not <(a) = (b)>>> |
([] < [])
|
<<not <(a) > (b)>> and <not <(a) = (b)>>> |
([] = [])
|
<<not <(a) < (b)>> and <not <(a) > (b)>>> or delete (all v) of [list v] //case sensitive add (a) to [list v] if <[list v] contains (b)> then . . . end |
<<> and <>>
|
if <condition 1> then if <condition 2> then . . . end end or <not <<not <condition 1>> or <not <condition 2>>>> or set [nope v] to [0] repeat until <(nope) = [1]> . . . // your block here, C-blocks loop inside if <> then set [nope v] to [1] end // this surprisingly works for all current boolean-accepting blocks or if <> then if <> then set [return v] to [true] else set [return v] to [false] end else set [return v] to [false] |
<<> or <>>
|
if <condition 1> then . . . else if <condition 2> then . . . end end or <not <<not <condition 1>> and <not <condition 2>>>> or if <> then set [return v] to [true] else if <> then set [return v] to [true] else set [return v] to [false |
<not <>>
|
<(. . .) = [false]> or if <> then //Put no blocks here. else . . . |
(join [][])
|
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 or // 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 () |
(letter (1) of [])
|
// Only works for whole numbers and the letter you're looking for must be 1 if <[] > [0] 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. |
(length of ())
|
set [return v] to [1] repeat until <(letter ((return) + (1)) of ()) = []> change [return v] by (1) end |
(() mod ())
|
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 |
(round ())
|
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 or 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 or 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 |
([10^ v] of ())
|
abs (absolute value): set [output v] to (number) if<(output) < (0)> then set [output v] to ((-1) * (output)) end or set [output v] to (([sqrt v] of ((input) * (input))) + (0)) sqrt (square root): set [output v] to (input) repeat until <(output) = (input)> set [output v] to ((((output) * (output)) + (input)) / ((2) * (output))) end or set [output v] to ([e^ v] of ((0.5) * ([ln v] of (input)))) ln (natural log): set [output v] to (([log v] of (input)) / ([log v] of ([e^ v] of (1)))) e^: set [output v] to ([10^ v] of ((input) * (2.718281828459))) log (base 10): set [output v] to (([ln v] of (input)) / ([ln v] of (10))) 10^: set [output v] to ([e^ v] of ((input) * ([ln v] of (10)))) floor: set [output v] to (round ((input) - (.5))) ceil: set [output v] to (round ((input) + (.49999999))) sin: set [output v] to ([cos v] of ((90) - (input))) cos: set [output v] to ([sin v] of ((90) - (input))) tan: set [output v] to (([sin v] of (input)) / ([cos v] of (input))) |
Pen Blocks
Block | Workaround |
---|---|
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]> stop [this script v] end // Note: Will contribute to the 300 clone limit and also will be removed with "delete this clone" blocks |
Sensing Blocks
Block | Workaround |
---|---|
ask [] and wait
|
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 |
(distance to [sprite v])
|
([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))))) |
(mouse x)
|
forever go to [mouse-pointer v] set [Mouse Position v] to (x position) |
(mouse y)
|
forever go to [mouse-pointer v] set [Mouse Position v] to (y position) |
(days since 2000)
|
Where d = days since 2000: 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) Correct from 1800-2199. |
PicoBoard Blocks
Block | Workaround |
---|---|
<sensor [A connected? v]
|
<([resistance A v] sensor value) < [10]>//resistance A through D |
Data Blocks
Variables Blocks
Block | Workaround |
---|---|
(variable)
|
([public variable v] of [Stage v]) ([personal variable v] of [Sprite1 v]) |
set [ v] to ()
|
change [variable v] by (((variable) * (-1)) + (amount)) Note: Only works with numbers. |
change [ v] by ()
|
set [variable v] to ((variable) + (amount)) |
List Blocks
Block | Workaround |
---|---|
(list) // category=lists
|
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 |
replace item (0 v) of [ v] with []
|
delete (position) of [List v] insert (item) at (position) of [List v] |
([ v] contains [])
|
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 script end end |
(length of [list v])
|
(length of (list)) |
add [] to [ v]
|
insert [thing] at (last v) of [List v] |
Removed Blocks
Block | Workaround | ||
---|---|---|---|
start scene [scene1 v]//category=control
|
broadcast [scene1 v] | ||
when gf clicked forever if <. . .> . . . end end | |||
forever if <>
|
forever if <. . .> then . . . end | ||
define all at once // run without screen refresh . . . | |||
create clone // category=control
|
create clone of [myself v] | ||
change costume by (1) // category=looks
|
switch costume to ((costume #) + (1)) | ||
change background by (1) // category=looks
|
switch backdrop to ((backdrop #) + (1)) | ||
say nothing // category=looks
|
say [] or think [] | ||
hide all sprites // category=looks
|
broadcast [hide all sprites v] and when I receive [hide all sprites v] // put this in every sprite hide | ||
stamp transparent (50) // category=pen
|
set [ghost v] effect to (...) stamp set [ghost v] effect to (0) | ||
(abs ()) // category=operators
|
([abs v] of ()) or see Operators Blocks | ||
(sqrt ()) // category=operators
|
([sqrt v] of ()) or see Operators Blocks | ||
<loud?>
|
<(loudness) > [30]> | ||
((days since 2000) - (2692)) | |||
(user id)
|
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 then use say (join [Your User ID is ] (check user id)) or if <(check user id) = [insert User ID number you want here]> . . . end depending on what you want to make.
| ||
//Right Click anywhere on scripts area -> "add comment" |
Experimental Blocks
Block | Workaround |
---|---|
(camera motion)
|
(video [motion v] on [this sprite v]) |
(camera direction)
|
(video [direction v] on [this sprite v]) |
(counter)
|
(counter) // Using a variable |
incr counter // category=control
|
change [counter v] by (1) |
clear counter // category=control
|
set [counter v] to [0] |
repeat until <not <. . .>> . . . end | |
set [i v] to [0] repeat (...) change [i v] by (1) . . . end |
Non-Existent Blocks
Block | Workaround | ||
---|---|---|---|
<[ v] received?> // category=events
|
when I receive [something v] set [something received v] to [true] . . . set [something received v] to [false] or when I receive [something v] set [something received v] to [true] wait (0.5) secs set [something received v] to [false] then if <(something received) = [true]> then . . . 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. when gf clicked set [something received v] to [false] when I receive [something v] set [something received v] to [true] and then simply use <(something received) = [true]> as the block you want to work around. Below is one that returns false when another broadcast is received when I receive [EVERYOTHERBROADCAST (duplicate and replace) v] set [something received v] to [false] 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 | ||
stop [all and press green flag v]
|
broadcast [Scratch-StartClicked v] Note: Only works offline in Scratch 1.x | ||
reset timer repeat until <(timer) > [1]> . . . end or set [timer offset v] to ((timer) + (1)) repeat until <(timer) > (timer offset)> . . . end | |||
when I receive [Spawn v] . . . broadcast [Spawn v] | |||
<clone?> // category=control
|
when I start as a clone set [clone? v] to [true] // create a variable for this sprite only, non-clones are set to false or set [clone? v] to [true] create clone of [myself v] set [clone? v] to [false] | ||
change by x: () y: () // category=motion
|
go to x: ((x position) + (X)) y: ((y position) + (Y)) or change x by (X) change y by (Y) | ||
glide () secs by x: () y: () // category=motion
|
glide (seconds) secs to x: ((x position) + (X)) y: ((y position) + (Y)) | ||
glide () secs () steps // category=motion
|
glide (seconds) secs to x: ((x position) + (([sin v] of (direction)) * (steps))) y: ((y position) + (([cos v] of (direction)) * (steps))) | ||
point towards x: () y: () // category=motion
|
point in direction (([atan v] of (((X) - (x position)) / ((Y) - (y position)))) + (<(y position) > (Y)> * (180))) | ||
(distance to x: () y: ()) // category=sensing
|
([sqrt v] of ((((x position) - (wanted x)) * ((x position) - (wanted x))) + (((y position) - (wanted y)) * ((y position) - (wanted y))))) | ||
<ask in progress?> // category=sensing
|
set [ask in progress? v] to [true] ask [...] and wait set [ask in progress? v] to [false] | ||
<sprite clicked?> // category=sensing
|
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] | ||
show all sprites // category=looks
|
broadcast [show all sprites v] and when I receive [show all sprites v] // put this in every sprite show | ||
previous costume // category=looks
|
switch costume to ((costume #) - (1)) | ||
previous backdrop // category=looks
|
switch backdrop to ((backdrop #) - (1)) or switch backdrop to [previous backdrop v] | ||
(costume name) // category=looks
|
([costume name v] of [wanted sprite v]) | ||
go to back // category=looks
|
go back ([10 ^ v] of (309)) layers | ||
(() ^ ()) // category=operators
|
([10 ^ v] of ((power) * ([log v] of (base)))) or ([e ^ v] of ((power) * ([ln v] of (base))))
| ||
<true>
|
<not <>> // Put no boolean in the not block. or <[0] = [0]> // Same input on both slots. | ||
<false>
|
<not <not <>>> // Put no boolean in the second not block. or <<> and <>> // Put no booleans in the and block. or <<> or <>> // Put no booleans in the or block. or <[0] = [1]> | ||
<[] ≠ []> // category=operators
|
<not <[] = []>> | ||
<[] ≥ []> // category=operators
|
<not <[] < []>> or <<(input 1) > (input 2)> or <(input 1) = (input 2)>> | ||
<[] ≤ []> // category=operators
|
<not <[] > []>> or <<(input 1) < (input 2)> or <(input 1) = (input 2)>> | ||
(if <> then [] else []) // category=operators
|
if <condition> then set [report v] to (true) else set [report v] to (false) or (((true) * <condition>) + ((false) * <not <condition>>))
| ||
(letters () through () of []) // category=operators
|
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 | ||
(digit () of ()) // category=operators
|
(([floor v] of ((number) / ([10 ^ v] of (([floor v] of (digit)) - (1))))) mod (10)) | ||
(round () to the nearest ()) // category=operators
|
((round ((round what) / (to the nearest))) * (to the nearest)) or ((round ((number) * ([10^ v] of (number of places)))) / ([10^ v] of (number of places))) | ||
([ v] effect) // category=looks
|
forever set [color v] effect to (effect) | ||
<sound [ v] playing?> // category=sound
|
set [playing v] to [true] play sound [wanted sound v] until done set [playing v] to [false] | ||
play sound [ v] for (1) beats // category=sound
|
play sound [wanted sound v] rest for (1) beats stop all sounds | ||
(instrument) // category=sound
|
forever set instrument to (instrument) | ||
change item (1 v) of [ v] by (1) // category=list
|
replace item (1 v) of [wanted list v] with ((item (1 v) of [wanted list v]) + (1)) |