Using OC to implement the unlimited label of the model [AE2] Application Energy 2 (Applied Energistics 2) Minecraft Game

Foreword

One day, you may encounter such a synthesis on the way to writing a model:

At this time, you will find that your model terminal has only 9 grids, which is not enough to put down such a large number of items.Naturally, if you have enough understanding of AE2, you can use this formula to complete this formula using pseudo -synthesis.But is there no other way of dealing with it?


Special thanks

@NYANMAID

@Neutron


Game version

Minecraft 1.7.10

MOD

[AE2] Application Energy 2 (Applied Energistics 2)

[OC] Open Computers

OpenComputers to write AE model

OpenComputers has a certain code compatibility with the ME interface, including modification of the model inside the interface.

OpenComputer brief use method

Installation

The most basic and most important step of OpenComputer is to configure a decent computer.No more described in this article, please move https://www.mcmod.cn/post/154.html.

This time, the parts we need are chassis, display, keyboard, adapter.

adapter

Adaptor (Adapter) is a block used to interact with other MOD devices. Putting it closely to the device can make OC read the information of the device.

Example:

Open the adapter, you can see that there is an upgraded socket inside it, which can be put in various upgrade components.

This time we will need to put a database upgrade to complete the next task.

Database upgrade

The picture corresponds to the basis, advanced, and super database upgrades.

Hold the database upgrade, right -click, you can see the following GUI:

This is the GUI upgrade of the super database. The low -level database upgrade effect will not be different, but the grid can become less.This tutorial directly uses a super database to upgrade as an example.

Among these 81 grids, we can use the items in the backpack to mark any grid, such as marking our first grid with red stones:

At this time, the red stone has been entered into the database upgrade.Now we put the labeled database upgrades into the adapter:

At this point, our computer can call the data in the database through code.

Write the code of the model

You need to use code to write a model. We need to know a string of code:

Component.me_interface.SetinterfacePatterninput

This string of code will be the core of our model we use OC.

Writing a script in OC

After the installation is launched, we should see the following interface:

At this point, we can type Edit to write your first script.

In OC, the method of paste the code is pressed for the mouse roller.

After the editor is completed, press CRTL+S to save the file and press CRTL+W to close the editor.

Call script

After writing a script, as long as you enter the name of your script in the main interface, you can activate the script to run.

Writing a lot of items

Code


component = request ("component")

me = component.me_interface

db = component.database

IO.WRITE ('Number of items Needed:')

nitems = IO.READ ("*N")

IO.Write ('db index:')

dbindex = IO.READ ("*N")

cyCles = nitems // 64;

LastStack = NITEMS%64;

for i = 1, cycles do

Me.SetinterfacepatterNinput (1, DB.Address, DBINDEX, 64, I)

end

me.SetinterfacepatternPut (1, DB.Address, DBIDEX, LastStack, CyCles+1)


Code analysis

Line 1: Introduce the component package.

Line 2, 3: Give variables to simplify the code below.

Line 4, 5: Set the value you type to you in the NITEMS variable.

Line 6, 7: Set the database to make the grid to the grid you type.

Line 8: Calculate the number of cycles.

Line 9: How much items need to be supplemented after calculating the cycle.Line 10-12: Cycles times, add a set of items to the model each time.

Line 13: Add the remaining items to the model.

Use


1. Enter Edit , enter the editor and paste the code.

2. Save and exit the editor and return to the main interface.

3. The item you want to write to the database upgrade, and write down the first grid.

4. Upgrade the database into the adapter.

5. Take a processing model containing your product from the interface terminal.

6. Put this model into the ME interface adjacent to the adapter.

7. Open the display, type , and start the script.

8. Type the number of items you need to put in sequence, which is the first grid of the database.

9. At this time, OC has begun to write a model, waiting for a while, waiting for the loop to complete.

10. When a new editor line pops up, the representative has been completed.

11. Go to the Me interface and take out your model.

Different items of more than 9 grids

Obviously, this formula is also far beyond the 9 -frame capacity of the model terminal, and even the addition of the wide range of the terminal of the leader is not enough to distribute the items and fluid units at the same time.

Of course, we only need to modify the code, and we can also write a formula.

Code

component = request ("component") -Import package


me = component.me_interface -variable

db = component.database -variable

Cell = 16-Start from the 17th grid of the sample to mark the item (adapting to the volatile terminal of the master)

IO.WRITE ("How Many ites in the database do you need to write into the pattern")

ntypes = IO.READ ("*N")-Set the value of ntypes to you

for I = 1, NTYPES Do -The cycle for labeling items

IO.WRITE ("The Number of items Do You Need to Write Into the Pattern") -The number of items you need to put in is allowed

NiTems = IO.READ ("*N") -The value that NITEMS is to type to you

CyCles = NITEMS // 64-Calculate a few times (mark 64 items per cycle)

LastStack = NITEMS%64-how much items need to be placed after the calculation cycle is completed

For j = 1, cycles do

Me.setInterfacePatterninput (1, DB.Address, I, 64, Cell+J)-Cycles times, add a set of items to the model each time

End

Me.setInterfacePatternInput (1, DB.Address, I, LastStack, Cell+CyCles+1) -ee

Cell = Cell+Cycles+1

end

Operation step


1. Writing the same script and won't repeat them.

2. Take out a model, write down the missing part, and put it in the interface.

3. Sign the previous N plaids of the database to marked the items you miss, and upgrade the database into the adapter.

Here the fluid unit is used to store fluids together.

4. Start the script, write the previous n grids of the database in turn, and then enter the number of each time at N times.

5. Take out your model.

The test distribution is fully in line with the order requirements of the assembly.

Conclusion

Using OC, you can theoretically mark unlimited items to enter the model and be highly customized, but there are still small flaws in the current code. I hope to help you, please give you guidance to optimize the code.Note: Starting from the 17th grid in the code is to consider the increase of the GTNH to increase the applicability.

Known BUG:


1. When the number of the same type of items exceeds 32767, an error will be reported to stop running.