Discuss Scratch

appdeveloper51251
New Scratcher
2 posts

More than one if for if then else

Currently, the scratch block for if then else looks like this:
ifthenelse
How about a block that lets you have multiple ifs but 1 else? For example, if there are “ranks” in a game you can purchase, (1 sprite for each rank which you click on to purchase), then you have a main sprite (a box which you ranked up), then the block would have multiple selections for if.
https://pasteboard.co/GPIsmcW.png
^^ what block could look like
And you could add more “if then”'s.
Excuse my terrible editing, and any unorthodox things I've said in my post, this is my first time on the forum
If you still don't understand, then basically I have a game with ranks and a box. You click the box for money and get ranks with money, which ranks up the box and gives you more money. I have a sprite for each rank which you click on to upgrade. That sets the variable for the rank to 1 (1 being true, 0 being false). I click the sprite and it changes the variable by 1. On the sprite for the box, the code says “if <variable = 1” then do this, else do this. I can do that, but I have multiple “rank” sprites and I can't code that properly, or at least to my knowledge. If there is a way to do this already, forgive me, I'm new to this. It would be nice to have a quick response, I have a deadline for this project in about a week.

Cheers,
appdeveloper51251 (Darren/Victor, we share an account for school)

Last edited by appdeveloper51251 (Oct. 19, 2017 22:57:51)

DaEpikDude
Scratcher
1000+ posts

More than one if for if then else

Rank?
Purchase?
What??

Wouldn't it be easier to just “extend” it if you right click?
Also you can use scratchblocks, like so:
if...then. . .else. . .else. . .
Looks much better.
-ShadowOfTheFuture-
Scratcher
1000+ posts

More than one if for if then else

No support. The workaround is really simple.

ifthen. . .elseifthen. . .elseifthen. . .else. . .
FUTSync
Scratcher
100+ posts

More than one if for if then else

If i'm understanding you correctly, why cant you just repeat the if/else block? and in every else block, do the thing you wanted?

ifthing1thendothing1elsedotheelsestatementifthing2thendothing2elsedotheelsestatement
DaEpikDude
Scratcher
1000+ posts

More than one if for if then else

aaroncavanagh wrote:

If i'm understanding you correctly, why cant you just repeat the if/else block? and in every else block, do the thing you wanted?

ifthing1thendothing1elsedotheelsestatementifthing2thendothing2elsedotheelsestatement
Because that's different to what an else if is.
If thing1 is true, it does the first statement, and then the else of the second.
If thing2 is true, it does the else of the first and then the second.
If the second if else was in the first it'd work, but that doesn't work.
appdeveloper51251
New Scratcher
2 posts

More than one if for if then else

Sorry for the useless thread then, thank you for the workaround!
FUTSync
Scratcher
100+ posts

More than one if for if then else

DaEpikDude wrote:

aaroncavanagh wrote:

If i'm understanding you correctly, why cant you just repeat the if/else block? and in every else block, do the thing you wanted?

ifthing1thendothing1elsedotheelsestatementifthing2thendothing2elsedotheelsestatement
Because that's different to what an else if is.
If thing1 is true, it does the first statement, and then the else of the second.
If thing2 is true, it does the else of the first and then the second.
If the second if else was in the first it'd work, but that doesn't work.


ifthing1thendothing1elseifthing2thendothing2elsedotheelsestatement
Charles12310
Scratcher
1000+ posts

More than one if for if then else

-ShadowOfTheFuture- wrote:

No support. The workaround is really simple.

ifthen. . .elseifthen. . .elseifthen. . .else. . .
Please explain:

ifthenelseifthenelseifthenelseifthenelseifthenelseifthenelseifthenelseifthenelseifthenelseifthenelseifthenelseifthenelseifthenelseifthenelseifthenelse
You can see now that in this instance, it doesn't seem to be easy anymore. You have to drag one block, and another, and another, and another…

Also, it takes up too much space causing more scrolling to see other scripts, which can get worse if the scripts inside them were big.

ifthenelseifelseifelseifelseifelseifelseifelseifelseifelseifelseifelse
You can see here that it looks much more organized, and much more shorter than the other. I doubt this would be easy if the user had to make a lot of ifs and elses.

I'm supporting for this reason.
FUTSync
Scratcher
100+ posts

More than one if for if then else

Charles12310 wrote:

-ShadowOfTheFuture- wrote:

No support. The workaround is really simple.

ifthen. . .elseifthen. . .elseifthen. . .else. . .
Please explain:


You can see now that in this instance, it doesn't seem to be easy anymore. You have to drag one block, and another, and another, and another…

Also, it takes up too much space causing more scrolling to see other scripts, which can get worse if the scripts inside them were big.

ifthenelseifelseif
You can see here that it looks much more organized, and much more shorter than the other. I doubt this would be easy if the user had to make a lot of ifs and elses.

I'm supporting for this reason

(snipped to shorten quote).
Just because you have to ‘drag and drop’ a lot of times & that its ‘more organised’ doesn't mean it should be implemented.

This block would rarely be used, and very rarely that many times, the work around is extremely simple.

many blocks on scratch can end up looking messy because of extended use of blocks, that doesnt mean their should be a simplified option.

Last edited by FUTSync (Oct. 21, 2017 01:19:03)

Charles12310
Scratcher
1000+ posts

More than one if for if then else

aaroncavanagh wrote:

Charles12310 wrote:

-ShadowOfTheFuture- wrote:

No support. The workaround is really simple.

ifthen. . .elseifthen. . .elseifthen. . .else. . .
Please explain:


You can see now that in this instance, it doesn't seem to be easy anymore. You have to drag one block, and another, and another, and another…

Also, it takes up too much space causing more scrolling to see other scripts, which can get worse if the scripts inside them were big.

ifthenelseifelseif
You can see here that it looks much more organized, and much more shorter than the other. I doubt this would be easy if the user had to make a lot of ifs and elses.

I'm supporting for this reason

(snipped to shorten quote).
Just because you have to ‘drag and drop’ a lot of times & that its ‘more organised’ doesn't mean it should be implemented.

This block would rarely be used, and very rarely that many times, the work around is extremely simple.

many blocks on scratch can end up looking messy because of extended use of blocks, that doesnt mean their should be a simplified option.
Ridiculous. Even my projects use so many ifs and elses. You don't care if someone has to suffer having to do all of that stuff? I told you, it saves time and energy. What do you mean, “rarely used”? The if and else block is an important block, and I've seen projects use a lot of ifs and elses. If you don't care about organised code, you will realize how much more time it takes, if you don't organise your code. Do you even care if people will lose energy and if they waste time? This is supposed to be about why an if block with multiple else blocks is useful. My opinion is my opinion. I think it's useful in case you have a lot of ifs and elses, and so it organises your scripts so that you can get the job done and only a bit of energy is wasted.
DaEpikDude
Scratcher
1000+ posts

More than one if for if then else

aaroncavanagh wrote:

Just because you have to ‘drag and drop’ a lot of times & that its ‘more organised’ doesn't mean it should be implemented.
Hey, uh, literally every other programming language would like to have a word with you.
if (so and so) {
...
} else if (so and so) {
...
} else if (so and so) {
...
} else if (so and so) {
...
} else {
...
}
anslovera27
New Scratcher
1 post

More than one if for if then else

I need to know if you can put multiple items in the diamond shaped block when you do, “if llllllll then…”
Where the l's are, I need to know if you can put multiple things in there.
Maarten_
Scratcher
100+ posts

More than one if for if then else

anslovera27 wrote:

I need to know if you can put multiple items in the diamond shaped block when you do, “if llllllll then…”
Where the l's are, I need to know if you can put multiple things in there.
You can, try using the following operators for that:
An “and” operator is used if both values are true
if...and...then. . .
An “or” operator is used if at least one value is true
if...or...then. . .
Harakou
Scratcher
1000+ posts

More than one if for if then else

I initially deleted a post suggesting that we merge this into this thread because I planned to do so, though on second look I could see some of the specific details of that thread possibly being more complex than the ones here, so I'm going to opt to leave these separate for now. Sorry about that!
Paddle2See
Scratch Team
1000+ posts

More than one if for if then else

It looks like this is a duplicate topic of this one over here so I'll close it to keep the conversation all in one place.

Please use the existing topic in the link above.

Powered by DjangoBB