Scrap Mechanic

Scrap Mechanic

Not enough ratings
Creating and compressing circuits
By Amy
Learn how to prepare, wire, scan, and save compressed circuits with the Circuit Creator Mod.
2
   
Award
Favorite
Favorited
Unfavorite
About this guide
This guide aims to demonstrate how to use the Circuit Creator mod with a simple and small sample circuit.

You'll learn the following:
  • Setting up, scanning, and saving a circuit
  • Interfacing with and verifying the circuit's IO
  • Notes and limitations
Prerequisites
You're required to own a legitimate copy of Scrap Mechanic. Subscribe to the Circuit Creator mod and preferably have already knowledge about digital logic.

The mod extensively uses the debug console to output additional relevant information. Launch the game with the -dev argument to display the debug console.

You'll encounter frequent digital logic terminology, be sure to look up unfamiliar terms. All About Circuits[www.allaboutcircuits.com] is a great resource for getting started with digital logic, harbouring a range of useful information. The relevant volume for this guide is "Vol. IV - Digital".
Building a circuit
A circuit is made up of multiple logic gates connected with each other in a manner to achieve a specified behaviour. The behaviour describes the output based on the given inputs and prior state.

Both combinational and sequential circuits are supported by the Circuit Creator mod.

Circuit definition
For this guide the circuit's behaviour is defined to accept four input signals and set four output signals. Input and output represent actual numbers as a binary coded number, with the left most pin as the least significant and the right most pin as the most significant bit.

An input of less than 5 (input < 5) is passed unchanged to the output (output = input), whereas for an input greater than 4 (input > 4) we add 3 to it and pass that (output = input + 3).

Building the circuit
The following picture shows our circuit built with logic gates:


Input/Output (IO) gates are coloured with a unique colours so that we can control the final mapping of the pins and easily retrieve them later. Chose your colours as you see fit, remember to use a unique colour for every IO gate for the mapping to work.

Input gates must have no other incoming connections and output gates must have no other outgoing connections, otherwise the scan process fails as it's not meeting the scanning criteria.
Setup, scanning, saving
During the scanning an internal representation of the circuit is created. Ensure that all gates of your circuit are reachable from any input gate. Unreachable gates won't be included in the final representation. Any error will be displayed in the debug console if the circuit hasn't been scanned.

Setup
Place a circuit block anywhere on your creation. Connect all the circuit's input gates to the circuit block. The connections must point away from the circuit block and towards the input gates as seen in the image below.


Scanning
The only incoming input connections must be the ones from the circuit block. Output gates can only correctly be identified if they have no outgoing connections. Press [Use] on the circuit block and select "Scan" to start the scan. Depending on the circuit's size this might take a while. After a successful scan the amount of internal gates (nodes) and connections (edges) will be displayed.

Saving
You can safely disconnect the circuit block from the scanned circuit by simply detaching it from the creation. Be sure to save it as a blueprint so you can reuse it later without risking losing the scanned circuit if the block is destroyed.
IO interface
To use the final circuit we need to interface with its IO, which is achieved with the provided IO blocks.

Within the inventory, the input block is green, whereas the output block is blue.

Preparing the IO
As you might remember, this circuit has four inputs and outputs. First, place down the respective amount of IO blocks.

Next, paint the IO blocks exactly as they've been coloured during the scanning process This colouring functions as a mapping to the circuit's internal IO interface.

Connecting the IO
Using the connection tool, connect the input to the circuit block, so the connection arrow points from the input to the circuit. Repeat with the output block so that the connection arrow points from the circuit to the output.

Provided you've correctly painted your IO blocks, the connection order is irrelevant. The mapping will be undetermined for similarly coloured IO blocks. In that case use the Gate Tagger to cross reference the IO blocks with the original circuit.


Verifying the IO
In cases where you weren't able to map IO gates to unique colours, you're able to cross reference the IO interface's IDs with the original circuit's IO gate IDs using the Gate Tagger block.

To display the IDs place the Gate Tagger block anywhere.
Toggle the ID display by pressing [Use] on it. An alert message will be displayed informing you that IDs are displayed or hidden. Hover your cross hair over any logic gate to see its ID.


The next image shows the corresponding IDs of the original circuit's and the circuit block's IO, verifying that the correct IO has been mapped.

IO block's colour can be changed, causing it to remap if an internal pin is available. A message in the debug console is shown when successfully connection IO blocks to the circuit.
Notes and limitations
This mod is in an early stage of development and could have game breaking bugs. Use it in a new world and save your creations prior to using this mod. Backup your worlds and creations to prevent potential loss.

Limitations
Respawining the original vanilla circuit assigns different IDs to its gates. This makes it difficult to cross reference IDs at a later point. Only cross reference IDs of the original circuit with the compressed one. This game limitation currently can't be circumvented by the mod.

Notes
Launch the game with the -dev argument in order to see the debug console and see the log output of the mod. The debug console provides valuable information should you encounter bugs or unexpected behaviours. Use that information if you issue a bug report.

If you share circuit blueprints on the workshop, kindly provide a description and mapping table of your circuit ☺!
4 Comments
Amy  [author] 18 Apr, 2021 @ 11:27am 
@Mushroom, this mod only supports logic gates.
You can't miss that it's about digital logic, while reading ;)

If you have feature requests though, feel free to put them in the discussion that you can find on the Circuit Creator workshop page, since I'm not following the comments over here regularly. :steamhappy:
Mushroom 18 Apr, 2021 @ 9:39am 
I couldn't find a way to let it output numbers using number logic from The Modpack (although it did scan successfully). I think a great addition would be number inputs and outputs
Natejoestev 4 Feb, 2021 @ 3:55pm 
I love the idea. but i can't get it working could you make a video explaining how to use it better.
michael australium 28 Jan, 2021 @ 5:10pm 
sus:tyhelmet: