Discuss Scratch

Mr_PenguinAlex
Scratcher
1000+ posts

if <> then <> block

<if <> then <> :: control>
We need this block, it would have a lot of uses.
For example, let's say there was a game where there is a choice of 2 players, and something must appear away from the players.
They would need this:
repeat until <not <<(distance to [player one v]) = [30]> and <if <(players) = [2]> then <not <(distance to [player two v]) = [30]>> :: control>>>
go to [random position v]
end
show

Last edited by Mr_PenguinAlex (Aug. 1, 2019 14:57:29)


Za-Chary
Scratcher
1000+ posts

if <> then <> block

It's subtle, but there is a relatively simple workaround.

<<not <>> or <>>

When you write this:

<if <boolean A> then <boolean B> :: control>

It is always true unless “boolean A” is true and “boolean B” is false. Similarly:

<<not <boolean A>> or <boolean B>>

If “boolean A” is false, then the entire boolean would be true due to the “or” statement. If “boolean A” is true, then we need “boolean B” to be true in order for the boolean to be true (otherwise, it's false). In other words, this boolean is always true unless “boolean A” is true and “boolean B” is false.

Applying this logic to the example you gave might make more sense.

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.

I was a Scratch Team member from May 10th 2019 to October 29th 2021.

my notebook | scratch team essay | accessibility essay
Mr_PenguinAlex
Scratcher
1000+ posts

if <> then <> block

Za-Chary wrote:

It's subtle, but there is a relatively simple workaround.

<<not <>> or <>>

When you write this:

<if <boolean A> then <boolean B> :: control>

It is always true unless “boolean A” is true and “boolean B” is false. Similarly:

<<not <boolean A>> or <boolean B>>

If “boolean A” is false, then the entire boolean would be true due to the “or” statement. If “boolean A” is true, then we need “boolean B” to be true in order for the boolean to be true (otherwise, it's false). In other words, this boolean is always true unless “boolean A” is true and “boolean B” is false.

Applying this logic to the example you gave might make more sense.
Oh, okay! Thanks!

Harakou
Scratcher
1000+ posts

if <> then <> block

Glad you found an answer! Since this is resolved, I'll close it to help highlight the answer and prevent future responses. If you need it re-opened, though, you can report this and ask.

Powered by DjangoBB