Discuss Scratch

Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

This forum topic aims to document a list of common workarounds for blocks which are requested a lot. A workaround is a way to create blocks (usually nonexistant ones) using other ordinary blocks. For example, the block:
previous costume :: looks
can be recreated with the following blocks instead:
switch costume to ( ( costume [number v] :: looks ) - ( 1 ) )

Keep in mind, I'm not saying these blocks shouldn't be added to Scratch because they're workaroundable – I'm just offering a workaround for the short term so people don't think that they can't make their project work without a certain block.


Last edited by Computer_Fizz (Jan. 28, 2020 23:12:31)

Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Motion :: motion hat
point towards x: ( WantedX ) y: ( WantedY ) :: motion
can be recreated by moving a sprite to that x and y then pointing toward that sprite. it can also be recreated with the following (more 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 :: motion
can be recreated with the following code:
point in direction ( ( direction ) - ( 180 ) )

Last edited by Computer_Fizz (Feb. 23, 2020 00:57:37)

Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Looks :: looks hat
previous costume :: looks
can be recreated with the following code:
switch costume to ( ( costume [number v] :: looks ) - ( 1 ) )

Last edited by Computer_Fizz (Oct. 1, 2019 18:47:34)

Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Sound :: sound hat
No sound blocks yet

Last edited by Computer_Fizz (Oct. 1, 2019 18:48:02)

Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Events :: events hat
when ( :: obsolete) clicked :: events hat
...
can be recreated with the following code:
when @greenFlag clicked
forever
set [timer v] to ( timer )
end

when [timer v] > ( timer :: variables )
. . .
———————————————————–
when < . . . > is true :: events hat
can be recreated with the following code:
when @greenFlag 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 < . . . > then
. . .
end
end



Last edited by Computer_Fizz (Oct. 26, 2019 18:57:22)

Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Control :: control hat
while < . . . > {
. . .
} @loopArrow :: control
can be recreated with the following code:
repeat until < not < . . . > >
. . .
end



Last edited by Computer_Fizz (Oct. 1, 2019 18:48:57)

Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Sensing :: sensing hat
< am i a clone ? :: sensing>
can be recreated with the following code:
when @greenFlag clicked
set [am i a clone? v] to [false]
// this variable must be "for this sprite only"
when I start as a clone
set [am i a clone? v] to [true]

if < ( am i a clone? ) = [true] > then
...
———————————————————–
< key [enter v] pressed? >
can be recreated with the following code:
< key ( join [enter] [] ) pressed? >
This can be used for “single-letter” keys, such as ; ' , \ and it also works with enter.
It does not seem to work with any non-single-letter keys besides enter, as shift, control, tab, etc will all fail.

Last edited by Computer_Fizz (March 24, 2020 20:20:52)

Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Operators :: operators hat
< < . . . > xor < . . . > :: operators>
can be recreated with the following code:
< not < < . . . > = < . . . > > >
———————————————————–
 < true :: operators> 
can be recreated with the following code:
 < [1] = [1] > 
———————————————————–
 < false :: operators> 
can be recreated with the following code:
 < [1] > [2] > 
———————————————————–
 ( letters ( start ) through ( end :: variables) of ( string ) :: operators) 
can be recreated with the following code:
set [iterator v] to ( start )
set [result v] to []
repeat ( ( ( end :: variables) - ( start ) ) + ( 1 ) )
set [result v] to ( join ( result ) ( letter ( iterator ) of ( string ) ) )
end
———————————————————–
< ( . . . ) ≥ ( . . . ) :: operators >
can be recreated with the following code:
< not < ( . . . ) < ( . . . ) > >
———————————————————–
< ( . . . ) ≤ ( . . . ) :: operators >
can be recreated with the following code:
< not < ( . . . ) > ( . . . ) > >

Last edited by Computer_Fizz (Oct. 18, 2019 18:13:29)

Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Variables :: variables hat
No variable blocks yet

Last edited by Computer_Fizz (Oct. 1, 2019 18:52:22)

Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

List :: list hat
 ( item ( last v ) of [ list v] ) 
can be recreated with the following code:
 ( item ( length of [ list v] ) of [ list v] ) 

Last edited by Computer_Fizz (Jan. 4, 2020 05:02:57)

Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Guide for contributing to this thread:
  • There must be several instances of the workaround you are creating being suggested as an official block. Not necessarily rejected, but suggested.
  • Workarounds are chosen with the priority of : most functionality, least blocks, least variables. There may be exceptions to this very rarely.
  • Use a blank scratch project to test out both the workaround listed and your workaround to see if it works to the standards
  • Use the ScratchBlocks feature to let me know what to work around is and I will review it.
  • If you are replacing an already existing workaround, explain what yours does better than the already existing one
  • Harassing me will not result in your workaround being added.
  • Posts that do not contribute to the thread will be ignored.

Last edited by Computer_Fizz (Jan. 13, 2020 19:20:03)

54329
Scratcher
500+ posts

Workarounds to frequently suggested blocks

Congrats on sticky!

Click Here To Get Free Loves, Favorites and Follows!!!
(Not edited by moderator - don't impersonate a moderator by adding this moderation since a moderator didn't moderate to add this moderation in.)

;
Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

54329 wrote:

Congrats on sticky!
:​O I got stickied. My first sticky :​) Do you have any ideas for improvement?

Last edited by Computer_Fizz (Oct. 1, 2019 05:18:01)

54329
Scratcher
500+ posts

Workarounds to frequently suggested blocks

Computer_Fizz wrote:

54329 wrote:

Congrats on sticky!
:​O I got stickied. My first sticky :​) Do you have any ideas for improvement?
Perhaps add a title to each post. Ex: On this reply, title it with the category of blocks it is (like how you have sounds, lists, etc). Otherwise looks good!

Click Here To Get Free Loves, Favorites and Follows!!!
(Not edited by moderator - don't impersonate a moderator by adding this moderation since a moderator didn't moderate to add this moderation in.)

;
WindOctahedron
Scratcher
1000+ posts

Workarounds to frequently suggested blocks

You can also add this to Operators (I can't easily quote it, because the thread is closed).

The message above may contain wrong information, rude remarks, or something embarrassing to my current self. In this case, please ignore it and remember that I likely wrote it back when I didn't know what “respect” truly meant. I really hate thinking about it again.
Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Thank you both for the feedback! I have now added titles to the posts. I've also looked at the operators boolean but I'm not sure if it's a good idea to add it. Is it requested enough that it would be worthwhile in a mainstream sticky? (I may consider making a second non-sticky thread and linking to it from here for less suggested workarounds)
openPoll
Scratcher
1000+ posts

Workarounds to frequently suggested blocks

Well done on this post! It's very nice, simple and intuitive.

Moi? Whaddya wahnt from moi?

——

Inactive Scratcher • making memes wen??? • define defineI have Robux >:)1,000+ hours on Splatoon 2 • 250+ hours on Pokémon White • 100+ hours on MinecraftAn 8 bit remix I love • i have lots game • too lazy to make rainbows • still a proud Windows 7 user
Beamy68
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Nice! I like the idea!

Also congrats on getting stickied even though I didn't find this through the sticky !


Here's one for
Sensing :: sensing
Better Timer(s)! the (s) is there because you can make multiple in one project!
Using the
when ( :: obsolete) clicked :: events hat
Code :: custom
can be recreated with the following code:
when @greenFlag clicked
forever
reset timer
end

when [timer v] > (0.1)
Code :: custom
// Now we can create multiple timer variables that run even when the project is stopped like the normal timer.


when green flag clicked
forever
change [timer1 v] by [0.001]
change [timer2 v] by [0.001]
change [timer3 v] by [0.001]
end

when [timer v] > (0.1)
forever
change [timer1 v] by [0.001]
change [timer2 v] by [0.001]
change [timer3 v] by [0.001]
end

define reset timer (timer #)
if < (timer #) = [1]> then // You'll need this to reset these timers
set [timer1 v] to [0]
end
if < (timer #) = [2]> then
set [timer2 v] to [0]
end
if < (timer #) = [3]> then
set [timer3 v] to [0]
end

Extra things you can do with this that the normal timer can't

This can allow for: Hiding and Showing these timers.
hide variable [timer1 v]
show variable [timer2 v]

Choosing intervals for each timer!
when @greenFlag or (::obselete) clicked :: events hat
forever
change [timer1 v] by [100]
change [timer2 v] by [0.1289118201]
change [timer3 v] by [1]
end

Doing multiple workarounds that all use timers in a single project!

// Such as
repeat for () secs {
...
} :: control

// by
reset timer (1) :: custom
repeat until <(timer1) = [secs]>
...
end
Choosing a starting and ending point for the timers!
when green flag clicked
wait until <(timer1) = [45]>
repeat until <(timer2) = [3]>
change [timer2 v] by (0.001)
end
Defining how long a second is for each timers!

when @greenFlag or (::obselete) clicked :: events hat
forever
change [timer1 v] by (1)
wait (5) secs
end

Assigning a timer to a specific sprite!

AND TONS MORE!
This took me 5 hours and I came up with this as I went, if this ends up not working for you, please let me know!

Last edited by Beamy68 (Oct. 7, 2019 01:53:11)


Post Goal:


Motion::motion
Looks::looks
Sound::sound
Pen::pen
Events::events
Control::control
Sensing::sensing
Operators::operators
Variables::variables
List::list
More Blocks::custom
bemy
Beamy68
Scratcher
100+ posts

Workarounds to frequently suggested blocks

Here is a workaround for
previous costume :: looks
Create the variable “c”
switch costume to (c) // This variable is set to "previous costume"
That's it!
I figured this out in my project Tests which you should check out!

Post Goal:


Motion::motion
Looks::looks
Sound::sound
Pen::pen
Events::events
Control::control
Sensing::sensing
Operators::operators
Variables::variables
List::list
More Blocks::custom
bemy
Computer_Fizz
Scratcher
100+ posts

Workarounds to frequently suggested blocks

your multiple timers thing while cool as a concept 1) count too fast 2) isn't really a workaround (this is mostly intended for blocks). i may consider adding a link to a working version though.

i already have a previous costume workaround, so what's yours besides requiring a variable?

however, i will add the key enter pressed thing from your tests project

Powered by DjangoBB