This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-07-29 15:17:19

MabonBaladevaKain
Scratcher
Registered: 2010-07-25
Posts: 80

Else if

I've come to a spot where I need Else or an Else If and there are no such blocks in Scratch. Has someone created an addition with those blocks in them?

There's If and If Else, but no Else or Else If ... is there a way for me to add Else blocks to Scratch easily or is it fairly complex and not worth the effort?

Offline

 

#2 2010-07-29 15:20:26

JeanTheFox
Scratcher
Registered: 2010-06-14
Posts: 1000+

Re: Else if

I think I can help you; I'll get back to you once I've finished.  big_smile


http://i51.tinypic.com/20gcn5j.png

Offline

 

#3 2010-07-29 15:23:47

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Else if

You can alway's stack If-else blocks inside each other. But no, Scratch doesn't support this yet. It has been suggested Here before though.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#4 2010-07-29 15:29:00

JeanTheFox
Scratcher
Registered: 2010-06-14
Posts: 1000+

Re: Else if

It doesn't seem like it works too well.  sad

For now I think you should just go with what you already have.


http://i51.tinypic.com/20gcn5j.png

Offline

 

#5 2010-07-29 15:29:08

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Else if

MabonBaladevaKain wrote:

is there a way for me to add Else blocks to Scratch easily or is it fairly complex and not worth the effort?

Extremely complex (but possible) and not worth the effort at all. Just put an 'if' into the bottom space in an 'if else.'

If you really want to make an else if block, reply back.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#6 2010-07-29 15:30:15

JeanTheFox
Scratcher
Registered: 2010-06-14
Posts: 1000+

Re: Else if

ScratchReallyROCKS wrote:

Extremely complex (but possible) and not worth the effort at all.

I just learned that the hard way  big_smile


http://i51.tinypic.com/20gcn5j.png

Offline

 

#7 2010-07-29 16:20:26

MabonBaladevaKain
Scratcher
Registered: 2010-07-25
Posts: 80

Re: Else if

I'd also like to see some While blocks .... do those exist somewhere?
Does one of those things like BYOB or Panther or that other one have these sort of blocks?

Offline

 

#8 2010-07-29 17:36:46

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Else if

MabonBaladevaKain wrote:

I'd also like to see some While blocks .... do those exist somewhere?
Does one of those things like BYOB or Panther or that other one have these sort of blocks?

Instead of While, Scratch has Repeat Until. Just put the  condition you need inside a "Not" block. So

Code:

While (condition)
    Do whatever
EndWhile

In Scratch would be:

Code:

Repeat until NOT(condition)
    Do whatever
EndRepeat

Just one of those things with a simple workaround.

Last edited by Harakou (2010-07-29 17:37:29)


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#9 2010-07-29 17:46:18

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Else if

Harakou wrote:

MabonBaladevaKain wrote:

I'd also like to see some While blocks .... do those exist somewhere?
Does one of those things like BYOB or Panther or that other one have these sort of blocks?

Instead of While, Scratch has Repeat Until. Just put the  condition you need inside a "Not" block. So

Code:

While (condition)
    Do whatever
EndWhile

In Scratch would be:

Code:

Repeat until NOT(condition)
    Do whatever
EndRepeat

Just one of those things with a simple workaround.

Uh, a while block is just the forever if block. No workarounds needed.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#10 2010-07-29 17:55:36

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Else if

ScratchReallyROCKS wrote:

Harakou wrote:

MabonBaladevaKain wrote:

I'd also like to see some While blocks .... do those exist somewhere?
Does one of those things like BYOB or Panther or that other one have these sort of blocks?

Instead of While, Scratch has Repeat Until. Just put the  condition you need inside a "Not" block. So

Code:

While (condition)
    Do whatever
EndWhile

In Scratch would be:

Code:

Repeat until NOT(condition)
    Do whatever
EndRepeat

Just one of those things with a simple workaround.

Uh, a while block is just the forever if block. No workarounds needed.

Nope, because
1) Forever if constantly checks for the given condition once it is executed.
2) Other scripts can't be placed under it.

While/repeat until checks for the given condition only as it reaches that point, and when the condition is no longer true, moves on to the scripts after it and stops checking. Forever if is actually equivalent to

Code:

Forever
    If (condition)
        code
    EndIf
EndForever

Last edited by Harakou (2010-07-29 17:58:01)


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#11 2010-07-29 21:09:19

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Else if

Harakou wrote:

ScratchReallyROCKS wrote:

Harakou wrote:


Instead of While, Scratch has Repeat Until. Just put the  condition you need inside a "Not" block. So

Code:

While (condition)
    Do whatever
EndWhile

In Scratch would be:

Code:

Repeat until NOT(condition)
    Do whatever
EndRepeat

Just one of those things with a simple workaround.

Uh, a while block is just the forever if block. No workarounds needed.

Nope, because
1) Forever if constantly checks for the given condition once it is executed.
2) Other scripts can't be placed under it.

You always find a flaw in my theorizing.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#12 2010-07-29 21:12:04

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Else if

ScratchReallyROCKS wrote:

Harakou wrote:

ScratchReallyROCKS wrote:


Uh, a while block is just the forever if block. No workarounds needed.

Nope, because
1) Forever if constantly checks for the given condition once it is executed.
2) Other scripts can't be placed under it.

You always find a flaw in my theorizing.

Hey, I'm just sayin'  tongue

Wait, is that a bad thing, or you mean I'm helpful at catching mistakes? I hope it's the second, I don't mean to be mean.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#13 2010-07-29 21:30:31

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Else if

Harakou wrote:

ScratchReallyROCKS wrote:

Harakou wrote:


Nope, because
1) Forever if constantly checks for the given condition once it is executed.
2) Other scripts can't be placed under it.

You always find a flaw in my theorizing.

Hey, I'm just sayin'  tongue

Wait, is that a bad thing, or you mean I'm helpful at catching mistakes? I hope it's the second, I don't mean to be mean.

It was more meant to be a joke. (I should have added a  tongue )


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#14 2010-07-29 21:34:54

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Else if

ScratchReallyROCKS wrote:

It was more meant to be a joke. (I should have added a  tongue )

Oh, I see now. Let me correct your post for you then:

ScratchReallyROCKS wrote:

You always find a flaw in my theorizing.  tongue

tongue


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#15 2010-07-29 21:51:19

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Else if

Harakou wrote:

ScratchReallyROCKS wrote:

It was more meant to be a joke. (I should have added a  tongue )

Oh, I see now. Let me correct your post for you then:

ScratchReallyROCKS wrote:

You always find a flaw in my theorizing.  tongue

tongue

tongue  (uhh, my tongue is getting dry from sticking it out so much  tongue  (grr! there I go again!) )


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#16 2010-07-29 22:34:33

MabonBaladevaKain
Scratcher
Registered: 2010-07-25
Posts: 80

Re: Else if

:p

I'm stuck already.
Pretty bad at Scratch, heh.
Klik & Play is easier.

Thanks for advice on the While thing ... it sorta confuses me though, wonder why they didn't just include a while ... <shrugs>

Oh, I have another question ... how can I make it so when pointing in a direction, the sprite does not flip upside down?
Do I have to make a left facing sprite and a right facing sprite and use extra code?
Or is there a better way?

Offline

 

#17 2010-07-29 22:44:47

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Else if

MabonBaladevaKain wrote:

Oh, I have another question ... how can I make it so when pointing in a direction, the sprite does not flip upside down?
Do I have to make a left facing sprite and a right facing sprite and use extra code?
Or is there a better way?

Yes, there is a better way. On the top of the script panel, above the tabs for scripts, costumes and sounds, there is a picture of the sprite. On the left of it are 3 buttons. Click the second button down and you should be all set!

EDIT: 14 posts and I'm at 1000!  big_smile

Last edited by ScratchReallyROCKS (2010-07-29 22:45:18)


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#18 2010-07-29 23:23:50

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Else if

MabonBaladevaKain wrote:

:p

I'm stuck already.
Pretty bad at Scratch, heh.
Klik & Play is easier.

Thanks for advice on the While thing ... it sorta confuses me though, wonder why they didn't just include a while ... <shrugs>

Oh, I have another question ... how can I make it so when pointing in a direction, the sprite does not flip upside down?
Do I have to make a left facing sprite and a right facing sprite and use extra code?
Or is there a better way?

It depends. Do you want it to face only left/right, or just spin 360 degress around, but not be upside down? If the former, then use ScratchReallyROCKS's suggestion. If the latter, then yes, make another costume that is upside down (copy the original costume and use the vertical flip button in the sprite editor), and use something like this:

Code:

When Green Flag Clicked
Forever
If <Direction < 0>
    Switch to costume upside_down
else
    Switch to costume normal
EndIf

Last edited by Harakou (2010-07-29 23:24:54)


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#19 2010-07-29 23:48:38

MabonBaladevaKain
Scratcher
Registered: 2010-07-25
Posts: 80

Re: Else if

Sweet! .. I didn't notice those buttons were there.
Thank you ScratchReallyROCKS!

Kewl, that could come in handy later on.
Thank you Harakou!

You guys are great  smile

Offline

 

#20 2010-07-29 23:57:55

ScratchReallyROCKS
Scratcher
Registered: 2009-04-22
Posts: 1000+

Re: Else if

MabonBaladevaKain wrote:

Sweet! .. I didn't notice those buttons were there.
Thank you ScratchReallyROCKS!

Kewl, that could come in handy later on.
Thank you Harakou!

You guys are great  smile

You're welcome! I only come to the's forums to help.


http://imageshack.us/a/img694/3806/sigmad.png

Offline

 

#21 2010-07-30 01:02:56

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Else if

MabonBaladevaKain wrote:

Sweet! .. I didn't notice those buttons were there.
Thank you ScratchReallyROCKS!

Kewl, that could come in handy later on.
Thank you Harakou!

You guys are great  smile

No problem. That's why we're here.  smile


http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

Board footer