This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2010-02-21 18:37:15

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Using scratch booleans

After experimenting with the boolean (the pointy < > blocks), I discovered something. It turns out that the pointy blocks report as booleans using the actual words true and false. For example, you could have a block that said:

<if <touching color red>=<true>>

Also, you can put booleans into say blocks and think blocks to make it easier to test these blocks. (By the way, anywhere you can add custom text you can add these boolean blocks, ie. in lists and variables)

You can also make the built in booleans equal to each other like this:

<<touching color red>=<mouse down>>

Although it doesn't make much sense, essentially what it does is compares the reported value (of true or false) to another reported value.

If not exactly sure what this does for you, but it's a very interesting thing to play with!  smile


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

#2 2010-02-21 18:46:27

Ace-of-Spades
Scratcher
Registered: 2010-01-08
Posts: 1000+

Re: Using scratch booleans

I knew this already. It's like that for variables too. If you double click "If variable = something," and it's true or false, it'll tell whether it's true or false.


11110010100011010100011010101000100011011011001010111100101000110101000110101010001000110110110010101111001010001101010001101010100010001101101100101011110010100011010100011010101000100011011011001010
110101010010001010101010101010101010101010100110101010010101010010101001101011010101010010101010101

Offline

 

#3 2010-02-21 19:14:13

scmb1
Scratch Team
Registered: 2009-03-19
Posts: 1000+

Re: Using scratch booleans

That's cool! Thanks greenflash!


http://i48.tinypic.com/2z5pqad.png

Offline

 

#4 2010-02-21 22:12:06

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Re: Using scratch booleans

greenflash wrote:

After experimenting with the boolean (the pointy < > blocks), I discovered something. It turns out that the pointy blocks report as booleans using the actual words true and false. For example, you could have a block that said:

<if <touching color red>=<true>>

...If not exactly sure what this does for you, but it's a very interesting thing to play with!  smile

Sure enough Cat knew whether it was touching a black oval in a quick new project, and said as much!

And then if it was true that Cat was touching the black oval, Cat played the sound "Meow."

A whole new dimension of Scratch to contemplate!

Thanks!!   smile

Offline

 

#5 2010-02-21 22:22:08

archmage
Scratcher
Registered: 2007-05-18
Posts: 1000+

Re: Using scratch booleans

Interesting... I wonder if you can do any other neat things with these blocks.


Hi, I am Archmage coder extraordinaire. I do Scratch,pascal,java,php,html, AS2 and AS3. Leave me a message if you want coding advice. Also check out my personal website, lots of good stuff about web development, Flash, and Scratch (v1 and v2) !

Offline

 

#6 2010-02-21 22:24:37

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: Using scratch booleans

Larry828 wrote:

greenflash wrote:

After experimenting with the boolean (the pointy < > blocks), I discovered something. It turns out that the pointy blocks report as booleans using the actual words true and false. For example, you could have a block that said:

<if <touching color red>=<true>>

...If not exactly sure what this does for you, but it's a very interesting thing to play with!  smile

Sure enough Cat knew whether it was touching a black oval in a quick new project, and said as much!

And then if it was true that Cat was touching the black oval, Cat played the sound "Meow."

A whole new dimension of Scratch to contemplate!

Thanks!!   smile

If kind of redundant if you use if <>=true. You can use the not block instead of false. But what I like the most is seeing if two values are the same, if they are true/true and false/false.

I just tried using the booleans with the > block instead of =. It turns out that truth is greater than falseness!

Edit: I bet we could figure out how to detect all the combinations of true/false for two booleans. Using the > you can determine "true, false" and using < you can detect "false, true"

Last edited by greenflash (2010-02-21 22:34:40)


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

#7 2010-02-21 23:17:46

Chrischb
Scratcher
Registered: 2008-07-24
Posts: 1000+

Re: Using scratch booleans

Nice discoveries!  smile

I'll try it...


I fall: It's a tragedy. You fall: It's comedy.
Hmph enjoy your fall - I get a lovely spring... without pans of new leaves.

Offline

 

#8 2010-02-21 23:26:30

greenflash
Scratcher
Registered: 2009-05-27
Posts: 1000+

Re: Using scratch booleans

Another weird discovery: on variables, true is true and false is false, but on lists, true is 1 and false is 0. Weird discrepancy... But I guess that explains why true>false


http://i48.tinypic.com/2wrkirk.pnghttp://i46.tinypic.com/6r5zk7.pnghttp://i45.tinypic.com/2vtxr1t.png

Offline

 

#9 2010-02-22 00:16:14

Ace-of-Spades
Scratcher
Registered: 2010-01-08
Posts: 1000+

Re: Using scratch booleans

What, you mean nobody's discovered this before? o.O

I found this like a week after I started using scratch.


11110010100011010100011010101000100011011011001010111100101000110101000110101010001000110110110010101111001010001101010001101010100010001101101100101011110010100011010100011010101000100011011011001010
110101010010001010101010101010101010101010100110101010010101010010101001101011010101010010101010101

Offline

 

#10 2010-02-22 09:11:56

technoguyx
Scratcher
Registered: 2008-10-18
Posts: 1000+

Re: Using scratch booleans

I knew that...

greenflash wrote:

Another weird discovery: on variables, true is true and false is false, but on lists, true is 1 and false is 0. Weird discrepancy... But I guess that explains why true>false

...But not this  yikes


http://getgnulinux.org/links/en/linuxliberated_4_78x116.png

Offline

 

#11 2010-02-22 12:13:52

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Using scratch booleans

I knida knew this, i just wouldn't have been able to put it into words.


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

#12 2010-02-22 19:57:00

Larry828
Scratcher
Registered: 2007-05-30
Posts: 100+

Re: Using scratch booleans

markyparky56 wrote:

I knida knew this, i just wouldn't have been able to put it into words.

And I could have put it into words, but I didn't know anything about it.

Offline

 

#13 2010-02-23 12:09:18

markyparky56
Scratcher
Registered: 2008-03-20
Posts: 1000+

Re: Using scratch booleans

Larry828 wrote:

markyparky56 wrote:

I knida knew this, i just wouldn't have been able to put it into words.

And I could have put it into words, but I didn't know anything about it.

Yet you knew nothing about it, so the subject of what you were putting into words would have been nothing, so it would be nothing.  wink


http://j.mp/jgVnTq
Check out my game engine development site: NewDawn I'm a Level 171 Scratcher.I am http://bit.ly/nkvLNT

Offline

 

Board footer