Digital CPU 数字化CPU

If you liked this item, please rate it up on Steam Workshop page.

Author: imengyu

Last revision: 19 Jan at 12:17 UTC (1)

File size: 1.96 MB

On Steam Workshop

Description:
Introduction

ONICPU is a CPU mod for OxygenNotIncluded that allows you to build programmable code execution control units to implement complex automation functions.

At present, the original game only has a simple logic gate automation, which will be very complicated when implementing some very large circuits, so i made the this mod, using code to control the automation.

Main functions:

– CPU computing unit, supporting 4 input and 4 output I/OS, 8 input and 8 output I/OS
– The CPU supports assembly code or JavaScript code for control
– Expanded the Logic ribbons /Reader/Writer to support the 32-bit values
– Expanded some sensors that can directly read values and pass them to the CPU for processing
– Digital number display

How to use

The complete user documentation manual has been built into the game’s database and can be viewed at any time during the game.

CPU

You can find the CPU in the Automation menu (need to unlock Automation Tech first), there are currently 3 sizes of CPU:

– 2 Input 2 Output I/O
– 4 Input 4 Output I/O
– 8 Input 8 Output I/O

The left side of the CPU is the input port, the program can read its value, and the right side is the output port, which can output the value and control the downstream connected devices.
The CPU uses a control port (lower middle position) for control, and the unit will only start when the control port receives a green signal. When the CPU is on, your program will execute at a rate of 5 times per second, and during each execution cycle, you can read the input parameters, perform custom calculations, and then modify the output port value.

Due to game code restrictions, all CPU ports support a maximum of 32bit values (Int32).

There are two versions of each CPU, with the (JavaScript) suffix indicating that the CPU is controlled using JavaScript code. JavaScript is easy to use, assembly is more complex but fun, you can choose what you like.

Note: You can’t use a while loop in your code to delay, it will cause the game to get stuck, you should use a variable counter to delay.

Code editor

You can open the editor by selecting the CPU unit and clicking "Write Program" in the right menu. In the editor:

– The top display is the current status information of the program
– Write the code in the left input box
– Upper right corner button control program run, pause.
– The right side shows the real-time program IO value
– In assembly mode, registers and memory data are also displayed on the right
– In JavaScript mode, program output log information is also displayed on the right

It is recommended that you write Code in Visual Studio Code or other Code Editors and then copy it into your game.

Click "Compile" to compile the program immediately, compile will stop running the CPU unit, click "Close" to compile the program and then close.

Tip: Whether the CPU is running is judged by whether the control port has a green signal, but when you manually click Run in the code editor, it is not limited by the signal and will still run.

Digital sensor

This mod extends a series of sensors so that it can directly read values, you can connect it to the CPU, and then you can read values for related processing.

Digital number display

This mod adds a Digital number display, which you can use to display the values in the network. It is divided into three bulidings, which can display 8-bit, 16-bit and 32-bit integers respectively.

Source Code

Source Code [github.com]

Download
Revisions:

Old revisions of this mod are available below. Click the link to download.