Discuss Scratch
- Discussion Forums
- » Suggestions
- » Boolean Variables and While Block
- thechief389
-
Scratcher
88 posts
Boolean Variables and While Block
I thought that it would be convenient to have boolean variables like
Then, you can make your own booleans set to either “True” or “False”, and you can check the boolean value with an if block easier.
For example:
can become:
Even though the while block is probably a rejected suggestion since there's a workaround, You could do:
even though you could still do:
Do you agree with me?
<happy :: variables>added to Scratch.
Then, you can make your own booleans set to either “True” or “False”, and you can check the boolean value with an if block easier.
For example:
if <(happy) = [True]> then
switch costume to [happy v]
else
switch costume to [sad v]
end
can become:
set boolean[happy v] to [True v] :: variables
if <happy :: variables> then
switch costume to [happy v]
else
switch costume to [sad v]
end
Even though the while block is probably a rejected suggestion since there's a workaround, You could do:
while <happy :: variables> {act[happy] :: custom} :: controleven though you could still do:
repeat until <not<happy :: variables>>
act[happy] :: custom
end
Do you agree with me?
- muellly
-
Scratcher
1000+ posts
Boolean Variables and While Block
You can already do this with normal variables. You can set them to true, or false and anything else you want. I don't see why another variable type should be added just for setting a variable to true and false.
- aking_
-
Scratcher
1000+ posts
Boolean Variables and While Block
You can already do this with normal variables. You can set them to true, or false and anything else you want. I don't see why another variable type should be added just for setting a variable to true and false.^^
No support because of what @muellly said.
- Charles12310
-
Scratcher
1000+ posts
Boolean Variables and While Block
I'm sure the alternatives are fine. More custom blocks will be added, so don't worry.
- walkcycle
-
Scratcher
500+ posts
Boolean Variables and While Block
Workarounds aren't too hard. I really like the write-up, though.
Maybe when a variable is set to true or false, the shape could become boolean…
<happy ::variables>
Maybe when a variable is set to true or false, the shape could become boolean…
set [happy v] to [true]
- FancyFoxy
-
Scratcher
500+ posts
Boolean Variables and While Block
Aren't custom booleans already being added?
Also, adding “not” is very easy to do. I won't support for the while block.
Also, adding “not” is very easy to do. I won't support for the while block.
- DatBoi404
-
Scratcher
1 post
Boolean Variables and While Block
You can already do this with normal variables. You can set them to true, or false and anything else you want. I don't see why another variable type should be added just for setting a variable to true and false.
Yeah, i'm new. Could someone show me how to make custom booleans.
- imfh
-
Scratcher
1000+ posts
Boolean Variables and While Block
I think that it would be better if variables could be dropped into boolean slots rather than having a new type of variable. The shape could change when it is dropped. It would likely be confusing to new scratchers though…
Welcome to the Scratch Forums! The snippet of code below is one way you can create custom booleans. If you need more help, feel free to create a topic on the Help With Scripts forum which better fits this kind of discussion.You can already do this with normal variables. You can set them to true, or false and anything else you want. I don't see why another variable type should be added just for setting a variable to true and false.
Yeah, i'm new. Could someone show me how to make custom booleans.
when [t v] key pressed
set [bool v] to [true]
when [f v] key pressed
set [bool v] to [false]
when green flag clicked
if <(bool) = [true]> then
… // True
else
… // False
end
- ChiaJia
-
Scratcher
62 posts
Boolean Variables and While Block
No support for the while block.
As someone who used to code with Python, (where, by the way, you can use “while” in a string of code like you suggested) I don't think the “while” block would be useful. The “repeat until” block works perfectly fine as a workaround for “while.”
Also, for the boolean variable, no support either. What if instead of true and false, you set your variable to a number or a string of letters? The boolean variable would just be confusing.
As someone who used to code with Python, (where, by the way, you can use “while” in a string of code like you suggested) I don't think the “while” block would be useful. The “repeat until” block works perfectly fine as a workaround for “while.”
Also, for the boolean variable, no support either. What if instead of true and false, you set your variable to a number or a string of letters? The boolean variable would just be confusing.
- imfh
-
Scratcher
1000+ posts
Boolean Variables and While Block
No support for the while block.I agree they could be very confusing. Fun fact, the while block actually exists for backwards compatibility with older versions which used it. It is not in the block palette, but you can find it by searching “while block.”
As someone who used to code with Python, (where, by the way, you can use “while” in a string of code like you suggested) I don't think the “while” block would be useful. The “repeat until” block works perfectly fine as a workaround for “while.”
Also, for the boolean variable, no support either. What if instead of true and false, you set your variable to a number or a string of letters? The boolean variable would just be confusing.
- Discussion Forums
- » Suggestions
-
» Boolean Variables and While Block