Discuss Scratch

videobob
Scratcher
100+ posts

___ or ___ but not both block

A new block in the operations section, this block works like the or block, but if both commands are activated, the block will not work. So, let's say <Variable1=1> or <Variable2=2> but both. This means if one of them is correct, the script will run. If both are, the script won't. I hope you consider this!
Firedrake969
Scratcher
1000+ posts

___ or ___ but not both block

so XOR?

Workaround in pseudocode:

if (x or y) and not (x and y)

'17 rickoid

bf97b44a7fbd33db070f6ade2b7dc549
davidkt
Scratcher
1000+ posts

___ or ___ but not both block

Yeah, but call it xor, and have something explaining what it does.
<<> xor <>::operators>

Last edited by davidkt (March 24, 2014 20:29:20)


Remember when I looked like this? I still do.


Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
AonymousProfessor
Scratcher
100+ posts

___ or ___ but not both block

Workaround: (by xlk)
<not <<bool1 :: grey> = <bool2 :: grey>>> //Yes, booleans can go into an equals block

I am @AonymousGuy's test account!

The word “test” in test accounts is outdated. That is why mine has professor instead!

Thanks @MicroMacro for the profile image!
EmeraldDaffodils
Scratcher
100+ posts

___ or ___ but not both block

If you mean when both variable are activated, then:

when green flag clicked
forever
if <(spuds) = [10]> then

change [or] by [1]
end
if <(corks) = [15]> then

change [spuds] by (1)
end
end
wait until <(or) = [2]>
say [Congrats! You completed the challenge!]

Last edited by EmeraldDaffodils (March 23, 2014 21:02:31)


videobob
Scratcher
100+ posts

___ or ___ but not both block

EmeraldDaffoldis, that's the exact opposite of what I mean, and there is a better way of doing that using the and block. I mean if only one of them is true, but not both.
Greatguy123
Scratcher
500+ posts

___ or ___ but not both block

when green flag clicked
forever
if <<<key [left arrow v] pressed?> or <key [right v] pressed?>> and <not <<key [left arrow v] pressed?> and <key [right arrow 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
This is a very impractical script, but you get the idea. I realize it's a lot more complicated, though, so I think it would be a good idea to add XOR, and perhaps some other ones as well.

The evil if block is hungry! >:-D
ExtremeLogic
Scratcher
500+ posts

___ or ___ but not both block

videobob wrote:

A new block in the operations section, this block works like the or block, but if both commands are activated, the block will not work. So, let's say <Variable1=1> or <Variable2=2> but both. This means if one of them is correct, the script will run. If both are, the script won't. I hope you consider this!
I don't know if this would work, but maybe it would?
when green flag clicked
if <<<(variable1) = [1]> or <(variable2) = [2]>> and <not <<(variable1) = [1]> and <(variable2) = [2]>>>> then
Some Block
end
I hope that's what you're looking for or that it helps.

Greatguy123
Scratcher
500+ posts

___ or ___ but not both block

ExtremeLogic wrote:

I don't know if this would work, but maybe it would?
when green flag clicked
if <<<(variable1) = [1]> or <(variable2) = [2]>> and <not <<(variable1) = [1]> and <(variable2) = [2]>>>> then
Some Block
end
I hope that's what you're looking for or that it helps.
That's basically what I did, except it's better as an example.

The evil if block is hungry! >:-D
DadOfMrLog
Scratcher
1000+ posts

___ or ___ but not both block

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

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.

Last edited by DadOfMrLog (March 25, 2014 19:58:25)



Alternate account: TheLogFather –– HowTos and useful custom blocks (see studio). Examples below…


- String manipulation - - - X to power of Y - - - Clone point to clone - Detect New Scratcher - Speed tests studio -

videobob
Scratcher
100+ posts

___ or ___ but not both block

DadOfMrLog: I didn't make that example. GreatGuy123 did.
braxbroscratcher
Scratcher
1000+ posts

___ or ___ but not both block

videobob wrote:

A new block in the operations section, this block works like the or block, but if both commands are activated, the block will not work. So, let's say <Variable1=1> or <Variable2=2> but both. This means if one of them is correct, the script will run. If both are, the script won't. I hope you consider this!

Easy workaround IN SCRATCHBLOCKS!

Just for all to see.
if <<<X> or <Y>> and <not <<X> and <Y>>>> then
blah blah blah script stuff.
end

So no support.

I did not mean any disrespect.

Last edited by braxbroscratcher (March 26, 2014 11:00:07)



My signature is kumquat proof.
But not tangerine pro-
nomnomnomnomnom










Current Project:
n/a
Quotes: “In our last hour, we burn the most brightly, trying to deny that we are burning out.” -Me
“Well, no. 1024 Killerbytes make a Murderbyte.” -MegaByteCorporations
“I hate out of context quotes.” -Me
“I hate it when Cubeupload breaks.” -Also me
Blueinkproductions
Scratcher
1000+ posts

___ or ___ but not both block

Support. The workaround is annoying.

Generation 2: the first time you see this copy and paste it on top of your sig in the scratch forums and increase generation by 1. Social experiment.
____                  _____  _______              
| \ | | | | | |\ | | /
|___/ | | | |__ | | \ | |/
| \ | | | | | | \ | |\
| | | | | | | | \ | | \
|___/ L____ \___/ |_____ ___|___ | \| | \
PRODUCTIONS





















































Here's a hint: support = support.

<shameless self promotion>follow me! follow me! follow me! love my stuff! love my stuff! love my stuff! follow me! love my stuff! remix my stuff! follow me! follow me! </shameless self promotion>
DadOfMrLog
Scratcher
1000+ posts

___ or ___ but not both block

videobob wrote:

DadOfMrLog: I didn't make that example. GreatGuy123 did.
Oops, quite right!

@braxbroscratcher: the workaround you suggest has been mentioned above, but can get somewhat clumsy and long (as Greatguy123's example shows), which is the reason for the request for a “xor” operator.

However, there is a more succint workaround - for your example it would be:
if < not < <X> = <Y> > > then // where X & Y are boolean expressions - why I've left them red, rather than variable orange
blah blah blah script stuff.
end
It's really only one “not” operator more than a built-in “xor” would be, so I don't think a xor operator is needed.

To spell it out again:
< <X> xor <Y> > // category=operators X & Y are boolean expressions
is exactly the same as:
< not < <X> = <Y> > > // X & Y are boolean expressions
See my post above for more examples.

Last edited by DadOfMrLog (March 26, 2014 12:31:50)



Alternate account: TheLogFather –– HowTos and useful custom blocks (see studio). Examples below…


- String manipulation - - - X to power of Y - - - Clone point to clone - Detect New Scratcher - Speed tests studio -

CGRises
Scratcher
500+ posts

___ or ___ but not both block

braxbroscratcher wrote:

videobob wrote:

A new block in the operations section, this block works like the or block, but if both commands are activated, the block will not work. So, let's say <Variable1=1> or <Variable2=2> but both. This means if one of them is correct, the script will run. If both are, the script won't. I hope you consider this!

Easy workaround IN SCRATCHBLOCKS!

Just for all to see.
if <<<X> or <Y>> and <not <<X> and <Y>>>> then
blah blah blah script stuff.
end

So no support.

I did not mean any disrespect.

I
am childcritic
no longer forumposting
but still on on here
@speedyturtle has correctly guessed that the poem is a haiku.
AMV contest
Chibi-Matoran
Scratcher
1000+ posts

___ or ___ but not both block

Because I made a duplicate of this topic and it got closed, I will support this suggestion.

If you see this signature while scrolling, you have been visited by ʎ++ haskal. Lazy evaluation, monads, function purity, lambdas, currying, partial application, algebraic data types, pattern matching, and typeclasses will come to you, but only if you comment, “Thanks, ʎ++ haskal” on my profile.

Cassian && ||
Hamish752
Scratcher
1000+ posts

___ or ___ but not both block

Support.

Cream_E_Cookie
Scratcher
1000+ posts

___ or ___ but not both block

Semi-support, worklaroundable:
<<<1> or <2 >> and <<not <<1> = <2>>> >

Last edited by Cream_E_Cookie (Aug. 1, 2015 23:08:58)


















monstermash3
Scratcher
1000+ posts

___ or ___ but not both block

No support, just use the workaround.
<<<(variable) = [1]> or <(variable) = [2]>> and <not <<(variable) = [1]> and <(variable) = [2]>>>

Last edited by monstermash3 (Aug. 1, 2015 23:15:41)


(Swallowed by an evil kumquat who was just taking a walk in the neighborhood of evil kumquats when they saw a garage sale where they bought a plate which they used to eat but they discovered that it leaked and they went to get their money back but the sale was over so they went in the house but the door was locked so they got their key but it didn't fit so they went home to use the key on the right door which was their own door and then they decided to swallow a signature for no reason.)
Znapi
Scratcher
500+ posts

___ or ___ but not both block

If you want a shorter(and likely faster) workaround that what most people here are posting, do what @TheLogFather posted:
<not <[] = []>>

DadOfMrLog wrote:

…there is a more succint workaround - for your example it would be:
if < not < <X> = <Y> > > then // where X & Y are boolean expressions - why I've left them red, rather than variable orange
blah blah blah script stuff.
end
It's really only one “not” operator more than a built-in “xor” would be, so I don't think a xor operator is needed.

To spell it out again:
< <X> xor <Y> > // category=operators X & Y are boolean expressions
is exactly the same as:
< not < <X> = <Y> > > // X & Y are boolean expressions
See my post above for more examples.
You don't need the extra stuff in the other workarounds.

Powered by DjangoBB

Standard | Mobile