Discuss Scratch
- Discussion Forums
- » Suggestions
- » The Workarounds to Frequently Suggested Blocks
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
This is the newest topic for frequently suggested blocks workarounds. You can find the old one here which is closed. The owner of it has quit Scratch and their account is no longer accessible so I have taken this over.
_______________________________________________________________________________________________
_______________________________________________________________________________________________
By the way, this topic is NOT saying that these blocks should never be added because of workarounds. Here's a quote from Za-Chary that explains this more:
_______________________________________________________________________________________________
Motion Blocks | Looks Blocks | Sound Blocks | Event Blocks | Control Blocks | Sensing Blocks | Operator Blocks | Variable Blocks
_______________________________________________________________________________________________
By the way, this topic is NOT saying that these blocks should never be added because of workarounds. Here's a quote from Za-Chary that explains this more:
Well, there's a couple reasons this is a useful list.
The “previous costume” block is not rejected, but it just hasn't been added to the editor. For those looking for something that works the same as a “previous costume” block, they can look at this topic for a workaround so they can effectively code their project.
The “when stop sign clicked” block is rejected, so we will not be adding it (and in this case, yes, there is something “wrong” with implementing the suggestion). Some Scratchers still might like to simulate its effects, however, so they can look at this topic for a workaround so they can accomplish what the block would do.
The purpose of this topic isn't to tell you to “stick” to workarounds — it's to provide you workarounds for blocks that you might be looking to use. It will likely save you time by using the workaround instead of waiting for us to implement a block.
Last edited by BearSlothCoding (Aug. 26, 2020 19:32:13)
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
Motion blocks :: hat :: motion_______________________________________________________________________________________________
point towards x:() y:() :: motionThis can be done with two methods.
Method 1:
Create a sprite and move it to where you want it. Say for example, you have a sprite X and move it to x:0 y:0, you could do this:
(for sprite X)
when green flag clicked(for the other sprite)
go to x:(0) y:(0)
when green flag clickedMethod 2:
forever
point towards [X v]
end
Or you could do this complicated code.
set [deltax v] to ((WantedX) - (x position))_______________________________________________________________________________________________
set [deltay v] to ((WantedY) - (y position))
if <not <(deltay) = [0]>> then
if <(deltay) > (0)> then
point in direction ([atan v] of ((deltax)/(deltay))
else
point in direction ([atan v] of (((deltax)/(deltay)) + (180)))
end
else
if ((deltax) > (0)) then
point in direction (90)
else
point in direction (-90)
end
bounce :: motioncan be made with this script:
point in direction ((direction) - (180)
Last edited by BearSlothCoding (July 12, 2020 01:04:31)
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
Looks Blocks :: hat :: looks_______________________________________________________________________________________________
previous costume :: looksThis can be done with a very simple script:
switch costume to ((costume #) - (1))You can also use this project which contains a previous costume hacked block.
_______________________________________________________________________________________________
shown? :: looks :: reporterCan be done with:
set [shown? v] to [yes]//Put this right after the "show" block
set [shown? v] to [no]//Put this right after the "hide" block
Last edited by BearSlothCoding (July 27, 2020 03:00:02)
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
Sound Blocks :: hat :: sound_______________________________________________________________________________________________
next sound ::soundcan be done with this:
when gf clicked
forever
play sound (sound#) until done
end
change [sound# v] by (1)
Similarly,
previous sound ::soundcan be done with this:
when gf clicked
forever
play sound (sound#) until done
end
change [sound# v] by (-1)_______________________________________________________________________________________________
pause sound :: soundor
resume sound :: soundcan be done with two methods.
You can find the first method in this project by xXRedTheCoderXx.
The second method you can find here by EIephant_Lover.
I did not provide the scripts here because the second one is very long and it wouldn't be fair to include one method but not the other just because one is long.
Last edited by BearSlothCoding (June 10, 2020 17:42:25)
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
Events Blocks :: hat :: events_______________________________________________________________________________________________
when ( :: more blocks) clicked :: hat :: eventsA when stop signed clicked block is rejected but you can achieve it with this script:
when green flag clicked
forever
reset timer
when [timer v] > (0)
do something
when [timer v] > (0)
forever
reset timer
end
Alternatively, you could also do this method which has less delay but uses a variable:
when green flag clicked_______________________________________________________________________________________________
forever
set [timer v] to (timer)
when [timer v] > (timer :: variables)
do something
when <something> is done :: hat :: eventscan be done with this script:
when green flag clicked_______________________________________________________________________________________________
broadcast [Continue v]
when [timer v] > (timer :: variables)
broadcast [Continue v]
when I receive [Continue v]
broadcast [Check v]
forever
set [timer v] to (timer)
when I receive [Check v]
forever
if <something happens> then
do something
end
broadcast [ v] received? :: boolean :: events
The traditional method is the following code:
when green flag clicked
set [received? v] to [False]
when I receive [Message v]
set [received? v] to [True]
when green flag clicked
repeat until <(received?) = [True]>
Do stuff
end
do other stuff
But some people don't like the amount of variables in large projects and don't want to add more, which in that case you can use this method where it uses a list instead of three variables:
when green flag clicked
replace item (1 v) of [list v] with [False]
replace item (2 v) of [list v] with [False]
replace item (3 v) of [list v] with [False]
when I receive [Event 1 v]
replace item (1 v) of [list v] with [True]
when I receive [Event 2 v]
replace item (2 v) of [list v] with [True]
when I receive [Event 3 v]
replace item (3 v) of [list v] with [True]
when green flag clicked
repeat until <(item (1 v) of [list v] :: list) = [True]>
Do Stuff
end
repeat until <(item (2 v) of [list v] :: list) = [True]>
Do Stuff
end
repeat until <(item (3 v) of [list v] :: list) = [True]>
Do Stuff
end
_______________________________________________________________________________________________
when costume switches to [ v] :: events :: hat
Can be done with:
wait until <(costume [number v] :: looks) = []>
Last edited by BearSlothCoding (Aug. 18, 2020 15:21:09)
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
Control Blocks :: hat :: control_______________________________________________________________________________________________
while < . . . > { . . . } @loopArrow :: controlcan be done by doing this:
repeat until < not < . . . > >_______________________________________________________________________________________________
...
if <...> then {
...
} else if <...> {
...
} :: control
Can be done with:
if <...> then
...
else
if <...> then
...
end
end
Last edited by BearSlothCoding (July 27, 2020 03:18:17)
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
Sensing Blocks :: hat :: sensing_______________________________________________________________________________________________
am i a clone? :: boolean :: sensingcan be made with this script:
when green flag clicked
set [am i a clone? v] to [false]
when i start as a clone
set [am i a clone? v] to [true]
when green flag clicked
forever
if <(am i a clone?) = [true]> then
do something
or you could also do this slightly more effective method:
when green flag clicked
switch costume to [Sprite Costume v]
when I start as a clone
switch costume to [Clone Costume v]
when I receive [Do Stuff v]_______________________________________________________________________________________________
if <(costume) = [Sprite Costume]> then
do something
end
if <(costume) = [Clone Costume]> then
do something else
end
<key [enter v] pressed?>
can be created with this:
key (join [enter] []) pressed?This can be used for other single character special keys, such as ; ‘ , \ as well as enter.
But it doesn’t not work with the shift, control, tab, etc. keys.
Last edited by BearSlothCoding (May 28, 2020 18:28:16)
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
Operator Blocks :: hat :: operators_______________________________________________________________________________________________
(this) xor (that) :: boolean :: operatorscan be made with this:
<not<(this) = (that)>>_______________________________________________________________________________________________
true :: boolean :: operatorscan be made with this:
<[1]=[1]>_______________________________________________________________________________________________
false :: boolean :: operatorscan be made with this:
<[1]>[2]>_______________________________________________________________________________________________
letters (start) through (end :: variables) of (string) :: reporter :: operatorscan be done with this:
set [iterator v] to (start)_______________________________________________________________________________________________
set [result v] to []
repeat until (((end :: variables)- (start))+(1)
set [result v] to (join (result) (letter (iterator) of (string)))
end
() ≥ () :: boolean :: operatorscan be done with:
<not <()<()>>_______________________________________________________________________________________________
() ≤ () :: boolean :: operatorscan be done with:
<not <()>()>>_______________________________________________________________________________________________
[sign v] of () :: reporter operators // reports "1" if the input is positive, "-1" if negative, and "0" when the number is 0.can be workarounded with:
(((n) / ([abs v] of (n)))+(0))
Last edited by BearSlothCoding (Aug. 6, 2020 23:00:19)
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
Variable Blocks :: hat :: variables_______________________________________________________________________________________________
List Blocks :: hat :: list_______________________________________________________________________________________________
item [last v] of [list v] :: list
item (length of [list v]) of [list v] :: list_______________________________________________________________________________________________
copy list [ v] to list [ v] :: list
when I receive [ v]_______________________________________________________________________________________________
delete (All v) of [list b v]
set [# v] to [0]
repeat (length of [list a v] :: list)
change [# v] by (1)
add (item (#) of [list a v] :: list) to [list b v]
end
(item [random v] of [list v] :: list)
(item (pick random (1) to (length of [list v])) of [list v] :: list)
Last edited by BearSlothCoding (Aug. 7, 2020 15:06:48)
- PizzaAddict4Life
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
You forgot the “Lists” block.
Ill report my reply to be deleted once you add it.
Also reporting to be stickied
Ill report my reply to be deleted once you add it.
Also reporting to be stickied
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
I figured I would add it in with the variables since that is where they are in the editor. It already is stickied, but thank you. You forgot the “Lists” block.
Ill report my reply to be deleted once you add it.
Also reporting to be stickied
- PizzaAddict4Life
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
I figured I would add it in with the variables since that is where they are in the editor. It already is stickied, but thank you. You forgot the “Lists” block.
Ill report my reply to be deleted once you add it.
Also reporting to be stickied
Ah got it! That makes sense.
Do you still want me to delete my post?
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
No, it's fine. I don't any more reserved.I figured I would add it in with the variables since that is where they are in the editor. It already is stickied, but thank you. You forgot the “Lists” block.
Ill report my reply to be deleted once you add it.
Also reporting to be stickied
Ah got it! That makes sense.
Do you still want me to delete my post?
- fdreerf
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
I'm sure creating all those posts with the 60-second rule was funnnnnn
Also by “this or that” you mean "this XOR that", correct?
Also by “this or that” you mean "this XOR that", correct?
Last edited by fdreerf (May 28, 2020 02:16:43)
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
Sure was! To make sure all of my posts were in a row with nobody else interrupting it, I just did the I'm sure creating all those posts with the 60-second rule was funnnnnn
Block section :: hatat first which takes like 20 seconds. Then I had to wait a while for every. Single. One.
XOR that", correct?Oh yes, sorry. I'll fix that. Also by “this or that” you mean "this
Last edited by BearSlothCoding (May 28, 2020 02:22:19)
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
Oh my god, I'm finally done. If only the old topic wasn't closed, then I could have quoted it and copy+pasted it instead of spending nearly 2 hours of my life doing this. Don't get me wrong, I wanted to recreate this sticky, I just didn't want to spend 2 hours figuring out scratchblocks.
But I definitely now know a lot more about scratchblocks and how to create more blocks.
But I definitely now know a lot more about scratchblocks and how to create more blocks.
- Za-Chary
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
If you asked, I could have re-opened the old topic so you could quote it — but perhaps, due to your bolded statement, it was good practice for you to do this anyway. Oh my god, I'm finally done. If only the old topic wasn't closed, then I could have quoted it and copy+pasted it instead of spending nearly 2 hours of my life doing this. Don't get me wrong, I wanted to recreate this sticky, I just didn't want to spend 2 hours figuring out scratchblocks.
But I definitely now know a lot more about scratchblocks and how to create more blocks.

- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
I was thinking about asking that, but I figured it would sound/be kind of lazy. I also figured that if I didn't know how to make the blocks on my own, then I wouldn't fit for running this. I can't teach something if I don't know it. Plus, I'm sure this new knowledge will prove useful in the future.If you asked, I could have re-opened the old topic so you could quote it — but perhaps, due to your bolded statement, it was good practice for you to do this anyway. Oh my god, I'm finally done. If only the old topic wasn't closed, then I could have quoted it and copy+pasted it instead of spending nearly 2 hours of my life doing this. Don't get me wrong, I wanted to recreate this sticky, I just didn't want to spend 2 hours figuring out scratchblocks.
But I definitely now know a lot more about scratchblocks and how to create more blocks.
- Nambaseking01
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
also, this is your second sticky (or third - idk)
- BearSlothCoding
-
1000+ posts
The Workarounds to Frequently Suggested Blocks
Second, but my first won't last long. It's about the server troubles we've been having and they won't last forever. I think. also, this is your second sticky (or third - idk)
“Won't last long” 3 months later… ;-;
Last edited by BearSlothCoding (Aug. 26, 2020 23:01:49)
- Discussion Forums
- » Suggestions
-
» The Workarounds to Frequently Suggested Blocks