Discuss Scratch

PkmnQ
Scratcher
1000+ posts

___ or ___ but not both block [XOR]

No support. Honestly, why would anyone need xor anyway?


The not block is useful. You can use it to make sure a variable is not a certain value.
The and block is useful. You can use it to see if a sprite is being clicked.
The or block is useful. You can use it to know when either the enemy or the player has died.


What's the use for the xor block?

Last edited by PkmnQ (April 9, 2020 04:13:30)

NxNmultiply
Scratcher
100+ posts

___ or ___ but not both block [XOR]

DadOfMrLog wrote:

To repeat what AonymousProfessor said, and to apply it to the examples given above…

First, the example from ExtremeLogic:
when green flag clicked
if < not <<(variable1) = [1]> = <(variable2) = [2]> > > then
Some Block
end
Then your own example:
when green flag clicked
forever
if <key [left arrow v] pressed?> then{
change x by (3)
}
else{
if <key [right arrow v] pressed?>{
change x by (-3)
}
end

Using “not (a=b)” is far more concise than using “(a or b) and (not (a and b))” - since Scratch lets you drop in booleans for a and b.

Wouldn't an else branch be used for this? (holy . I messed up the order of the two scripts)
when green flag clicked
forever
if < not < < key [left arrow v] pressed? > = < key [right v] pressed? > > > then

if <key [left arrow v] pressed?> then

change x by (3)
end
if <key [right arrow v] pressed?> then

change x by (-3)
end
end
end
MDCCCLXVII
Scratcher
1000+ posts

___ or ___ but not both block [XOR]

bumped from a duplicate topic
Mr_erson
Scratcher
58 posts

___ or ___ but not both block [XOR]

Thats an XOR. What you can do instead is:

if <<Var1> or <Var2>> then
if <not <[Var1] = [Var2]>> then
say [This is the workaround]
end
end

Last edited by Mr_erson (April 9, 2021 21:34:52)

dhfbei8987
Scratcher
1000+ posts

___ or ___ but not both block [XOR]

Mr_erson wrote:

Thats an XOR. What you can do instead is:

if <<Var1> or <Var2>> then
if <not <[Var1] = [Var2]>> then
say [This is the workaround]
end
end
incorrectly used, let me help correct your mistake:

if <not <[something] = [other something]>> then
do stuff::operators
end
mumu245
Scratcher
1000+ posts

___ or ___ but not both block [XOR]

If it's too hard to understand, could this work?
<only one of <> <> ::operators>
undeterminstic
Scratcher
1000+ posts

___ or ___ but not both block [XOR]


PkmnQ wrote:

No support. Honestly, why would anyone need xor anyway?


The not block is useful. You can use it to make sure a variable is not a certain value.
The and block is useful. You can use it to see if a sprite is being clicked.
The or block is useful. You can use it to know when either the enemy or the player has died.


What's the use for the xor block?
I support because we could use the xor block to solve a fun projecteuler question anyway that is my only reason.
EDawg2011
Scratcher
1000+ posts

___ or ___ but not both block [XOR]

I've seen 2 main workarounds for this block.

<not <<1::#888888> = <2::#888888>>>

The problem with this workaround is that not everyone knows they can put boolean blocks in those white spaces.

<<<1::#888888> or <2::#888888>> and <not <<1::#888888> and <2::#888888>>>>

The problem with this workaround is that it could be annoying to do every time you want a xor function in your project.

mumu245 wrote:

If it's too hard to understand, could this work?
<only one of <> <> ::operators>
That wouldn't work because that is ambiguous; the condition would be true if only one of these conditions what? Here's a non-ambiguous version:

only one of <1::#888888> and <2::#888888> is true?::boolean operators

Not everyone knows what xor is and I feel like this block would be useful for some people; support.
starlightsparker
Scratcher
1000+ posts

___ or ___ but not both block [XOR]

EDawg2011 wrote:

only one of <1::#888888> and <2::#888888> is true?::boolean operators

i support this block because xor is confusing for some.

Last edited by starlightsparker (Feb. 25, 2024 15:45:16)

undeterminstic
Scratcher
1000+ posts

___ or ___ but not both block [XOR]

i have been on scratch for 4 years and haven't founda usage for it. where would it be used
mumu245
Scratcher
1000+ posts

___ or ___ but not both block [XOR]

undeterminstic wrote:

(#50)
i have been on scratch for 4 years and haven't founda usage for it. where would it be used
It would be used for logic.
kkidslogin
Scratcher
1000+ posts

___ or ___ but not both block [XOR]

undeterminstic wrote:

(#50)
i have been on scratch for 4 years and haven't founda usage for it. where would it be used
Specific kinds of logic, encoding, and bitwise operations.
CodeComet6161
Scratcher
1000+ posts

___ or ___ but not both block [XOR]

Workaround:
if <<<(a) = [true]> and <(b) = [false]>> or <<(a) = [false]> and <(b) = [true]>>> then
something
something
something
end
NPLol39-2_
Scratcher
100+ posts

___ or ___ but not both block [XOR]

There's a simple workaround:
<not <<boolean :: grey> = <boolean2 :: grey>>> //works as XOR
<<boolean :: grey> = <boolean2 :: grey>> //works as not XOR (both booleans are true or false)
This workaround was mentioned 11 years ago.
Also, Scratch is meant to be intuitive for all ages. Calling it XOR would be confusing to most people.

Powered by DjangoBB