Discuss Scratch
- Discussion Forums
- » Suggestions
- » (Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
- openPoll
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
NOTICE: This has been copy-pasted from the old thread.
Previous List of Workarounds
Previous List of Workarounds
What Is A Workaround?
You might come here and think to yourself: “What in the world is a workaround!” Well I'll explain it to you!
To put it simply, a workaround on Scratch is a way of making a script that does the function of a made-up block.
Workaround = A script that does a function = Made-up block
If you still aren't sure, here's an example:
I have a made-up block that I call:(() + () + 1) :: operators
A workaround looks like this:(() + (() + (1)))
See how the top one is made-up, but the bottom one isn't? Though the bottom one works just like the top one!
Here in the suggestions forum many people make suggestions for new blocks. The purpose of this thread is to keep up with blocks which have workarounds to!
—-
Notable Posts/Workarounds from other Suggestions:
A new operators block, similar to (letter () of ) by dvargasewsSo, for anybody who's curious, here is the full workaround, that is the absolute best approximation to the block suggested in the OP, which stores its output in ‘result’:define letters (a) to (b) of (str) => result“But that's too long!” I hear you say. Note that this is the absolute complete workaround, that does everything mentioned in the OP (reverse output on backwards indices) and then some (return the same thing as letter (0) of (str) if indices are out of bounds).
if <<<(a) < [1]> or <(b) < [1]>> or <<(a) > (length of (str))> or <(b) > (length of (str))>>> then
set [result v] to []
stop [this script v]
end
delete (all v) of [chars v]
set [i v] to (a)
if <(a) < (b)> then
repeat (((b) - (a)) + (1))
add (letter (i) of (str)) to [chars v]
change [i v] by (1)
end
else
repeat (((a) - (b)) + (1))
add (letter (i) of (str)) to [chars v]
change [i v] by (-1)
end
end
set [result v] to (chars)
For the majority of cases, something much simpler will work, such as:define letters (a) to (b) of (str) => resultNote that the only things this block does not support are a) reverse strings, b) bounds checking, and c) strings above the join block limit, which is barely even a problem, as most string manipulation will involve the join block anyways.
set [i v] to (a)
set [result v] to []
repeat (((b) - (a)) + (1))
set [result v] to (join (result) (letter (i) of (str)))
Also note that this block will still return a valid value for invalid bounds, simply due to how Scratch bound checks the letter of () block.
If the i variable is bothering you, it gets even better:define next letter (i) (b) (str)And if we had custom reporters, this block would need no variables at all.
set [result v] to (join (result) (letter (i) of (str)))
if <(i) < (b)> then
next letter ((i) + (1)) (b) (str)
end
define letters (a) to (b) of (str) => result
set [result v] to []
next letter (a) (b) (str)
To compare, the speed of all three blocks is pretty good for small strings, and the second one should work for almost anything that you would actually need to do in Scratch. It's likely that whatever block the Scratch Team implemented would also be slow on ridiculously large strings, simply because creating substrings, unless they are interned, is by nature an O(n) operation.
My point with this post is that OP's argument that the workaround is laggy / slow is basically moot; although this custom block only works in a single thread, if you are doing multi-threaded string manipulation you are already probably doing something wrong.
I'm honestly not sure where I stand in terms of better string manipulation features in Scratch - certainly they are useful, but figuring out how to implement them myself was honestly one of the best critical thinking exercises I ever received from Scratch. It's important to be able to know how these sorts of operations work on the inside, as it allows you to see how slow they really are - I think people learning to implement them manually is a good experience, and I think that it is not at all bad that Scratch provides it.
I especially think that if we do ever get custom reporters, we should not implement blocks like these - if there were custom reporters (and maybe local variables) than implementing these blocks by hand would have very little negative effect, while it would have a huge educational effect.
Maybe not though. I am using anecdotal evidence here, but I don't think my point is entirely invalid.
Concerning the Bounce blockBecause they seem to be cropping up, let me make an offtopic post to clear up some misconceptions about the bounce block…
It's very difficult to make a general “bounce” block, because what it does is reflect the sprite by mirroring its velocity across the line normal to the surface it hits. (Sorry, it's kind of hard to be exactly clear about what it does, so I'm trying to be specific).
However, it's very likely that this block would work imperfectly, at least for bitmap sprites, because the normal line calculated would be more of an “average” normal line than the actual line.
That's not the only problem, of course - the other problem is the question of what to do when the sprite is intersecting (not merely touching the edge of) the other sprite, and what to do when it's touching or intersecting multiple sprites.
The ‘if on edge, bounce’ block is comparatively simple - it merely means that if the sprite is touching or intersecting an edge, reflect across the line perpendicular to that edge in the middle of the sprite, which is really easy to do.
(The reason intersection works for the edge and not for sprites is because the edge is a single line - it's easy to define where the reflection line is, which is straight in the middle of the sprite. However, if it is intersecting a generally shaped object, you also have to calculate the normal line - and where to calculate that is based on where it is touching, which is ambiguous.)
P.S. If you would like to discuss the bounce block more, please make a new topic or find an old one (I'm pretty sure there is at least one old one you can use).
Workarounds
Note: If you have trouble finding one already in the list then make a post asking about a workaround to a certain block. I'll reply with the workaround if there is one!Rejected Blocks:<[ v] recieved? ::events>____________________
when green flag clicked
set [var v] to [0]
forever
if <(var) = [1]> then
set [var v] to [0]
...
end
end
when I receive [message v]
set [var v] to [1]
wait (0.25) secs
set [var v] to [0]when stop sign clicked ::events hat____________________
when gf clicked
forever
reset timer
end
when [timer v] > (0.1)
...when <> ::events hat
...
when [timer v] > (0.1)
forever
if <> then
...
end
end
NOTICE: I honestly don't want to overkill these posts with workarounds so I'm working on separate projects for workarounds for each category!Motion:change direction by () ::motion___________________
point in direction ((direction) + (number))point towards x: () y: ()::motion___________________
define point towards x: (x) y: (y)
set [deltaX v] to ((x)-(x position))
set [deltaY v] to ((y)-(y position))
if <not<(deltaY)=(0)>> then
if <(deltaY)>(0)> then
point in direction ([atan v] of ((deltaX)/(deltaY))
else
point in direction ((180)+([atan v] of ((deltaX)/(deltaY))))
end
else
if <(deltaX)>(0)> then
point in direction (90)
else
point in direction (-90)
move up (10) steps :: motion
go to x: (([cos v] of (direction)) * ((-1) * (10))) y: (([sin v] of (direction)) * (10))Looks:previous costume ::looks____________________
switch costume to ((costume #) - (1))(showing? :: looks)define hide____________________
hide
set [showing v] to [false ]
define show
show
set [showing v] to [true]
if <(showing)=[true]> then
say [ you can see me!]
else
say [you can't see me!]color :: reporter looks //works for any effect, just change the dropdowns/var names
change [color v] effect by (25)
change [color v] by (25)Sound:
None!Pen:set pen color to hexadecimal input [] :: pen // Applies to all set pen color hex variants
set pen color to ((((R) * (65536)) + ((G) * (256))) + (B))Events:<[ v] recieved? ::events>____________________
when green flag clicked
set [var v] to [0]
forever
if <(var) = [1]> then
set [var v] to [0]
...
end
end
when I receive [message v]
set [var v] to [1]
wait (0.25) secs
set [var v] to [0]when stop sign clicked ::events hat____________________
when gf clicked
forever
reset timer
end
when [timer v] > (0.1)
...when <> ::events hat____________________
...
when [timer v] > (0.1)
forever
if <> then
...
end
endwhen costume switches to [costume1 v] ::events hat
when gf clicked
forever
wait until <([costume name v] of [sprite v]) = [costume name here]>
...
endControl:if <> then {____________________
} else if <> {
} :: control
if <> then
else
if <> then
end
endforever if <> {____________________
} :: control cap
forever
if <> then
end
endforever if <> then {____________________
} else forever {
} :: control cap
forever
if <> then
...
else
...
end
endrepeat () secs {____________________
} :: control
reset timer //this will only work if you're not using the timer elsewhere in your project
repeat until <(timer) = (number)>
...
end
set [old timer v] to (timer)
repeat until (((timer) - (old timer)) > (seconds ::grey) ) //use this if you are using the timer elsewhere in your project
...
endrepeat (1) secs {The best workaround:
} :: controlset [mode v] to (0)Because sometimes the script inside the loop will run longer than it is supposed to, like in this situation:
broadcast [repeat secs v] and wait
when I receive [repeat secs v]
if <(mode)=[0]> then
set [t v] to (((days since 2000)*(86400))+(seconds::grey))
wait until <((days since 2000)*(86400))>(t)>
set [mode v] to [1]
broadcast [repeat secs v]
end
when I receive [repeat secs v]
if <(mode)=[0]> then
forever
...
end
endrepeat (1) secs {____________________
wait (2) secs
} :: control(CloneID::control)set [clone id v] to [0 ]____________________
repeat (...)
create clone of [sprite v]
change [clone id v] by (1)
end
when I start as a clone
if <(clone id) = [1 ]> then
...:: grey
end(# of clones ::control)____________________
define create clone of [object]
create clone of (object)
change [clone # v] by [1] // use this instead of the regular create clone block
define delete clone
change [clone # v] by [-1]
delete this clone // use this instead of the delete clone block
create clone of [...] :: custom
delete clonespawn {____________________
...
} :: control
broadcast [spawn v]
when I receive [spawn v]
...for each((var) : (list :: list):: reporter control) {____________________
...
} :: control
//Workaround:
set [var v] to [] // leave this blank
set [i v] to [1] //since scratch's array index starts in 1
repeat (length of [array v])
set [var v] to (item (i v) of [array v])
... //do your stuffs here
change [i v] by (1)
enddo {
...
} while <sample bool::operators>{
...
}::controlwhen gf clicked
...
forever
if <sample bool::operators> then
...
end
endSensing:(clone? ::sensing)____________________
when I start as a clone
set [clone? v] to [true] //variable for this sprite only(ask in progress? ::sensing)____________________
set [ask v] to [1]
ask [...] and wait
set [ask v] to [0](sprite clicked? ::sensing)____________________
when this sprite clicked
set [clicked v] to [1]
wait until <not <<mouse down?> and <touching [mouse-pointer v] ?> >>
set [clicked v] to [0]day of year :: sensing reporter((days since 2000) - ((365) * ((current [year v]) - (2000))))Operators:
ProjectVariables/Lists:
Project
____________________
Last edited by openPoll (Aug. 23, 2019 15:31:37)
- Truck11111
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
oh nice
- Zro716
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
No need to, and frankly we should avoid making such topics – it lends itself to shutting down new block ideas too quickly, no matter how innocent or complex. We want to encourage vital discussion and gauge the necessity of new blocks rather than judge them based on “how easy” it is according to a workaround made by someone else. Remember that not all Scratchers have the same skill level, and certainly a huge percentage of Scratchers still have a long ways to learn everything about Scratch. We don't want to just hand over the solution, as a workaround list proves, because it does not feel as rewarding as building their own solution step-by-step, and may even be discouraging to see such quip used against them.
Hopefully you understand, to make Scratch the best learning community possible, we need to be mindful of skill differences and try our best to discuss ideas constructively.
Hopefully you understand, to make Scratch the best learning community possible, we need to be mindful of skill differences and try our best to discuss ideas constructively.

- Za-Chary
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
Are you planning to replace the current sticky? Is that what this is?
Make sure you do ask for permission; if you don't get a response within a week, it's probably safe to sticky (I'd ask @Paddle2See just to be sure). Also, I would say to completely create the topic before reporting it to be stickied (that is, make sure you really do have a bunch of workarounds listed here before you report the topic).
Good luck!
Make sure you do ask for permission; if you don't get a response within a week, it's probably safe to sticky (I'd ask @Paddle2See just to be sure). Also, I would say to completely create the topic before reporting it to be stickied (that is, make sure you really do have a bunch of workarounds listed here before you report the topic).
Good luck!
- openPoll
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
No need to, and frankly we should avoid making such topics – it lends itself to shutting down new block ideas too quickly, no matter how innocent or complex. We want to encourage vital discussion and gauge the necessity of new blocks rather than judge them based on “how easy” it is according to a workaround made by someone else. Remember that not all Scratchers have the same skill level, and certainly a huge percentage of Scratchers still have a long ways to learn everything about Scratch. We don't want to just hand over the solution, as a workaround list proves, because it does not feel as rewarding as building their own solution step-by-step, and may even be discouraging to see such quip used against them.
Hopefully you understand, to make Scratch the best learning community possible, we need to be mindful of skill differences and try our best to discuss ideas constructively.
I can see you are a very experienced Scratcher, with your 1000+ posts, and I will try to explain this in the best way that I can (which probably won't be that good).
I really don't want to destroy the new block ideas that so many people present; I want to provide a library of efficient ways to allow people to overcome a block challenge in the event it is not added. Some blocks are really helpful, and have very hard, over-complicated workarounds I want people to have a temporary solution to the non-existent block so that they can use it without actually needing the block there and then.
People don't need to use this list. Not a lot of people (on a broad overview) post block suggestions in the Suggestions forum. In fact, few people post on the Discussion forums at all.
I can, and will, support block suggestions if they are helpful to Scratch even if they have a workaround. Besides, I'd rather let people create their own workaround or use guides to.
Sorry if I offended you.
the current sticky? Is that what this is?That's exactly what my goal is. I have asked permission on Are you planning to replace their profile, and then later I will ask Paddle2See. Thank you!
Make sure you do ask for permission; if you don't get a response within a week, it's probably safe to sticky (I'd ask @Paddle2See just to be sure). Also, I would say to completely create the topic before reporting it to be stickied (that is, make sure you really do have a bunch of workarounds listed here before you report the topic).
Good luck!
- openPoll
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
I feel the need to possibly bump this
- MathlyCat
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
I think this massively overthinking the purpose of such a sticky. No need to, and frankly we should avoid making such topics – it lends itself to shutting down new block ideas too quickly, no matter how innocent or complex. We want to encourage vital discussion and gauge the necessity of new blocks rather than judge them based on “how easy” it is according to a workaround made by someone else. Remember that not all Scratchers have the same skill level, and certainly a huge percentage of Scratchers still have a long ways to learn everything about Scratch. We don't want to just hand over the solution, as a workaround list proves, because it does not feel as rewarding as building their own solution step-by-step, and may even be discouraging to see such quip used against them.
Hopefully you understand, to make Scratch the best learning community possible, we need to be mindful of skill differences and try our best to discuss ideas constructively.
Judging a suggestion based on how easy it is to workaround is legitimate, some blocks don't really serve much purpose if their replacement is only a few extra steps, thus encouraging the end goal of learning the solution. Yes the sticky provides a list of those solutions, why shouldn't they have access? I can make the same argument you've just made about the Scratch Wiki, why reveal how to mock velocity in Scratch when they could learn on their own? It's about exposing these ideas, and not all of them are very simple either.
From my experience I've learned plenty through just looking at the solutions to these blocks, and the concept of working backwards is popular in countries like Japan where Math problems are solved in reverse.
I believe your response is a bit extreme to the actual harmlessness of such a thread.
- MathlyCat
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
congratz on sticky!
- openPoll
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
thanks! congratz on sticky!
- Za-Chary
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
Might I make a suggestion? I think it would be very helpful to post a workaround for rejected suggestions 1.1 and 1.2 found here.
That is, I think a lot of users would like to see workarounds for “when (broadcast) received” and “when stop sign clicked”.
That is, I think a lot of users would like to see workarounds for “when (broadcast) received” and “when stop sign clicked”.
- openPoll
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
here.Okay, thanks! Might I make a suggestion? I think it would be very helpful to post a workaround for rejected suggestions 1.1 and 1.2 found
That is, I think a lot of users would like to see workarounds for “when (broadcast) received” and “when stop sign clicked”.
- codeman1044
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
I'm not sure if you already have this covered. I didn't see it. Let me know if you did cover it.
point towards x: () y: ()::motionThe wiki has a page on this block: https://en.scratch-wiki.info/wiki/Point_Towards_()_(block)#Related_Suggestion
define point towards x: (x) y: (y)
set [deltaX v] to ((x)-(x position))
set [deltaY v] to ((y)-(y position))
if <not<(deltaY)=(0)>> then
if <(deltaY)>(0)> then
point in direction ([atan v] of ((deltaX)/(deltaY))
else
point in direction ((180)+([atan v] of ((deltaX)/(deltaY))))
end
else
if <(deltaX)>(0)> then
point in direction (90)
else
point in direction (-90)
- dogeiscut
-
500+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
<Hash encrypt []> :: operatorsplz how remake
<Hash decrypt []> :: operators
Last edited by dogeiscut (July 9, 2019 03:56:16)
- TailsFanV51
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
move up (10) steps :: motion
go to x: (([cos v] of (direction)) * ((-1) * (10))) y: (([sin v] of (direction)) * (10))
- mrbean757
-
21 posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
do {workaround
...
} while <sample bool::operators>{
...
}::control
when gf clicked
...
forever
if <sample bool::operators> then
...
end
end
pretty simple tbh
well I think I just necroposted
Last edited by mrbean757 (July 11, 2019 21:05:25)
- openPoll
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
Thanks!move up (10) steps :: motion
go to x: (([cos v] of (direction)) * ((-1) * (10))) y: (([sin v] of (direction)) * (10))
- SuperKamekArea
-
500+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
Bounce block Workaround:
define bounce
point in direction ((direction) * (-1))
- openPoll
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
What happens if the direction is 0? Bounce block Workaround:define bounce
point in direction ((direction) * (-1))
- NilsTheBest
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
0 * -1 = -0 = 0What happens if the direction is 0? Bounce block Workaround:define bounce
point in direction ((direction) * (-1))
what about 0?
Edit: oh, right. nvm. then I guess you could just add a “if direction = 0 then point in direction 1” or something.
Last edited by NilsTheBest (July 27, 2019 10:06:37)
- openPoll
-
1000+ posts
(Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪
nvm
Last edited by openPoll (July 27, 2019 10:15:23)
- Discussion Forums
- » Suggestions
-
» (Wanting block workarounds posted!) The Ultimate List of Workarounds and More ②.⓪