Discuss Scratch
- Discussion Forums
- » Suggestions
- » More than one if for if then else
- appdeveloper51251
- New to Scratch
2 posts
More than one if for if then else
Currently, the scratch block for if then else looks like this:
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)
if <> thenHow 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.
else
end
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:
Purchase?
What??
Wouldn't it be easier to just “extend” it if you right click?
Also you can use scratchblocks, like so:
if <...> then{Looks much better.
...
} else {
...
} else {
...
}::control
And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
- -ShadowOfTheFuture-
- Scratcher
1000+ posts
More than one if for if then else
No support. The workaround is really simple.
if <> then
...
else
if <> then
...
else
if <> then
...
else
...
end
end
end
<Insert uncreative signature here>
██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██
███ ███ ██ ████ ██ ███ ███
█████████ █████ █████ █████████
“Though the seasons come and go, and sunshine turns to snow, we will always have tomorrow up ahead.”
- 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?
if <thing1> then
do thing 1
else
do the else statement
end
if <thing2> then
do thing 2
else
do the else statement
end
FUTSync
- DaEpikDude
- Scratcher
1000+ posts
More than one if for if then else
Because that's different to what an else if is. 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?if <thing1> then
do thing 1
else
do the else statement
end
if <thing2> then
do thing 2
else
do the else statement
end
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.
And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
- appdeveloper51251
- New to Scratch
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
Because that's different to what an else if is. 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?if <thing1> then
do thing 1
else
do the else statement
end
if <thing2> then
do thing 2
else
do the else statement
end
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.
if <thing1> then
do thing 1
else
if <thing2> then
do thing 2
else
do the else statement
end
end
FUTSync
- Charles12310
- Scratcher
1000+ posts
More than one if for if then else
Please explain: No support. The workaround is really simple.if <> then
...
else
if <> then
...
else
if <> then
...
else
...
end
end
end
if <> thenYou 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…
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
if <> then
else
end
end
end
end
end
end
end
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.
if <> then {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.
} else if<> {
} else if<> {
} else if<> {
} else if<> {
} else if<> {
} else if<> {
} else if<> {
} else if<> {
} else if<> {
} else if<> {
} else {
} :: control
I'm supporting for this reason.
A few internet communication companies want to corrupt the internet by getting rid of net neutrality. Stop Them!
- FUTSync
- Scratcher
100+ posts
More than one if for if then else
Just because you have to ‘drag and drop’ a lot of times & that its ‘more organised’ doesn't mean it should be implemented.Please explain: No support. The workaround is really simple.if <> then
...
else
if <> then
...
else
if <> then
...
else
...
end
end
end
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.if <> then {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.
} else if<> {
} else if<> {
}
I'm supporting for this reason
(snipped to shorten quote).
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)
FUTSync
- Charles12310
- Scratcher
1000+ posts
More than one if for if then else
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.Just because you have to ‘drag and drop’ a lot of times & that its ‘more organised’ doesn't mean it should be implemented.Please explain: No support. The workaround is really simple.if <> then
...
else
if <> then
...
else
if <> then
...
else
...
end
end
end
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.if <> then {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.
} else if<> {
} else if<> {
}
I'm supporting for this reason
(snipped to shorten quote).
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.
A few internet communication companies want to corrupt the internet by getting rid of net neutrality. Stop Them!
- DaEpikDude
- Scratcher
1000+ posts
More than one if for if then else
Hey, uh, literally every other programming language would like to have a word with you. Just because you have to ‘drag and drop’ a lot of times & that its ‘more organised’ doesn't mean it should be implemented.
if (so and so) {
...
} else if (so and so) {
...
} else if (so and so) {
...
} else if (so and so) {
...
} else {
...
}
And all the world over, each nation's the same,
They've simply no notion of playing the game.
They argue with umpires, they cheer when they've won,
And they practice beforehand, which ruins the fun!
- anslovera27
- New to Scratch
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.
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
You can, try using the following operators for that: 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.
An “and” operator is used if both values are true
if <<...> and <...>> thenAn “or” operator is used if at least one value is true
...
end
if <<...> or <...>> then
...
end
- 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.
Please use the existing topic in the link above.
Scratch Team Member, kayak and pickleball enthusiast, cat caregiver.
This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.
(credit to Za-Chary)
;
- Discussion Forums
- » Suggestions
- » More than one if for if then else