A Literature Society OC installation+basic command+try to understand and use simple command programming (Chapter 1) [OC]

This tutorial is set by the author to use the CC By-NC-SA protocol.

Zero: Foreword

In fact, there have been many big guys who have written similar tutorials before. I did n’t have to write a machine, but think about it, it ’s easy to install the machine to make it comfortable.This article will talk about how to do it and talk about these rules.

Use version: MC 1.12.2, OC 1.7.7


One: installation

This part can refer to the "Open Computer User Manual" built -in game.

1. Preparation items

You have to prepare three aspects: "energy", "machinery" and "components".

In terms of energy, you need to prepare a stepping power capacitor or energy converter to supply the entire system.Also count the cable and (option) capacitance

Among them, energy converters are recommended to generate electricity.Because stepping on power capacitors need to stand at least two sheep above (power generation speed 3/s) or two leopard cats (power generation speed 6/s) to generate electricity ...The power generation capacitor is fine, but as long as you just point high -intensity such as robots or something, it is not enough to step on the power capacitor.Energy converter is the energy sources in other mods into energy used by OC and injected into the grid.

Most machinery comes with a capacitor that can save 500 electricity, and the capacitance itself can save 1600 electricity.The capacitance can increase the amount of electricity in a single capacitor in the way of stacked together.The calculation method is: the number of capacitors within one and back and forth, up, down, left, left, and back, the number of capacitors that have not been calculated in the upper and lower left, left, left, and backward, up, down, left and right.For example, the 3 capacitors are lined up in a row, and the leftmost capacitance is used as the calculation benchmark. The capacitance is detected on the right.The capacitance is far from the far left, so it is the upper limit of the 1*400.Then the upper limit of the capacitor at this time is 1600+800+400 = 2800.The position of the equal lines at the top right is not tight, so it is a long distance from the capacitance.The capacitor can also be detected in one grid, and at this time, only +400 power is limited.

Cable has two functions: do data cables and energy lines.Energy line, as the name suggests, supply mechanical energy.The data cable can be used as a network cable or something, it is used for data transmission between multiple devices.At present, you only need to remember that there are two cables we can't see in the cable. I will talk about why they understand separately.

The mechanical part is the core block of the computer. According to the minimum configuration, you have to prepare a basic case, a basic display screen, a keyboard, and a disk drive (my translation is a floppy drive).

The basic chassis is the core, and other items need to be posted as possible to put it as much as possible ... Use the cable as far as possible.Among them, the keyboard does not need to be posted by the chassis, it must be sticked at the display.When the display and the keyboard are packed together and the system is detected, right -click the keyboard or screen to open a GUI.If you are not right or not recognized, you will not jump out of any GUI.This set is an initial computer. In the later period, you only need a basic chassis, a basic display, and a keyboard to form a computer.

Of course, there are not only computers in OC, but also tablets, single -chip machines, robots, drones, servers, etc. These things will be mentioned in the back.The first part only talks about the most basic ordinary computers.

Next is the key part: component.In order to ensure that a minimum matching computer can be turned on, you need: a central processor (CPU), a basic disk drive, a T1 -level memory bar, an Eeprom (LUA BIOS), an OpenOS.Well, these can make you turn on.(^v^)

It can be turned on, but you can't see anything, so you need a basic graphics card to make the screen display what the computer is doing.For safety reasons, you can prepare another analyzer, which allows you to check the grid, physical address and error.

2. Installation

We have the simplest, the easiest, startup computer.

First, we want to install the energy system.I use the IC2MOD (Industrial Age 2) here to supply the system.

From left to right, the creation mode generator, copper insulation cable, energy converter, and capacitance.Tip: The capacitor can be equal to the cable.Now, the energy part is completed.

The next step is to install the mechanical part.From left to right is a floppy drive, the basic chassis, and the basic display.A keyboard is placed in front of the basic display.

The cables here are casual, mainly to let readers know that they want to boot as long as the chassis can be powered on.

We then started to rotate components.First open the floppy drive and put the OpenOS soft disk in it.You can use this floppy disk as a system to start a USB flash drive, and contain a system of Linux.You can also hold this soft disk Shift+right -click and insert it directly.

Then we right -click to open the basic chassis and start filling the remaining components we prepared before

This is nothing like installing anything.When your mouse moves to a certain field, the items that can be placed in the field will be high in your backpack.Conversely, when your mouse moves to a certain item in your backpack, if it can be put in, the correspondingly placed field will be high.

The far left field is placed EEPROM (LUA BIOS), that is, it can be wiped and programmable.This chip stores the bottom -level system (BIOS), in this MOD, it stores LUA's BIOS.In reality, the first picture you saw when you turned on the computer was this.It is responsible for the entire computer's hardware -level self -inspection, input and output, and provides the bottom layer of control over hardware.The operating systems we use such as Windows and Linux are actually based on BIOS.In this regard, it involves the principles of computer at the bottom of the computer. If you are interested, you can search for things yourself.

I don't need to say the power key in the middle, right?

There are three columns on the right.The first column is called a card slot, which is used to place additional accessories.The computer was originally called a calculator, but it was used to calculate mathematics. This part was responsible for the CPU.Then its other functions need to be installed with other hardware to complete, such as network cards, display images require special graphics cards, etc.This is a bit different from reality, but don't care about it.

The first one in the second column is the CPU position, and the following two are the memory (RAM) position.The third column is the position of the hard disk.Both the hard disk and memory bar are stored. Why should two be separated?Because the CPU reads and write data from the hard disk is too slow, although the hard disk can store a lot of data.Therefore, the CPU needs a memory barrier to speed up reading and writing.The memory of the memory bar is very fast, but only a little data can be stored.This is the same as reality.

After all assembly is completed, it should be like this:

After the installation is completed, click the power button in the middle, the computer is bright green, and the power is successful.Congratulations, you will assemble your computer.

2.5. An error analysis of the assembly part

Q: I didn't show anything on my screen.A: You didn't install a graphics card?

Q: After pressing the boot, I shut down two times without prompting any problems.

A: Pick up the analyzer, sneak in the chassis+right -click, and a bunch of information will be jumped out of the chat box. If the previous error is the beginning of NO BIOS FOUND, then your EEPROM is not put or put on the left.

Q: After pressing the boot key, the computer runs two sounds. Two shutdown is turned off. NO Bootable Medium Found appears.

A: Are you sure the computer reads the OpenOS system?See if the floppy plate is right?See if the disk drive is close to the chassis or can be connected to the chassis via cable?Or is your disk not installed the OpenOS system?

If you are sure that everything is fine, but there are various strange errors, then all the blocks are removed again, and there are still questions, I can do nothing, ask the author.

3. Installation system

The computer finally started running normally after dripping.It looked at the disk first, without the system, okay, it went to find the OpenOS startup, found it, started reading the content of the soft disk, and finally the computer entered the following page

This page is divided into 4 parts

The first part is the red line in the white frame. Here are: This is the OpenOS system, version 1.7.7, and the memory supported by this computer is 192K.

The second part is the red line in the white frame. Here is a small prompt given by the system author, and every time it is turned on, it will change.This prompt is that it will consume less electricity when the computer does not run much.

The third part is the on top of the red line under the white frame. This is said that you start the system by starting the disk. Go to enter the Install and restart the system to install it.If you don't do this, then there are only files in many places that can only be written and cannot be read.

The fourth part is the red line below the white frame. This is where you lose the command.#Is currently under the home folder, which is the folder that jumps to the jump to after the default.

So, now you have to enter Install and start installing the system to your hard disk so that you can write some code later.If it jumps out of No Writable Disks Found, Aborting prompt .............. Are you sure you install a hard disk?

After the input is completed, the system starts searching for things that can be installed.We generally have only one OpenOS that can be installed, so it asked: Install Openos? [Y/n] Do you want to install OpenOS?Determine the input Y and deny the input n.Then we are of course y

Next, it should search for a few hard disks you can choose to install on different hard disks (such as you can install the system D disk in reality).But we only prepared a hard disk for it here, so it installed this hard disk by default.

After a while, it should be prompted by Installation Complete! Reboot now? [Y/n] installation is complete, do you want to restart now?We certainly choose Y to determine the restart now.Sometimes, it prompts that the installation fails, don't worry, this is because we only use a memory bar, the memory is too small.We can usually come again.

After restarting, the third part of the above page should disappear.In this way, we have successfully installed it.

Tip: If you suspect that entering a complete command is a bit troublesome, you can enter the first 3-5 letters of the command and click the TAB key. This is called automatic supplement command, which will greatly make you more comfortable.

Now, your system is installed, and the system disk is useless, you can put it away.The system will now read and start from your hard disk.

4. Supplement

Your computer has "complexity" or "support connection number".In the game, the number of connected numbers is calculated according to the component of the readable machine+the internal component of the chassis, and the complexity is determined by the level of the component or upgrade.Excellence will cause shutdown or unable to assemble.At present, we only talk about "supporting connection numbers", and the complexity is used in the later drones, robots and single -chip machines.Tell you one thing secretly: the more things displayed on the screen, the more power consumption, so remember to shut down at hand -v-

2. Common commands of the operating system and your first program

1. Operating system directory

Look at the tutorial of the big guy, this has been written very complete.I can't come directly to Copy, right?

OpenOS operating system directory structure- [OC] Open Computers (Open Computers) -MC Encyclopedia | The largest MINECRAFT Chinese MOD Encyclopedia (MCMOD.CN)


One thing to pay attention to is that the system is similar to Linux, you can use a large part of the linux commands.Built -in a language LUA.When you run a file, use Lua to run by default.

2. Commonly used commands

There are spaces between most commands, pay attention to space!

You can use the arrow key back and forth to put the command you lost before.

CD XXX jump to the XXX folder, such as CD /USR jump to USR folder, CD /jump to the outermost directory, CD ./test jump to the test folder, CD ../Jump to the previous folder (return to the previous level)

LS -L lists everything in the current folder, and nothing will display anything.(Use list instead when low memory).

The picture above is the contents of the LS -L, which is divided into 4 columns.The first column is the file attribute. D means that this is a folder. F means that this is a file. R means that this thing can be written. W means that this thing can be read.The second column is the size, and only the file will calculate the size.The third column was the last modification time (I don't know if this is a real time or in the game, it is weird).The fourth column is the name of the file/folder.

Mkdir XXX creates a new directory called XXX.

RMDIR XXX deletes an empty view list called XXX.Note that the CP XX YY copy file or directory from XX to YY.Example: CP A B copys a copy of the file A and named B, CP/HOME/A TMP/B copy the files in the folder home A to the folder TMP and named B.Usually add a -i at the end to automatically check whether there is a file with the same name, so as not to cover your hard -to -write code by mistake.

RM XXX delete files or directory, usually using this delete file.(Destroy the dedicated command)

MV XXX YYY mobile file and directory, or modify the name of the file and directory.

Edit XXX built -in editor, if there is no XXX file, it will be newly created, and it will be modified if there is.The same name but different vessel names are counted as different files.After entering, Ctrl+S is saved, and CTRL+W is closed (whether or not it is stored).It's a bit like Vim.

Cat XXX quickly views what is written in the file XXX, and it will "brush out" what the file is written in the file at a very fast speed.

DF view the disk to access.The name is the physical address of the disk

Rebote immediately restarted the computer.If your computer has strange problems after restarting the game, try this.

3. Your first code

Before starting to write code, don't forget that I said that this is the minimum configuration that can ensure the opening of the computer. However, if you want to program, you need to improve its memory and add a memory bar. T1 is enough.Remember to restart the computer for the application of hardware changes.

Let's enter the edit XXX.LUA in the directory where the home folder, that is, the directory where the boot is located. XXX can be any of your own name. The .lua was to ensure that you can recognize it as a LUA file later.

Later, we entered Print ("Hello World");

Note that all of them must be English mode.

Subsequently, Ctrl+S saved, Ctrl+W exit, enter the name you just started, and output Hello World on the screen.Full of Vim flavor.

You are already programming, go as a bald programmer

4. How to destroy your good friend computer and make him look aggressive

Delete the outermost init.lua, which is the lowest level.Delete a file in the Boot folder, which is intermediate.Set a program that allows it to restart the computer, or restart the computer after a period of power. This is advanced.

Don't say what I taught you, all you realized.(Manual funny)

Third, understand and use other people's API

Seeing this, you must really want to get started by yourself, right?First of all, you should understand the manual?Then understand the lua language, right?Let's "quickly".First look at the official manual.OpenComputers's official documentation

1. A simple applet

Let's first use the simplest applet to complete this teaching.What we want to do this time is to read the items in a box and output its name.

So, we need to see how to access a box: need a adapter block to "interact" with the block in the MC.In the instructions, the adapter can connect and connect the supported components into the network ... but the box is not a supported component. What should I do?Below is mentioned below, you can add more detailed information to access the item bar controller, then let's try it.There is an API on the page corresponding to this item, which is just a command to read a grid item name.The command to read is getstackinslot (size: number, slot: number): table.Translate, getstackinslot is the name of this command. In parentheses, the data you want to enter. The final colon+name actually means that it will return to you some data. The data exists in the form of table (table).So what is SIDE?According to the inquiry, this is a data set by the author to represent the items of which side, from 0 to 5 represents the bottom, top, back, front, right side, and left side.Where is slot?It is a slot value, translate, which is the first grid.There is a Number behind SIDE and Slot, indicating that this should be a number that is filled in.

Look at the example below the tutorial page, what does local do?It is used to represent a variable.Require () What do you do?In a check, it is used to apply for the library (code) written by the author.Then, according to the instructions, first of all, we must first apply for the component library written by the author, and then select the component name of the component library inventory_controller, and then call the command in this component to getstackinslot (), enter the direction corresponding to your box,Then use a variable to store the data returned by the command, and then print () to output the data ... and so on. Is the number and code output?What's this?This is actually the memory address, it does not really release the data stored inside.So how to call the data in Table?Check it, it turned out to be called by table.I want to output the name of the item, where is the name of the name of the item?The name is Label.Try to output it, no problem.I also have to consider that if the output is empty, then it will report an error, so I have to use the IF to check whether it is empty.


In the end, the code is like this.

 local com = require ("component");

local IV = Com.Inventory_Controller;

local data = getstackinslot (0,1);

if data then

Print (data.label);

else

Print ("Nothing or E error");

end

I guess, you must want to copy it directly ... No problem, copy the code above, and press the mouse key to paste in the game by default.Unfortunately, I didn't find how to copy the code in the game.

If you have learned some programming, you should be able to keep up with my thinking.Because the programming lecture was slightly complicated, I updated it later that it was more suitable for tutorials that did not understand the programmers at all.If you install Jei Mod, you can view its built -in mini English version of API by looking at a way to make a component.For example, there is an API of the interface display network card in the interface where the network card can do.