Profile image

[1.7 and above] LOGIC GATE tutorial

106k hpgbproductions  6.6 years ago

--- TEST: LOGIC GATES WITH SP 1.7 ---

Demonstration - CLICK HERE

The new ActivateN inputs can be used with Activation Groups to get some really interesting things to happen.

INTRODUCTION TO LOGIC GATES:

By stacking more than one modded rotator or piston, you can achieve activation parameters so that a system only activates when the specific Activation Groups are turned on.

All Range and Speed settings for rotators and pistons MUST be the same for the system to work correctly. These systems will have the exact same range and speed as a single rotator or piston with the same Range and Speed settings.

Suitable parts for use:
- Rotators, Small Rotators
- Pistons
- Hinge Rotators (AND, NOT, NAND only)
- Beacon Lights (no pistons) (AND only)

The logic gates are:
- AND
- OR
- XOR
- NOT
- NAND
- NOR
- XNOR

Additional Reading

Some parts of this tutorial will NOT cover hinge rotators as they will not work with this system - the object would end up offset from its original position when parameters are only partially fulfilled. Use sideways rotators instead. If a system needs more than ONE gizmo, it won't work with hinge rotators.

If you want a light that can be used with the other logic gates, use a piston system with an activated light that will be pushed through an activated light when conditions are met. You need not do this for AND gates, the XML attributes for lights are good enough.

Set min and max values as required. This tutorial should work with any of such values, as long as they are the same for each gizmo. For most builds, you may want to change min to 0 and leave max at 1.

You will get to use some of these in your more complex creations (I hope anyways).

Note: by using the "original" or "inverted" direction, I mean using the direction relative to your "desired" direction i.e. what you want your creation to do.


AND

Gizmos: 1

The AND gate is where two predetermined AGs must be activated at the same time for a system to work.

For A AND B, a gizmo must have the following under inputController:

activationGroup="A"
input="ActivateB"
zeroOnDeactivate="true" (important!)

The system may be used in beacon lights as well, without needing to push any activated beacon lights past a deactivated one.

activationGroup="A"
input="ActivateB"

The following table shows the parameters required for output:

A B Out
0 0 0
1 0 0
0 1 0
1 1 1

OR

Gizmos: 3

The OR gate is where at least one of the two predetermined AGs must be activated for a system to work. If both AGs are activated, the output is still 1.

For A OR B, the settings required for each gizmo are:

1. AG A Controller:
activationGroup="0" ("None" in Editor)
input="ActivateA"

2. AG B Controller:
activationGroup="0"
input="ActivateB"

3. AND Gate deriative:
activationGroup="A"
input="B"
`zeroOnDeactivate="true"
Invert the piston or rotator direction for this one.

The output table is as follows:
A B Out
0 0 0
1 0 1
0 1 1
1 1 1

For a system that is as common as this in real life, it's pretty complicated.

XOR

Gizmos: 4

The XOR (exclusive-OR) gate is mostly similar to a OR gate, but does not return 1 when both predetermined AGs are activated.

The gizmos used are the same as the OR gate but with one more gizmo. This fourth gizmo is a copy of the third gizmo I listed in the OR gate list (see above).

The output table is:

A B Out
0 0 0
1 0 1
0 1 1
1 1 0 (the main difference from OR gate)

NOT

Gizmos: 1

The NOT gate (inverter) inverts the input activation group for the part. It is the only logic gate using one single AG.

By default, a part with invert=false returns the min value when the associated AG is activated, and the max value when the AG is deactivated.

For NOT A, the settings required for the gizmo are:

activationGroup="0"
input="-ActivateA"

The output table is:

A Out
0 1
1 0

This system is very good for building (and posting screenshots) of systems in an alternate mode.
Example
(shameless self-promotion)

NAND

Gizmos: 1

A NAND (inverted AND) gate has the opposite outputs of a AND gate.

This can simply be built by inverting the directions of the piston or rotator used in the AND gate.

The output table is:
A B Out
0 0 1
1 0 1
0 1 1
1 1 0

NOR

Gizmos: 3

A NOR (inverted OR) gate has the opposite outputs of a OR gate.

This can be built by inverting the directions of all pistons and rotators used in the NOR gate. Remember that for the gizmo which direction is already inverted, the direction should now be the un-inverted direction.

The output table is:
A B Out
0 0 1
1 0 0
0 1 0
1 1 0

XNOR

Gizmos: 4

A XNOR (inverted XOR) gate has the opposite outputs of a XOR gate.

This can be built by inverting the directions of all pistons and rotators used in the XOR gate. Remember that for the gizmo which direction is already inverted, the direction should now be the un-inverted direction.

The output table is:
A B Out
0 0 1
1 0 0
0 1 0
1 1 1


By using logic gates, complex part movement operations can be achieved. "Failsafes" to prevent collision of moving parts, can also be built.

Any designs using less gizmos? Or used logic gates in a creation? Tell me in the comments section below.

  • Log in to leave a comment
  • Profile image
    1,160 Frostx27

    Yay!! I was using logic gates in a game called "Survivalcraft 2". Now I can apply what I've learned from that game here! Thanks for posting this!!

    6.6 years ago
  • Profile image
    8,433 Testin123

    Insert smoke rising from my head here
    Uhh.. what?
    Whatever. I don't understand that stuff, but I'll upvote anyway.

    6.6 years ago
  • Profile image

    Great job. Thanks for sharing with the community. I, myself learned logic gates a year ago in computer engineering course at my highschool, but never thought I could be achieved in SP.

    6.6 years ago
  • Profile image
    29.1k destroyerP

    That is some complex mechanism...

    6.6 years ago