Discuss Scratch
- Discussion Forums
- » Suggestions
- » Ultimate List of Workarounds And More
- DaEpikDude
-
1000+ posts
Ultimate List of Workarounds And More
Maybe put both in: the listed one is understandable, but this one is shorter?The workaround listed is better because it's easier to understand; you don't need hex knowledge to be able to use it.within topic bump i guess??? I'd like to point out that there's a better workaround for setting pen colour to hex input:set pen color to (join [0x][hex input])//this is the color picker, not the number inputThis is more compact and easier to interpret at a glance (mainly due to the 0x).
- Jonathan50
-
1000+ posts
Ultimate List of Workarounds And More
The workaround is supposed to be for hexadecimal input though. The workaround listed is better because it's easier to understand; you don't need hex knowledge to be able to use it.

- Charles12310
-
1000+ posts
Ultimate List of Workarounds And More
All you need to do is define variables R, G, and B.The workaround is supposed to be for hexadecimal input though. The workaround listed is better because it's easier to understand; you don't need hex knowledge to be able to use it.
- DaEpikDude
-
1000+ posts
Ultimate List of Workarounds And More
They bring up a good point: if someone wanted a hex input, there's a 99% chance they have hex knowledge.All you need to do is define variables R, G, and B.The workaround is supposed to be for hexadecimal input though. The workaround listed is better because it's easier to understand; you don't need hex knowledge to be able to use it.
- Sharp-Shark
-
22 posts
Ultimate List of Workarounds And More
What about this? :
<True::operators>
<[1]=[1]>
<False::operators>
<[1] = [0]>
<<A> xor <B>::operators>
<<<A> or <B>> and <not<<A> and <B>>
Last edited by Sharp-Shark (Oct. 9, 2017 01:13:00)
- Charles12310
-
1000+ posts
Ultimate List of Workarounds And More
for each [] in [list v] {
} :: list
set [count v] to [0]
set [count2 v] to [0]
repeat (length of [list v])
change [count v] by (1)
if <(item (count) of [list v]) = (item needed)> then
change [count2 v] by (1)
end
end
if <(count2) > [0]> then
repeat (count2)
...
end
end
Last edited by Charles12310 (Nov. 23, 2017 15:10:23)
- DaEpikDude
-
1000+ posts
Ultimate List of Workarounds And More
Uh, don't you mean…<(letter (count) of [list v]) = (item needed)>
<(item (count) of [list v]) = (item needed)>
- MathlyCat
-
1000+ posts
Ultimate List of Workarounds And More
It doesn't matter.The workaround is supposed to be for hexadecimal input though. The workaround listed is better because it's easier to understand; you don't need hex knowledge to be able to use it.
if you actually read the sticky you would notice the hex workaround already there?
- Jonathan50
-
1000+ posts
Ultimate List of Workarounds And More
No, it's not. There's just this It doesn't matter.
if you actually read the sticky you would notice the hex workaround already there?
which might be a better workaround, but it's not for hex inputset pen color to hexadecimal input [] :: pen // Applies to all set pen color hex variants
set pen color to ((((R) * (65536)) + ((G) * (256))) + (B))

- DaEpikDude
-
1000+ posts
Ultimate List of Workarounds And More
Isn't another potential workaround to that…<<A> xor <B>::operators>
<<<A> or <B>> and <not<<A> and <B>>
<<> xor <>::operators>Because if both inputs are true or false it returns false, and if they're different (i.e. 1 true 1 false) it returns true.
<not <<bool1> = <bool2>>>
- neeb132
-
500+ posts
Ultimate List of Workarounds And More
THIS TEXT IS BIGPlease don't spam or necropost.
- -ShadowOfTheFuture-
-
1000+ posts
Ultimate List of Workarounds And More
THIS TEXT IS BIGPlease don't spam or necropost.
I thought you can't necro on a sticky…
But still though, it was spam.
- -ShadowOfTheFuture-
-
1000+ posts
Ultimate List of Workarounds And More
Some workarounds for existing blocks:
I'm not sure if all of them work…
set x to (0)
go to x: (0) y: (y position)
( ::#000000)
set y to (0)
go to x: (x position) y: (0)
( :: #000000)
next costume
switch costume to ((costume #) + (1))
( :: #000000)
move (10) steps
go to x: ((x position) + (([sin v] of (direction)) * (10))) y: ((y position) + (([cos v] of (direction)) * (10)))
( :: #000000)
forever
end
when green flag clicked
loop :: custom
define loop
...
loop
I'm not sure if all of them work…
- TailsFanV51
-
1000+ posts
Ultimate List of Workarounds And More
This is a workaround for
repeat for (. . . :: grey) secs {
} :: control
:: reporter #000
when gf clicked
set [wait v] to (0)
broadcast [wait v]
repeat until <(wait) = (1)>
...
end
set [wait v] to (0)
:: reporter #000
when i receive [wait v]
wait (. . . :: grey) secs
set [wait v] to (1)
- neeb132
-
500+ posts
Ultimate List of Workarounds And More
This is a workaround forrepeat for (. . . :: grey) secs {
} :: control
:: reporter #000
when gf clicked
set [wait v] to (0)
broadcast [wait v]
repeat until <(wait) = (1)>
...
end
set [wait v] to (0)
:: reporter #000
when i receive [wait v]
wait (. . . :: grey) secs
set [wait v] to (1)
Cool! This is very helpful!
- Charles12310
-
1000+ posts
Ultimate List of Workarounds And More
You can also do:This is a workaround forrepeat for (. . . :: grey) secs {
} :: control
:: reporter #000
when gf clicked
set [wait v] to (0)
broadcast [wait v]
repeat until <(wait) = (1)>
...
end
set [wait v] to (0)
:: reporter #000
when i receive [wait v]
wait (. . . :: grey) secs
set [wait v] to (1)
Cool! This is very helpful!
set [repeat timer v] to (timer)
repeat until <((timer) - (repeat timer)) > [insert any amount of seconds here]>
...
end
- AmazingMech2418
-
1000+ posts
Ultimate List of Workarounds And More
It would actually be this:Isn't another potential workaround to that…<<A> xor <B>::operators>
<<<A> or <B>> and <not<<A> and <B>><<> xor <>::operators>Because if both inputs are true or false it returns false, and if they're different (i.e. 1 true 1 false) it returns true.
<not <<bool1> = <bool2>>>
<<not <<bool1::grey> and <bool2::grey>>> and <<bool1::grey> or <bool2::grey>>>You were thinking of nand.
Last edited by AmazingMech2418 (Nov. 9, 2017 03:02:17)
- DaEpikDude
-
1000+ posts
Ultimate List of Workarounds And More
…no…It would actually be this:Isn't another potential workaround to that…<<A> xor <B>::operators>
<<<A> or <B>> and <not<<A> and <B>><<> xor <>::operators>Because if both inputs are true or false it returns false, and if they're different (i.e. 1 true 1 false) it returns true.
<not <<bool1> = <bool2>>><<not <<bool1::grey> and <bool2::grey>>> and <<bool1::grey> or <bool2::grey>>>You were thinking of nand.
Think about it:
Say you have “A xor B”. Imagine you used “not A = B”.
If A and B are true:
A = B, so it returns false.
If A and B are false:
A = B, so it returns false.
If A is true and B is false:
A != B, so now it returns true, same for if B is true and A is false.
- MathlyCat
-
1000+ posts
Ultimate List of Workarounds And More
Well if it's so simple wouldn't they know it or at least try it?No, it's not. There's just this It doesn't matter.
if you actually read the sticky you would notice the hex workaround already there?which might be a better workaround, but it's not for hex inputset pen color to hexadecimal input [] :: pen // Applies to all set pen color hex variants
set pen color to ((((R) * (65536)) + ((G) * (256))) + (B))
I'm not going to add the workaround simply because if the person who needs to use it understands the logic, they can use the base methods to ultimately achieve what they need.…no…It would actually be this:Isn't another potential workaround to that…<<A> xor <B>::operators>
<<<A> or <B>> and <not<<A> and <B>><<> xor <>::operators>Because if both inputs are true or false it returns false, and if they're different (i.e. 1 true 1 false) it returns true.
<not <<bool1> = <bool2>>><<not <<bool1::grey> and <bool2::grey>>> and <<bool1::grey> or <bool2::grey>>>You were thinking of nand.
Think about it:
Say you have “A xor B”. Imagine you used “not A = B”.
If A and B are true:
A = B, so it returns false.
If A and B are false:
A = B, so it returns false.
If A is true and B is false:
A != B, so now it returns true, same for if B is true and A is false.
Again, I want to have a separation of learning and workarounds
- whitelily1196
-
100+ posts
Ultimate List of Workarounds And More
thanks alxephan
You may have noticed that I have decided to re-do this entire sticky. Please be aware, the Workarounds still exist.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) // fixed
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).