shradibop

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 \/ \/ \/ \/

shradibop

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)

shradibop

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

shradibop

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.

shradibop

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) = []>

shradibop

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

shradibop

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.

shradibop

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))

shradibop

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)

Ihatr

Nice

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

edited

Vibrato

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

shradibop

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.

Ihatr

Vibrato wrote:

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

fdreerf

Vibrato wrote:

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

Ihatr

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

Super_Scratch_Bros20

Congrats on the sticky!

shradibop

Super_Scratch_Bros20 wrote:

Congrats on the sticky!

Thanks!

Ihatr

Stickied

fdreerf

A fairly unexpected sticky owner, but a welcome one.

Vercte

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