Discuss Scratch

shradibop
Scratcher
100+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Hello! My name is @shradibop, and I'm the new host of this topic.

In the suggestions forum, you might have a suggestion for a block. But, if it gets rejected, have no fear! On this topic, you can easily ask for workarounds for block. Still don't get it? Confused as to why you can't just get the block added? @Za-Chary is here to explain that to you.

Za-Chary wrote:

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.

It's a useful topic that can also get you more experienced with coding! Don't be afraid to ask/answer questions, the Scratch community is here to help!

Find the old ones here:
Computer_Fizz Forum
BearSlothCoding Forum

Below are some things you can use without having to ask for a workaround \/ \/ \/ \/

Last edited by shradibop (Feb. 19, 2021 00:51:44)


hey. what's good

hopefully, i'm having fun right now
shradibop
Scratcher
100+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Motion

_______________________________________________________________________________________________

point towards x:() y:() :: motion
This 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
go to x:(0) y:(0)
(for the other sprite)
when green flag clicked
forever
point towards [X v]
end
Method 2:
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 :: motion
can be made with this script:
point in direction ((direction) - (180)

Last edited by shradibop (Oct. 2, 2020 15:57:02)


hey. what's good

hopefully, i'm having fun right now
shradibop
Scratcher
100+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Looks
_______________________________________________________________________________________________

previous costume :: looks
This 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 :: reporter
Can 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

hey. what's good

hopefully, i'm having fun right now
shradibop
Scratcher
100+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Sound
_______________________________________________________________________________________________

next sound ::sound
can be done with this:
when gf clicked
forever
play sound (sound#) until done
end

change [sound# v] by (1)

Similarly,
previous sound ::sound
can be done with this:
when gf clicked
forever
play sound (sound#) until done
end

change [sound# v] by (-1)
_______________________________________________________________________________________________

pause sound :: sound
or
resume sound :: sound
can 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.

hey. what's good

hopefully, i'm having fun right now
shradibop
Scratcher
100+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Events
_______________________________________________________________________________________________

when ( :: more blocks) clicked :: hat :: events
A 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 :: events
can 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) = []>

hey. what's good

hopefully, i'm having fun right now
shradibop
Scratcher
100+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Control
_______________________________________________________________________________________________

 while < . . . > { . . . } @loopArrow :: control 
can 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 shradibop (Oct. 5, 2020 14:15:35)


hey. what's good

hopefully, i'm having fun right now
shradibop
Scratcher
100+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Sensing
_______________________________________________________________________________________________

am i a clone? :: boolean :: sensing
can 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 work with the shift, control, tab, etc. keys.

Workaround for
turbo mode?::boolean sensing

when gf clicked
forever
repeat(10)
move(0)steps
end
if<(timer)<[.1]>then
set[turbo mode? v]to<[1]=[1]>
else
set[turbo mode? v]to<[0]=[1]>

Last edited by shradibop (March 10, 2021 16:38:34)


hey. what's good

hopefully, i'm having fun right now
shradibop
Scratcher
100+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Operator
_______________________________________________________________________________________________

(this) xor (that) :: boolean :: operators
can be made with this:
<not<(this) = (that)>>
_______________________________________________________________________________________________

true :: boolean :: operators 
can be made with this:
<[1]=[1]>
_______________________________________________________________________________________________

false :: boolean :: operators 
can be made with this:
<[1]>[2]>
_______________________________________________________________________________________________

letters (start) through (end :: variables) of (string) :: reporter :: operators
can 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 :: operators
can be done with:
<not <()<()>>
_______________________________________________________________________________________________

() ≤ () :: boolean :: operators
can 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))

hey. what's good

hopefully, i'm having fun right now
shradibop
Scratcher
100+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Variable
_______________________________________________________________________________________________

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)

hey. what's good

hopefully, i'm having fun right now
Ihatr
Scratcher
1000+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Nice

Also, here's a project containing all these workarounds, for easy backpacking and using.

edited

Last edited by Ihatr (Oct. 8, 2020 13:54:44)



this is a link
Vibrato
Scratcher
1000+ posts

Helpful Workarounds for Frequently Suggested Blocks!

This is the top sticky right now. Are you trying to make a new one?

I understand about indecision

Captain Disillusion wrote:

In software development, deleting, it's just a concept. Some software might have a delete button and when you click it a thing disappears, but it's not really gone. Okay, it's not gone from the memory.




fdeerf wrote:

chances are nobody will find your account, so nobody will follow you.



Za-Chary wrote:

I'm going to close this suggestion as it is technically implemented and rejected at the same time.
shradibop
Scratcher
100+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Ihatr wrote:

Nice

Could you link this project in the sticky? It contains lots of these blocks, just placed into a project for easy backpacking, so they don't have to copy all the blocks. I made that project specifically to be included in the sticky.

Well, you just linked it. But it's helpful, and you should stick around to help people out with their projects.

Last edited by shradibop (Oct. 2, 2020 16:17:24)


hey. what's good

hopefully, i'm having fun right now
Ihatr
Scratcher
1000+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Vibrato wrote:

This is the top sticky right now. Are you trying to make a new one?
BearSlothCoding gave him permission to create it.


this is a link
fdreerf
Scratcher
1000+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Vibrato wrote:

This is the top sticky right now. Are you trying to make a new one?
BSC no longer wants to own it.

Hyped for MS-DOS 11.0
Ihatr
Scratcher
1000+ posts

Helpful Workarounds for Frequently Suggested Blocks!

shradibop wrote:

Ihatr wrote:

Nice

Could you link this project in the sticky? It contains lots of these blocks, just placed into a project for easy backpacking, so they don't have to copy all the blocks. I made that project specifically to be included in the sticky.

Well, you just linked it. But it's helpful, and you should stick around to help people out with their projects.
I meant for it to be included around the top, specifically near the introduction. Thanks for the comment on it though


this is a link
Super_Scratch_Bros20
Scratcher
1000+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Congrats on the sticky!


shradibop
Scratcher
100+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Super_Scratch_Bros20 wrote:

Congrats on the sticky!

Thanks!

hey. what's good

hopefully, i'm having fun right now
Ihatr
Scratcher
1000+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Stickied


this is a link
fdreerf
Scratcher
1000+ posts

Helpful Workarounds for Frequently Suggested Blocks!

A fairly unexpected sticky owner, but a welcome one.

Hyped for MS-DOS 11.0
Vercte
Scratcher
500+ posts

Helpful Workarounds for Frequently Suggested Blocks!

Good job on adopting the sticky!
this probably will be the only time I'll see today as the OP timestamp on a sticky

not that active anymore

_________










Seriously. Period. I'm not that active anymore. I've recently realised that Scratch, while good for basic programing, is just not that versatile for making games. So, I've moved on to engines like Roblox and Stencyl, which are entirely different from scratch. Farewell.

Powered by DjangoBB