your current location:首页 > news>CC: T+AE2 Equipment Automation [CC: T] CC: TWEAKED MINECRAFT Game

CC: T+AE2 Equipment Automation [CC: T] CC: TWEAKED MINECRAFT Game

2024-12-10 17:48:38|Myriagame |source:minecraft skins

This tutorial is set by the author's setting without permission.

Previous Summary

Because my learning ability is not allowed, I can't understand the high -profile pure AE automation, and the Steve factory does not have 1.12.2 (GTCE, CEU) nor 1.19/1.20 (GTM).Operation, so I thought of using CC: T to allocate the materials distributed by AE to the assembly line.I was thinking about the automation lines made by the big guys with CC: T, CC or OC, and I directly copied my homework. HoweverThe code cannot handle the most troublesome dissipated group of items.

Originally, the code was finished and the problem was solved. So why do you send this tutorial?It is certain to share your experience, and that that, I hope that beginners do not see a bunch of English documents that are not understood. I hope to use the guidance of this tutorial.Turtles learn through practice.The post -class exercises are definitely essential

Show the video here

frame

Do not consider the details of the computer, the turtle, the code, etc., and think about how we allocate items to the input bus from the assembly line when facing the items from AE.

Need a doubt, you need to open the box first [1], see [2] AE sent us what the gadget was sent to us

After that, find jei [3] Of course, you can also be NEI HEI Rei Emi one by one.

Before [5] corresponding input bus bus, put the corresponding items in accordance with the JEI instructions [6] into the input bus

Go back to [7] box, wait for [8] to go to the input bus, there is no items in the input bus, and then synthesize the next item

As for the fluid, the method of using steel barrels and fluids is too abstract, and the model cannot be compiled. It is necessary to use super high "fake synthesis".1.19 and later the body can be distributed with fluids, and more items can be edited. Direct fluids can get the corresponding input warehouse.1.12 There is an affiliated with items and fluids. Even if this subsidiary is not installed, it can be solved violently with a folding AE straight -hair fluid method.In short, the solution of fluid is diverse and does not have technical difficulties, so it is not considered.

Therefore, we only need to use the turtle to complete the eight red moves above, and we can complete the automation of the turtle to send items.

At the same time, it is noted that the action [3] [6] needs to use JEI. Therefore, before letting the turtles move, we need to manually tailor a set of "turtle Ei" for the turtle for its search and use.

Therefore, we get the following large framework:

One or more programs get a synthetic table for the turtles

A program realizes the above eight actions

Implement and technical details

Make turtle Ei for turtles

GetRecipe.lua

TURTLE Turtle .Get gets items Detail details () can tell us the specific information of the items selected. After turning on the turtle, you can enter LUA after turning on the turtle, and then enter turtle, getItemDetail () to observe the results.Such as {count = ???, name = ???, damage = ???}.If we make Temp the output stuff above, then Lua will think that Temp ["Count"] is the things behind the count and other numbers. Temp ["name"], TEMP ["damage"] is the same.At the same time, through many attempts, we can also get equal to that if name and name are equal, damage and damage are equal, then this is the same thing.In this way, we first get a very important judgment whether the two items given are the functions of the same item (professional terms are functions).

 Local Function Equalitem (L, R)

If l ["name"] == r ["name"] and

L ["damage"] == r ["damage"] then

Return true end

Return false

end

If if and then, if L, R's name and and damage are equal, the Return of Return from then to END returns true.The place where the operation is located deleted something behind Return.

Can't understand the support above?It doesn't matter!As long as you know that this action can get L and R corresponding to whether it is the same item, it is equivalent to L == R designed for items.

In order to get the synthetic table, we must have to fill in the items we need from from top to bottom in Jei. For turtles, we only need to do it from left to right to get this synthetic table.There is only one sentence lua statement after a line.

 local t = turtle; t.Select (1);

local h = t.getItemDetail ();

local slot = 1; local list = {};

While H do

Table.insert (list, h);

Slot = slot+1; t.Select (slot);

H = t.getItemDetail ();

end

A new word appeared at first glance, Local.Observe the above program. Only when a "letter" or more professional, the variable appears for the first time.Now, as long as the word is told to tell the computer here to create a new variable named XXX, just like you can enter articles in it only after the new Word document is built, and treat it as a habit.

How do you understand the local T = turtle?T.GetITEMDetail () is the same as turtle.getItemDetail ()?This turtle is almost the same as the TEMP mentioned above, all of which are the structures of {??? = ???, ??? = ???…}, and the operation is equivalent to getting getItemDetail in Turtle in Turtle= ??? ???.Since the value of T is the same as Turtle, the effect of T.XXX (…) is exactly the same as turtle.xxx (...), so it can be understood that Turtle is renamed for abbreviation.

List = {}, everyone must have guessed, this is to build a table similar to Turtle, but it is very simple and empty.As for table.insert (list, h), it is to add h to the list, table.insert ({...}, 1), that {...} will become {..., 1}, inIn the end, one more one came out.

While is the first structure logo we encountered. The formula behind While is true, so we repeatedly execute a bunch of do end, until the formula after the whole is false.And GetItemDetail () has a characteristic that if there is nothing that the grid of the grid is false, the operation between do end is over until the selection grid is not available.T.Select (X) is about to choose a grid to move to X.

Therefore, the operation of the entire While is to obtain the synthetic table of a certain item from the way to scan the grid from the first grid.

Only the synthetic table, our turtle Ei is not enough, because when AE is distributed, we will combine all the things that are not over full. If we only hold this synthetic table for judgmentTherefore, in addition to synthetic operations, our synthetic table should contain a "head", which consists of the type of items, so that after convenience, which item to synthesize.In this regard, we get the following procedures,

 Local slot = 1; t.Select (slot); local I = 1; local h = t.getItemDetail ();

LOCAL Head = {};

table.insert (head, h);

While H do

If not equalitem (h, head [i]) then

I = i+1; table.insert (head, h);

End

Slot = slot+1; t.Select (slot);

H = t.getItemDetail ();

end

Equalitem finally appeared!Obviously, I used to mark the item that was finally added in the head.For head [i], you can understand it like this. Although the head may look like {9,8,7}, there is no xxx = 9, but in fact this structure has been default {1 = 9,2 = 8,3 3= 7}, so we can get the last addition value of head [3] with head [3].In this way, the same items are sieved and the head head has.

Since we may make a lot of items synthetic tables, these synthesis tables need to be stored in files for future use. Therefore

-coded by asqttr

local save = "saves/"; local t = turtle;

local num = 1;

LOCAL FUNCTION EQUALITEM (L, R)

If l ["name"] == r ["name"] and

L ["damage"] == r ["damage"] then

Return true

End

Return false

end

While IO.OPEN (Save..Tostring (NUM), "R") do

Num = num+1;

end

local file = IO.Oopen (Save..Tostring (num), "w");

local slot = 1; t.Select (slot); local I = 1;

local h = t.getItemDetail ();

local list = {}; local head = {};

table.insert (head, h);

While H do

Table.insert (list, h);

If not equalItem (list [slot], head [i]) then

I = i+1; table.insert (head, h); End

Slot = slot+1; t.Select (slot);

H = t.getItemDetail ();

end

file: write (tostring (#Head) .. "

");

for v = 1,#head do

Local u = head [v];

Local out =

U.Name .. '

'..

Tostring (u.Damage) .. '

';

File: write (out);

end

file: write (tostring (#List) .. "

");

for v = 1,#List do

Local u = list [v];

Local out =

U.Name .. '

'..

Tostring (u.Damage) .. '

'..

Tostring (u.Count) .. '

';

File: write (out);

end

IO.Close (File);

Wow!So long, I can understand it!From top to down, OO.OPEN () is to open a file, the front of the comma is the position of the file, and the latter is the form of the opening. R represents the readings. Here is the characteristics of the fake if the file does not exist.EssenceThis is to arrange the synthetic table you added every time in SAVES according to name 1 2 3 ... so to screen to see which one that does not exist., Change the numbers into text, that is, the string, .. It means connecting the two string.Next, open the file that is not found in the writing mode, and build it newly. The back is the core program of previous analysis, which is a synthetic table.The next thing is to write the length of #Head Head and the length of the list, and then write specific information.There are many variants for for, but the most used is as shown above. A certain variable = 1,?, indicates that this variable is obtained from 1? In every cycle, then the meaning of this is to give the head and the head and the head and the head and theThe header and synthetic operation in the list are written into the file.IO.Close (), of course, is to close the file, otherwise you can't write it.

Dump.lua

The synthesis of Turtle Ei has already existed in SAVES, but the real use is the synthetic table group instead of a synthetic table, because generally one ME controller can be matched with multiple items. Our turtles must be composed of the nine items synthesis tables.The synthetic table group is used as a reference.In order to pack the synthetic table in SAVES into a synthetic table, you can get it.

-coded by asqttr

local num = 1; local dir = "disk/saves/";

Print ("where do you want to dump to?");

local ofile = IO.Oopen (IO.READ (), "w");

Print ("Some Description About the Recipe-found:"); Term.setTextColor (colors.gray);

Print ("Press A Single Line of%to Finish Edition the Description.");

Term.setTextColor (colors.white);

local line = IO.READ;

While line == '%' do

Ofile: Write (line .. "

"); line = io.read ();

end

ofile: write ("%

");

While IO.OPEN (Dir..Tostring (NUM), "R") do

Num = num+1;

end

num = num-1; ofile: write (tostring (num) .. '

');

Print ("Dump Start");

for i = 1, num do

Print ("Now is dumping no." .. tostring (i) .. "recip");

Local infile = IO.OPEN (Dir .TOSTRING (I), "R");

Offile: WRITE (Infile: Read ("A") .. '

'); IO.Close (Infile);

end

IO.Close (ofile);

Print () and Term.SetTextColor are used to output the color of the prompt information and change the word. It is almost useless for understanding logic to delete it directly.After removing all the bulls in the flowers, it is easy to find that this program is actually to copy 1 2 3 in SAVES ...number.

Let the turtles move!

Construct a synthetic group

For the sake of convenience, we put the name of the synthetic group we need to join in a certain file, and use the Config variable to represent the open file. Since the file is described as a description of the notes, we need to give it up.See a synthetic table as a unit, unit = {head = ???, OP = ???}, head is the head of this synthetic table, and OP is the synthetic operation.Put the unit table.insert () to the list, and you can save the corresponding synthetic group into the memory. There is a program.

 local list = {};

local opfile = config: read ();

While OPFILE do

OPFILE = IO.OPEN (OPFILE);

While OPFILE: Read () ~ = "%" do end;

Local num = Tonumber (OPFILE: Read ());

For i = 1, num do

Local unit = {}; local head = {}; local op = {}; local tnum = tonumber (opFile: read ());

For j = 1, tnum do

LOCAL TEMP = {};

Temp ["name"] = opFile: read ();

Temp ["damage"] = tonumber (opFile: read ());

Table.insert (head, temp);

End

Tnum = tonumber (opFile: read ());

For j = 1, tnum do

LOCAL TEMP = {};

Temp ["name"] = opFile: read ();

Temp ["damage"] = tonumber (opFile: read ());

Temp ["Count"] = Tonumber (OPFile: Read ());

Table.insert (OP, TEMP);

End

Unit ["head"] = head; unit ["op"] = OP;

Table.insert (list, unit);

End

OpFile = config: read ();

end

~ = It does not mean the meaning, as literally.

wait

Just use os.pullevent ("Redstone") to wait for the end after entering the redstone signal.Therefore, we can use the external redstone signal to control the turtle to stop waiting and start working.

Open the box

Don't open it so elegant, dig the box directly, anyway, the effect is the same.Use turtle.dig () to tap the square in front of the turtle, so you need to face the box when putting down the turtle.change.

Determine the synthetic table

 t.Select (1); t.Dig ();

LOCAL TTT = 0; Local Flag = TRUE;

for i = 1,#List do

Ttt = ttt+1;

Flag = true; local head = list [i] ["head"];

Local slot = 1; local p; local Q;

T.Select (slot); p = t.getItemDetail ();

For j = 1,#head do

Q = p;

Flag = (Flag and equalitem (p, head [j]));

If flag == false then

Break;

End

While Equalitem (P, Q) Do

Slot = slot+1; t.Select (slot);

P = t.getItemDetail ();

End

End

If flag then

Break;

End

end

From the perspective of the synthetic table in order, if the all -in -one is this synthetic table, you wo n’t continue to search for the next.

operate

Go back and put things in the input bus on the top of the head according to the synthetic operation.Special attention, the input bus cannot be facing down.

 local slot = 1; local op = list [ttt] ["op"];

T.Select (slot);

Print ("Start Crafting No.", TTT, "Recipe"); for i = 1,#OP Do

While Not Equalitem (OP [i], T.getItemDetail ())?

Slot = slot+1; t.Select (slot);

End

T.back (); T.DROPUP (OP [i] ["Count"];

end

for i = 1,#OP Do

T.Forward ();

end

T.Select (slot+1);

t.place ();

RunAssline.lua

Finally, plus the external loop and the necessary guidance at the beginning, you can get the final code

-coded by asqttr

local configdir = "asslineconfig";

local log = IO.Oopen ("Log", "w");

local t = turtle;

local config = IO.OPEN (configdir);

LOCAL FUNCTION EQUALITEM (L, R)

If l == nil or r == nil then

Return false

End

If l ["name"] == r ["name"] and

L ["damage"] == r ["damage"] then

Return true

End

Return false

end

LOCAL FIRTENTRYINFO =

"We Notice that it is your first time to run this program," .. "..

"So we will give you a small taron to help you get familiar with it.

"..

"First, count the number of recipe groups you want to load in the turtle," .. ..

"and please input it.";; local if;

if config == nil then

IO.Close (config);

Term.setTextColor (colors.lightgray);

Print (FIRTENTRYINFO);

Term.setTextColor (colors.purple);

Local num = io.read ();

Config = IO.OPEN (configdir, "w");

Term.setTextColor (colors.lightgray);

Print ("next, input the recipe group (s)");

For i = 1, num do

Term.setTextColor (colors.yllow);

IO.WRITE (Tostring (i) .. ':');

Term.setTextColor (colors.white);

Config: write (io.read ("l") .. '

');

End

IO.Close (config);

Term.setTextColor (colors.lightgray);

IO.WRITE ("Your Recipe Group (s) Path now is saving in this config file:");

Term.setTextColor (colors.yllow); IO.Write (configdir .. '

');

Term.setTextColor (colors.white);

Config = IO.OPEN (Configdir);

end

local list = {};

local opfile = config: read ();

While OPFILE do

OPFILE = IO.OPEN (OPFILE);

While OPFILE: Read () ~ = "%" do end;

Local num = tonumber (OPFILE: Read ()); for i = 1, num do

Local unit = {}; local head = {}; local op = {};

Local tnum = tonumber (opFile: read ());

For j = 1, tnum do

LOCAL TEMP = {};

Temp ["name"] = opFile: read ();

Temp ["damage"] = tonumber (opFile: read ());

Table.insert (head, temp);

End

Tnum = tonumber (opFile: read ());

For j = 1, tnum do

LOCAL TEMP = {};

Temp ["name"] = opFile: read ();

Temp ["damage"] = tonumber (opFile: read ());

Temp ["Count"] = Tonumber (OPFile: Read ());

Table.insert (OP, TEMP);

End

Unit ["head"] = head; unit ["op"] = OP;

Table.insert (list, unit); End

OpFile = config: read ();

end

While true do

Print ("waiting for redstone signal ..");

os.pullevent ("Redstone");

t.Select (1); T.Dig ();

LOCAL TTT = 0; Local Flag = TRUE;

for i = 1,#List do

Ttt = ttt+1;

Flag = true; local head = list [i] ["head"];

Local slot = 1; local p; local Q;

T.Select (slot); p = t.getItemDetail ();

For j = 1,#head do

Q = p;

Flag = (Flag and equalitem (p, head [j]));

If flag == false then

Break;

End

While Equalitem (P, Q) Do

Slot = slot+1; t.Select (slot);

P = t.getItemDetail ();

End

End

If flag then

Break;

End

end

local slot = 1; local op = list [ttt] ["op"];

T.Select (slot);

Print ("start crafting no.", ttt, "recipe");

for i = 1,#OP Do

While Not Equalitem (OP [i], t.getItemDetail ()) do slot = slot+1; t.Select (slot);

End

T.back (); T.DROPUP (OP [i] ["Count"];

end

for i = 1,#OP Do

T.Forward ();

end

T.Select (slot+1);

T.Place ();

end

Send a letter

As for when the redstone signal is issued to make the turtle start to work, of course, when there is an item in the box and there is no item in the bus, send the signal to tell the turtle that you should go to work.

Post -class exercise

Try the order of finding in order instead of finding trees or other fast search methods.