Discuss Scratch

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

kNoobLauch wrote:

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”.


And it was delicious! Play TBGs! Check out my Scheme Interpreter!
;
Scratcher1002
Scratcher
1000+ posts

Boolean variables :D

Nurutomo wrote:

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
Or at that point just put the mouse down variable in the first script and delete the second script.

NanoRook wrote:

kNoobLauch wrote:

Yes, I can… but boolean variables would be also nice ._.

How? The workaround literally takes two seconds.

set [WaffleTastiness v] to [true ]
Not exactly the workaround, this too:
<(WaffleTastiness) = [true]>
agarraga
Scratcher
500+ posts

Boolean variables :D

Scratcher1002 wrote:

Nurutomo wrote:

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
Or at that point just put the mouse down variable in the first script and delete the second script.

NanoRook wrote:

kNoobLauch wrote:

Yes, I can… but boolean variables would be also nice ._.

How? The workaround literally takes two seconds.

set [WaffleTastiness v] to [true ]
Not exactly the workaround, this too:
<(WaffleTastiness) = [true]>
This thread is too old!
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
edward789121test
New to Scratch
93 posts

Boolean variables :D

I know, because with Python/C++/JavaScript/XCode it has that.
Example:
bool = name = true
bool = name = false
edward789121test
New to Scratch
93 posts

Boolean variables :D

MathlyCat wrote:

Isn't there already a defined workaround here? What's with the pointless discussion anyways?
Just ‘cause something has a workaround doesn’t mean no one wants it, though.
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!

Sheep_maker
Scratcher
1000+ posts

Boolean variables :D

edward789121test wrote:

MathlyCat wrote:

Isn't there already a defined workaround here? What's with the pointless discussion anyways?
Just ‘cause something has a workaround doesn’t mean no one wants it, though.
They're probably just pointing out that we keep repeating what has already been made clear

- 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

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.
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

mixxxXD wrote:

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:
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.










If you can read this, my signature cubeupload has been eaten by an evil kumquat!




or you just used Inspect Element, you hacker

;
stickfiregames
Scratcher
1000+ posts

Boolean variables :D

mixxxXD wrote:

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

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
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










If you can read this, my signature cubeupload has been eaten by an evil kumquat!




or you just used Inspect Element, you hacker

;
Mega987654
Scratcher
100 posts

Boolean variables :D

NanoRook wrote:

How? The workaround literally takes two seconds.

set [WaffleTastiness v] to [true ]
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:
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

Mega987654 wrote:

NanoRook wrote:

How? The workaround literally takes two seconds.

set [WaffleTastiness v] to [true ]
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:
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.
Please don't Necropost.

Disco Calculator | Is it Prime?
Translate The SDS | The Scratch Wiki

define How to scratch
think [Creative]
This message was transmitted using 100% recycled electrons
;
Charles12310
Scratcher
1000+ posts

Boolean variables :D

jakel181 wrote:

Mega987654 wrote:

NanoRook wrote:

How? The workaround literally takes two seconds.

set [WaffleTastiness v] to [true ]
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:
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.
Please don't Necropost.
Necroposting is allowed on topics that are suggestions.

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

Mega987654 wrote:

NanoRook wrote:

How? The workaround literally takes two seconds.

set [WaffleTastiness v] to [true ]
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:
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.
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.

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
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

MathlyCat wrote:

As for the suggestion, just use:

<[0] = [1]> // always false

<[1] = [1]> // always true
Although the workaround works, it requires typing in the inputs, which isn't the most efficient.

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; }

Powered by DjangoBB