// Talrey's Guide to Logic Commands

Share your experience by writing tutorials to help other players.
Post Reply
User avatar
Talrey
Entrepreneur
Posts: 86
Location: Garden of the Sun
Has thanked: 8 times
Been thanked: 49 times

Sun Jun 02, 2019 5:59 am

Welcome to version 2.0 of Talrey's Guide to Logic! I was planning on just extending and editing version 1, but the entire logic system has transformed in significant ways, so I decided to start fresh. I'll keep this up to date with future developments unless a drastic shift happens again. Changes will be logged at the bottom of the modified post.

== TABLE OF CONTENTS ==
== CHAPTER 1: Basics of Operation ==

This section will attempt to answer the question of how the Skywanderers logic system operates, as well as provide the groundwork for later exploration of the system's capabilities. I will use the term "circuit" to describe an arrangement of logic components due to the many parallels with real-life electronics, but there is no transmission of power and thus no need for a complete electrical "circuit" as such.

The shortest way to describe Skywanderers' logic system is that it is a "packet-based binary system with instantaneous transmission between tightly-coupled components," but what does that mean? Let's break it down:
  • "packet-based": Each time a logic component wants to update, for example when a switch is flipped, the component decides what the new output value should be and sends a message to the logic network with that value. This is in stark contrast to the kind of system seen in real life and Minecraft, where the output value is a continous emission. However, the system will remember what the last input was, so there's no need to continuously repeat the signal - in effect, the system emulates real-life continuous signals without needing to continuously take up game processing time.
  • "binary system": The system only supports two values, zero and one. I will sometimes refer to zero as a "low" or "off" signal and one as a "high" or "on" signal, a convention taken from the study of electronics in real life.
  • "instantaneous transmission": Every time a packet is sent (that is, a component updates), any connected logic will receive and process that new data within the same game "tick" to update the entire circuit faster than the blink of an eye. This means it can be very difficult to predict which component will activate first when an output is connected to multiple inputs at once. It's easy to deal with this and create predictable ordering with delays, which we'll cover in the next chapter.
  • "tightly-coupled components": In general, a component will only accept one input connection. A Button can flip two Switches, but two Buttons can't flip one Switch. There's a simple way around this, and the next chapter will discuss it at length.
Now that we have some idea of how the system operates "under the hood", we can start building with it. Every logic component is a slightly shortened brick with a symbol on top that indicates what it does. Since the components are bricks, we can fit four of them into the length of one block for a total of 16 per block face. Quite compact, if you choose to build that way. I personally like to put each component in a location and rotation where it becomes easy to "read" the operation of a circuit by following the shapes, but everyone's style is different and there's no wrong way.

There's one last critical step before the system will work, and that's to link it all up. Skywanderers has a dedicated "Link Tool" that looks like a white chevron (>>>) in the menu. This tool is quite handy: not only does it allow us to make and break links between components, but it visualizes all input and output links on a component by clicking on it. To create a link, click on the input component and drag your mouse. A holographic arc will appear and the game will produce a humming sound. The color of the arc, and the pitch of the hum, will change when you drag the mouse to a linkable component. Release the mouse to complete the link - the arc will disappear and you'll hear a chirp to confirm the link. If the link was unsuccessful, you'll hear a buzz instead. To confirm that the link is set, you can click on either component. To delete a link, simply drag from the input component to the output component again as if you were linking it a second time.

In the next chapter, we'll examine each brick component in the system and discuss their operation.

----
Revisions:
01JUN2019 - original post
Last edited by Talrey on Sun Jun 02, 2019 6:05 am, edited 1 time in total.

User avatar
Talrey
Entrepreneur
Posts: 86
Location: Garden of the Sun
Has thanked: 8 times
Been thanked: 49 times

Sun Jun 02, 2019 6:00 am

== CHAPTER 2: Discrete Components ==

This section will act as a dictionary of the brick components in the system, defining their appearance and function. For a summarized reference, click here.

Section 1: Interactive Devices

BUTTON: The simplest device. Generates a high signal whenever it is pressed by a player. Note that it never generates a low signal, unlike buttons in Minecraft or real electronics. It can also be used as an intermediate link, since it will accept an input. The resulting output will match that input.

SWITCH: This toggles between a high and low signal whenever it is interacted with. It can also accept a signal from other logic, in which case it functions as a "toggle flip-flop". Very useful!

HOTKEY: Acts as a Button, except it is bound to a specific keyboard key. Useful for making turrets or giving a ship pilot control of special functions on a ship.

SLIDER: Directly controls a child entity system (rail, hinge, or rotator) by producing a value proportional to the slider's handle position.

Here is a picture of the slider variants (on top), two Switch variants (bottom-left and bottom-right) and the Light Indicator, discussed below.

Section 2: Gates

TIMER: Adds a delay to a system. Any signal input to a Timer will be held for the length of time set in the Timer's menu before being output without change. Note that a Timer cannot hold more than one signal at once - any signals input while it is holding will simply be lost. Also, a Timer cannot be set lower than 0.1 seconds.

LOGIC: While it may seem intimidating or complex at first, this component is the heart of the system. The menu allows you to select which of six logical functions the brick will perform:

OR: High output if any input is high. "A or B".

AND: High output only if all inputs are high. "A and B".

XOR: High output only if an odd number of inputs are high. Short for "Exclusive OR". "A or B, but not both".

NOR: Low output if any input is high. An inverted OR. "not (A or B)".

NAND: Low output only if all inputs are high. An inverted AND. "not (A and B)".

XNOR: High output only if an even number of inputs are high. An inverted XOR. "Both A and B, or none".

Section 3: Entity Control

SEQUENCER: A very useful brick when working with child entity systems (rails, hinges, or rotors). The output can only be linked to child entity systems and will output one of two values (positions or angles) set in its menu depending on whether the input is high or low. Be sure to link it before you set the values, because their allowable range will be shown in the menu once that is done.

QUERY: Can only receive inputs from child entity systems, and outputs a binary signal compatible with the rest of the logic system. Once it has been linked to a child entity system, it can be set to output a high signal when the entity's position is either greater than or less than a specified value. Think of this as the reverse of a Sequencer; where the Sequencer has a logic input and a motion output, the query has a motion input and a logic output.

INDICATOR: A helpful brick shaped like a lamp for building into control consoles. It changes color depending on the state of a child entity system linked into it. Like the Query, it acts as an end point for linking rather than a start point.
In the next chapter, we'll discuss some simple applications of the logic system as demonstrations of its operation.

----
Revisions:
01JUN2019 - added information on Sliders and the Light Indicator
01JUN2019 - original post
Last edited by Talrey on Sun Jun 02, 2019 6:25 am, edited 1 time in total.

User avatar
Talrey
Entrepreneur
Posts: 86
Location: Garden of the Sun
Has thanked: 8 times
Been thanked: 49 times

Sun Jun 02, 2019 6:00 am

== CHAPTER 3: Example Builds ==

This section will not attempt to be an exhaustive list of uses for the logic system because the study of Electronic Engineering exists, as does the internet. What this section will do is provide a few demonstrations of common questions or interesting problems that the logic system can solve.


- Locking Door -

This circuit is designed to allow a door to be opened from either side, but only when a Switch is turned off to unlock it. If you don't need a lock, just omit that part of the circuit to get a normal door.

We'll start with making the door controls. Two Buttons, one on either side of the door, are both wired into an OR gate, which is linked to a Switch. This allows either Button to remotely flip the state of the Switch, which we'll use to control the door's position.

Link the Switch into a NAND gate, and link a second Switch in as well - this is the door lock control. While you could do a second Button->OR sequence for the lock, I'd advise putting the lock Switch in a visible spot or building some other way of displaying that the door's locked. If you don't need to lock the door, then just bypass the NAND entirely. The NAND's purpose is to only allow the door to open when both the lock switch and the door control switch are active. An AND gate would also work here, and will reverse the functionality of the lock switch.

The final piece of the circuit is linking the NAND gate into a Sequencer and linking that into the door entity (whether that's a hinge, rail, or rotator). The Sequencer stores the open and closed values of the door, and will display the maximum and minimum values allowed in its menu.

You can now test the door. If the door locks in the wrong position, swap the values in the Sequencer. If you aren't using a lock on this door, then the position of the Switch linked from the OR gate isn't all that important because it just toggles between on and off whenever a Button is pressed.


- Reversing Sequence | "ABBA" -

This circuit is designed to turn on the outputs in a certain order, but turn them off in reverse order (first on is last off). I'll also cover an expandable "tileable" version for long sequences.

We start with the right side, where the system input (here, a Switch) activates a Logic brick set to OR, because we want it to stay on if the Switch is on OR if the output to the left is on. The OR outputs to our first output and to a Timer. This Timer controls the delay between when our first system turns on and when the second system turns on. That timer feeds into a Logic brick set to AND, because we only want the second output to be on if the first input is on AND the Switch is on. The AND outputs to our second system and also to a Timer leading back into the OR gate, to keep the OR on for a few moments even when the AND turns off.

In the extendable version, we still have an OR gate as the first output and an AND gate as the last output, but the middle is slightly trickier. Output B can't turn on until after output A does, but we also want output C to keep B on after the Switch is turned off. An OR gate is used here to partially fulfill those requirements, as it will be on if the Switch OR output C is on. The OR is linked into an AND gate next to complete the design; an AND will only be on if all inputs are on, so our condition for B to be on is: "if output A is on, AND (output C OR the Switch) is on".

To "tile" or extend this design, put an OR underneath output C's AND and repeat the middle part of the pattern: two Timers, then AND and OR.

There are definitely other ways to do this, by the way, but I'll leave that as - wait for it - an exercise for the student, mwahaha.


- Signal Holding | "Kill-Switch" -

This circuit is designed to stop or hold a signal, preventing it from reaching the intended destination unless an enable signal is high. It will store the signal internally until that happens, so it can be used for data as well - in fact, this design is a form of "Data Flip-Flop" circuitry as seen in real-life electronics, and can be used as such.

The core structure of this design is a pair of NAND gates feeding back into each other to form a stable loop. Skywanderers doesn't like us forming instant loops, however, so we need to put a Timer set to 0.1 on the right side. The data input passes into the first top NAND, as does the enable input, to control whether the data input can reach the second top NAND. Meanwhile, the data input is inverted with a NOR and passes into the first bottom NAND along with the enable input. The result of this NAND is passed to the second bottom NAND, which acts as an inverted output in addition to helping to lock the circuit.

Essentially, what this design does is prevent the second set of NANDs from changing state if the enable input is off, by using the fact that a NAND will only output low if both inputs are high.

Of note here is that even if we say "the second set of NANDs will not change state", the truth is that they're still operating. They just send an output that's identical to their previous state. This can form a "slow infinite loop" where the output of the system passes through our feedback loop and Timer, and updates the whole circuit every 0.1s. This can be problematic for systems that involve Switches (which will toggle endlessly if being controlled by this circuit), as well as for game performance reasons. The "slow infinite loop" can be stopped, however! Where the Timer by itself stops "fast infinite loops", we can add a Sequencer and Query to stop "slow infinite loops". Link the Sequencer into a Hinge, link the Hinge to the Query, and set the Sequencer and Query so that the hinge moves only a very small amount in either direction to trigger the Query. Since the Hinge won't react when it gets an identical input, the Query won't react either and no output will be sent.

----
Revisions:
01JUN2019 - original post

User avatar
Le minaw
Website developer
Posts: 105
Location: Paris
Has thanked: 16 times
Been thanked: 5 times

Wed Jun 05, 2019 11:53 pm

As I removed your pin on your previous topic about the old system, here's a fresh new one. ;)
Thanks for all the work!

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest