Discuss Scratch
- Discussion Forums
- » Suggestions
- » Boolean variables :D
- Nurutomo
- Scratcher
12 posts
Boolean variables :D
when green flag clicked
forever
if <(Variable) = [true]> then
say [Place Block Here] for (0.5) secs
end
end
when green flag clicked
forever
set [Variable v] to <mouse down?>
end
Last edited by Nurutomo (May 1, 2016 02:49:24)
- NanoRook
- Scratcher
1000+ posts
Boolean variables :D
Yes, I can… but boolean variables would be also nice ._.
How? The workaround literally takes two seconds.
set [WaffleTastiness v] to [true ]
I LOVE BEING PURPLE!!!! JOIN THE PURPLE COALITION TODAY IF YOU ALSO LOVE BEING PURPLE. PURPLE IS THE NEW BLUE! PURPLE IS THE SUPERIOR NAVBAR COLOR! YYYEAAHHHHH BABY!!!!
- joefarebrother
- Scratcher
500+ posts
Boolean variables :D
It would be a useful idea, support!
Even though the easy workaround exists, there is a chance of spelling true and false wrong, leading to bugs.
Also, I don't understand how it's confusing to beginners - we already have the “Boolean” option for custom block inputs, so Scratch does already use the word “Boolean”.
Even though the easy workaround exists, there is a chance of spelling true and false wrong, leading to bugs.
Also, I don't understand how it's confusing to beginners - we already have the “Boolean” option for custom block inputs, so Scratch does already use the word “Boolean”.
- Scratcher1002
- Scratcher
1000+ posts
Boolean variables :D
Or at that point just put the mouse down variable in the first script and delete the second script.when green flag clicked
forever
if <(Variable) = [true]> then
say [Place Block Here] for (0.5) secs
end
endwhen green flag clicked
forever
set [Variable v] to <mouse down?>
end
Not exactly the workaround, this too:Yes, I can… but boolean variables would be also nice ._.
How? The workaround literally takes two seconds.set [WaffleTastiness v] to [true ]
<(WaffleTastiness) = [true]>
・Scratcher1002は「ここにランダムな日本語の言葉はたくさんですか?はい」と言いました・
||||Search:
Topics | Users
||Studios | Projects
||
||||Search:
Topics | Users
||Studios | Projects
||
- agarraga
- Scratcher
500+ posts
Boolean variables :D
This thread is too old!Or at that point just put the mouse down variable in the first script and delete the second script.when green flag clicked
forever
if <(Variable) = [true]> then
say [Place Block Here] for (0.5) secs
end
endwhen green flag clicked
forever
set [Variable v] to <mouse down?>
endNot exactly the workaround, this too:Yes, I can… but boolean variables would be also nice ._.
How? The workaround literally takes two seconds.set [WaffleTastiness v] to [true ]<(WaffleTastiness) = [true]>
- MathlyCat
- Scratcher
1000+ posts
Boolean variables :D
Isn't there already a defined workaround here? What's with the pointless discussion anyways?
Think before you act.
Actions speek louder than words.
hi there fella
Actions speek louder than words.
hi there fella
- edward789121test
- New to Scratch
93 posts
Boolean variables :D
I know, because with Python/C++/JavaScript/XCode it has that.
Example:
Example:
bool = name = true bool = name = false
- edward789121test
- New to Scratch
93 posts
Boolean variables :D
Just ‘cause something has a workaround doesn’t mean no one wants it, though. Isn't there already a defined workaround here? What's with the pointless discussion anyways?
- JavierR100
- Scratcher
500+ posts
Boolean variables :D
No support:
if <(HP) < [15]> // if player has low health
set [Low health? v] to [1]
else
set [Low health? v] to [0]
end
if <(Low health?) = [1]>
. . .
end
// OR
if <(HP) < [15]> // You know.
set [Low health? v] to [true]
else
set [Low health? v] to [false]
end
if <(Low health?) = [true]>
. . .
end
My customs Blocks on “Snap!” || search in google HN54FyF4KW27o*YWAD94qjEMLV62+]59 to find all my posts. || “Fantasy Tank Builder” Topic || Diep.io | Official Thread || Geometry Dash name account: "JavierR100". || Geometry Dash Official Topic
Actually, [B]en is my legal name!- Pen, BFB 5
Sorry, I'm gone to roblox now, so Im not able to reply anymore!
Sorry, I'm gone to roblox now, so Im not able to reply anymore!
- Sheep_maker
- Scratcher
1000+ posts
Boolean variables :D
They're probably just pointing out that we keep repeating what has already been made clearJust ‘cause something has a workaround doesn’t mean no one wants it, though. Isn't there already a defined workaround here? What's with the pointless discussion anyways?
- Sheep_maker This is a kumquat-free signature. :P
This is my signature. It appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
- mixxxXD
- New to Scratch
2 posts
Boolean variables :D
Boolean can be replaced by 0 and 1 or -1 and 1. I prefer -1 (for false) and 1 (for true) because it is easy to make negation. So boolean negations
not true gives false
and
not false gives true
can be replaced by
-1 * 1 -> -1
and
-1 * -1 -> 1
not true gives false
and
not false gives true
can be replaced by
-1 * 1 -> -1
and
-1 * -1 -> 1
when [ v] key pressed
set [foo] to [((-1) * (foo))]
Last edited by mixxxXD (April 9, 2017 23:39:14)
- mixxxXD
- New to Scratch
2 posts
Boolean variables :D
We can easily switch our "bool" variable value between 1 and -1 i.e.
ans we can verify current “bool” state with
when [space v] key pressed
set [bool v] to ((-1) * (bool))
ans we can verify current “bool” state with
if <(bool) > [0]> then
else
end
Boolean can be replaced by 0 and 1 or -1 and 1. I prefer -1 (for false) and 1 (for true) because it is easy to make negation. So boolean negations
not true gives false
and
not false gives true
can be replaced by
-1 * 1 -> -1
and
-1 * -1 -> 1
- stickfiregames
- Scratcher
1000+ posts
Boolean variables :D
How would you set a variable directly to true or false? Here are some possibilities:
Using existing blocks, but it's ugly and less intuitive:
New true and false reporters:
A hybrid boolean-dropdown input:
A toggle:
Personally I would prefer the true and false reporters or the toggle. If it is the toggle, it would make sense to add it to custom block boolean inputs as well.
Using existing blocks, but it's ugly and less intuitive:
set [var v] to <not <>>
New true and false reporters:
set [var v] to <true :: operators>
A hybrid boolean-dropdown input:
A toggle:
Personally I would prefer the true and false reporters or the toggle. If it is the toggle, it would make sense to add it to custom block boolean inputs as well.
- stickfiregames
- Scratcher
1000+ posts
Boolean variables :D
I prefer 0 and 1? Why? Because if you drop a boolean reporter into a number slot, it turns into 0 or 1. That means you can set the variable with Boolean can be replaced by 0 and 1 or -1 and 1. I prefer -1 (for false) and 1 (for true) because it is easy to make negation. So boolean negations
not true gives false
and
not false gives true
can be replaced by
-1 * 1 -> -1
and
-1 * -1 -> 1
set [var v] to (<value :: grey> * (1))and it is just as easy to negate by doing
((1) - (var))you can also do and like this:
((var1) * (var2))
also you have a tagleak
- Mega987654
- Scratcher
100 posts
Boolean variables :D
Yes, except now you have to deal with the = block. Plus, it's much easier, and “real” programming languages use it. New scratchers could make a use of it. There are tons of workaround-able blocks, but we still have them (for new scratchers). Here are some: How? The workaround literally takes two seconds.set [WaffleTastiness v] to [true ]
move (10) steps // Simple calculations
point in direction ( v) // Along w/ all the other rotational ones, JUST USE COSTUMES!
go to [ v] // Literally. So. Easy. Just do go to x: (x pos of blah) y: (y pos of blah)
change x by ()
set x to ()
change y by ()
set y to ()
// ^^^ Just use the go to x/y block (and + - for operations)
say [jeff] for (2) secs // Workaround below:
say [jeff]
wait (2) secs
say []
define use broadcasts bro
Those were just some examples of the MANY workarounds to blocks.
- jakel181
- Scratcher
1000+ posts
Boolean variables :D
Please don't Necropost.Yes, except now you have to deal with the = block. Plus, it's much easier, and “real” programming languages use it. New scratchers could make a use of it. There are tons of workaround-able blocks, but we still have them (for new scratchers). Here are some: How? The workaround literally takes two seconds.set [WaffleTastiness v] to [true ]move (10) steps // Simple calculations
point in direction ( v) // Along w/ all the other rotational ones, JUST USE COSTUMES!
go to [ v] // Literally. So. Easy. Just do go to x: (x pos of blah) y: (y pos of blah)
change x by ()
set x to ()
change y by ()
set y to ()
// ^^^ Just use the go to x/y block (and + - for operations)
say [jeff] for (2) secs // Workaround below:
say [jeff]
wait (2) secs
say []
define use broadcasts bro
Those were just some examples of the MANY workarounds to blocks.
Disco Calculator | Is it Prime?
Translate The SDS | The Scratch Wiki
define How to scratchThis message was transmitted using 100% recycled electrons
think [Creative]
;
- Charles12310
- Scratcher
1000+ posts
Boolean variables :D
Necroposting is allowed on topics that are suggestions.Please don't Necropost.Yes, except now you have to deal with the = block. Plus, it's much easier, and “real” programming languages use it. New scratchers could make a use of it. There are tons of workaround-able blocks, but we still have them (for new scratchers). Here are some: How? The workaround literally takes two seconds.set [WaffleTastiness v] to [true ]move (10) steps // Simple calculations
point in direction ( v) // Along w/ all the other rotational ones, JUST USE COSTUMES!
go to [ v] // Literally. So. Easy. Just do go to x: (x pos of blah) y: (y pos of blah)
change x by ()
set x to ()
change y by ()
set y to ()
// ^^^ Just use the go to x/y block (and + - for operations)
say [jeff] for (2) secs // Workaround below:
say [jeff]
wait (2) secs
say []
define use broadcasts bro
Those were just some examples of the MANY workarounds to blocks.
Also, you can just make a variable that sets to 1 or 0, but I agree with having to keep on using the equals and the fact that other programming languages use boolean variables.
A few internet communication companies want to corrupt the internet by getting rid of net neutrality. Stop Them!
- MathlyCat
- Scratcher
1000+ posts
Boolean variables :D
Those are there to help introduce new users. But you have to understand a certain level of complexity is needed so Scratcher's can learn.Yes, except now you have to deal with the = block. Plus, it's much easier, and “real” programming languages use it. New scratchers could make a use of it. There are tons of workaround-able blocks, but we still have them (for new scratchers). Here are some: How? The workaround literally takes two seconds.set [WaffleTastiness v] to [true ]move (10) steps // Simple calculations
point in direction ( v) // Along w/ all the other rotational ones, JUST USE COSTUMES!
go to [ v] // Literally. So. Easy. Just do go to x: (x pos of blah) y: (y pos of blah)
change x by ()
set x to ()
change y by ()
set y to ()
// ^^^ Just use the go to x/y block (and + - for operations)
say [jeff] for (2) secs // Workaround below:
say [jeff]
wait (2) secs
say []
define use broadcasts bro
Those were just some examples of the MANY workarounds to blocks.
As for the suggestion, just use:
<[0] = [1]> // always false
<[1] = [1]> // always true
Think before you act.
Actions speek louder than words.
hi there fella
Actions speek louder than words.
hi there fella
- JonathanSchaffer
- Scratcher
1000+ posts
Boolean variables :D
no support, can be worked around.
club penguin is kil
- Sheep_maker
- Scratcher
1000+ posts
Boolean variables :D
Although the workaround works, it requires typing in the inputs, which isn't the most efficient. As for the suggestion, just use:<[0] = [1]> // always false
<[1] = [1]> // always true
False can be workarounded by just leaving the boolean input empty; true is the opposite:
<not <>>
- Sheep_maker This is a kumquat-free signature. :P
This is my signature. It appears below all my posts. Discuss it on my profile, not the forums. Here's how to make your own.
.postsignature { overflow: auto; } .scratchblocks { overflow-x: auto; overflow-y: hidden; }
- Discussion Forums
- » Suggestions
- » Boolean variables :D