Logic gates / operators

Overview

Logic gates are really important for testing conditions. There your basic AND, OR, and XOR, but there is also NAND, NOR and NXOR gates which make use of the NOT block. We will cover how these work and how to make them in a procedure as well as what the outputs are when conditions fail or are return true. Lets get to it!

Where to find the blocks

So in order to find these blocks you must look under two tabs.

  1. Flow control - for the "If statement"
  2. Logic - for the NOT and logic operator block.

By default the logic operator will be the same color as the NOT block but have the default operation set to "=" You can click on the operation (the = sign) and more options will show.

Conditions

Using a condition generally will require a if statement block and some kind of conditional to test, for example if you stick the is time day directly on to the block the condition will only return true if the time is day. You can change how the output of the the condition returns with logic gates and NOT blocks. Below is a simple condition just testing one condition.

Basic condition

AND

To summarize what and does it requires all conditions to be true. Below is a quick chart to show the outcomes.

Input A Input B Output
True True True
True False False
False True False
False False False

To make a and operation you just need to do the following.

And gate

OR

To summarize what or does it requires at least one of the conditions to be true. Below is a quick chart to show the outcomes.

Input A Input B Output
True True True
True False True
False True True
False False False

To make a or operation you just need to do the following.

Or gate

XOR

Also know as Exclusive OR this requires only one of the values to be true all other values must be false. Also all values can not be true or false.

To summarize what or does it requires at least one of the conditions to be true. Below is a quick chart to show the outcomes.

Input A Input B Output
True True False
True False True
False True True
False False False

To make a XOR operation you just need to do the following.

XOR gate

NAND

Not and gates are a bit different they are the opposite from AND gates in the regard that all values can't be true, they can all be false or have some true and some not true.

Input A Input B Output
True True False
True False True
False True True
False False True

To make a NAND operation you just need to do the following.

NAND gate

NOR

Not or gates are the reversed version of NAND gates, they can't have any conditions return true.

Input A Input B Output
True True False
True False False
False True False
False False True

To make a and operation you just need to do the following.

NOR gate

NXOR

NXOR gates require all values to be true or all values to be false to retune true.

Input A Input B Output
True True True
True False False
False True False
False False True

To make a and operation you just need to do the following.

NXOR gate

Equals

You can also test if both values are the same using the "=" sign this will require both values to be the same exact thing. For example Pig = Pig will retune true, but Pig = Cow will return false because cows are not pigs.

equals

Not Equals

Also you can use the not equals "≠" sign to test if the values are not the same. For example water ≠ lava will return true because water and lava are not he same fluid, but if you try to test water ≠ water this will return false because its the same liquid.

Not equals

NOT

Also just to drive the point across the NOT block can also be used to test for any value that is NOT the condition being tested for. For example time is NOT day, this would be testing if the time is night.

Not block

Using more than one gate

You can also use more than one logic operator and even change the values on some of them to mix and max the settings. Keep in mind though that when you use the NOT block this will effect all values after the NOT block so make sure to structure your conditions in a way where other conditions you need to return true or have different operations are not effected by the NOT block. Below is an example how to do this.

Using more than one gate



Donate to MCreator

By donating to developers you can speed up development, as with more resources, we can dedicate more time to MCreator. It is a free project made by developers working on it in their free time.