Programming logic from [CRT] Crafttweaker Minecraft Game

What is this

It is a CRT tutorial and a programming entry tutorial.

In this tutorial, we will complete some very Cool things!

You only need to add and delete the synthetic table. It is best to use other tutorials to understand the synthetic table operation of various module machines.

In addition, it is best to learn to use/CT Syntax and/CT Hand in the game.

After reading this tutorial, you should still frequently visit docs.blamejared.com. This tutorial will also allow you to learn how to read Wiki (to be written in the type chapter).

variable

Master of arrangement

It seems that a lot of things can be combined with wooden sticks and stones ...

But it seems tortured to hit .Even if you copy and paste, it is bad.

 var cs = ;

var ST = ;

recipes.addshapet (, [

[CS, CS, CS],

[NULL, ST, NULL],

[NULL, St, NULL]]);

recipes.addshapet (, [[[[[[[Stone_axe>

[CS, CS, NULL],

[CS, ST, NULL],

[Null, st, null]]);

Change ~

Variables can naturally change:

 var mat = ;

var ST = ;

recipes.addshapet (, [

[MAT, MAT, MAT],

[NULL, ST, NULL],

[NULL, St, NULL]]);

mat = ;

recipes.addshapet (, [

[MAT, MAT, MAT],

[NULL, ST, NULL],

[Null, st, null]]);

It seems to be useless ...

But in fact, variables can be numbers, with seventy -two changes.

Now we seem to be static, and there seems to be no guy who will change.

But this program can move immediately (?)

constant

Well, the correct writing of the above is a bit of memory.

We should change VAR CS to Val CS.But if you write Val Mat = xxx;

You can't let MAT = a new thing later, because Val explains that MAT is constant.

But this is also a cup of water salary

Cycle, array

Digital cycle

Gauss's primary school math teacher

As we all know, 1+2+3+...+100 = 5050.

But Gauss's "Primary School Mathematics Teacher" didn't seem to know this.

Then let's describe the calculation method of Gauss's primary school math teacher:

 var sm = 0;

for I in 1 to 101 {

SUM = SUM+I;

}

Print (SUM); // Output to Crafttweaker.log

SUM: harmony, numbers.

In Zenscript, when I in a to b (A and B are both integer), I will take A, A+1, A+2, ..., B-1, but not B

Thermal expansion gear

There are many gears in thermal expansion, and have a very stupid synthetic table. For example, why can't silver gears be used to criticize vampires?

So we must delete these synthetic tables.

You need to know:

.definition.makestack (i) is the guy of Metadata under this item.

For example, .definition.makestack (258) is the silver gear, which can also be expressed as

But if i is a variable, you cannot write directly.

After observation, the ID of the thermal gear is thermalFoundation: Material, and the metadata is divided into a few string:

22 ~ 27, 256 ~ 264, 288 ~ 295

Then we just write 3 cycles:

 for I in 22 to 28 {{

Recipes.remove ( .definition.makestack (i));

}

for I in 256 to 265 {

Recipes.remove ( .definition.makestack (i));

}

for I in 288 to 296 {

Recipes.remove ( .definition.makestack (i));

}

Array

What is an array?It is probably a string of similar things.

For example, the input of the disorderly synthetic table is the array of the iingredient.

Build an empty array, the type is xxx, so that there is nothing in it: var a = [] as xxx [];

Build an array with A, B, C, and the type is xx: var s = [a, b, c] as xxx [];

Access elements in the array: s [0], in the above is A.

Note: The setting of the array starts from 0.

Add new elements at the end of the array: s+= d;

80 grains

Why are 80 grains?Because this is a way to manually brush minerals.It can be reasonable to increase production with extreme workbench!IntersectionNow?

The empty level must be in the middle!

But if you don't want 80 in the code?Even Val Fe_n = and 80 Fe_n appear, it is not acceptable!

However, the input of the Extreme Work Station is ingredient [] [], a two -dimensional array.

In other words, it is an array, and every item in it is an ingredient [].

 Val N =  as icodient;

value a = [n, n, n, n, n, n, n, n, n] as lyngredient [];

Val b = [n, n, n, null, n, n, n, n] as lybredient [];

Mods.avaritia.extremeCrafting.addshaped ("Iron Duplication", , [A, A, A, B, A, A, A, A]);

?We change to write, this time with the previous cycle.

 Val T = [] as icodient [] [];

for I in 0 to 9 {{

T+= [] as lyingredient [];

For j in 0 to 9 {{

T [i]+= ;

}

}

t [4] [4] = null;

mods.avaritia.extremeCrafting.addshaped ("Iron Duplication", , T);

Understand?

The colorful flower is 16 -color wool

How to synthesize the colorful flowers if there is no Hua Yaotai?

Gather 16 different colors of wool at the altar!

Don't ask where the rune altar comes from.

 varway = [] as crafttweaker.INGREDIENT [];

for I in 0 to 16 {{

Wools+= .definition.makestack (i);

}

mods.botania.runealtar.addrecipe (. Withtag

List: The array of other people's house

Sometimes the array is not made by us, but the others give us.

For example, all the ores of an item ITEM are a gadget similar to an array, which is obtained with item.ores.

The difference between lists and arrays is that the internal structure of the list is relatively complicated.Therefore, we cannot use [i] to access it like an array.

But we can use each element in the poverty list!

Make the furnace without burning powder!

First, Furnace.all returns all the furnace synthesis tables.Secondly, I as a furnace synthesis table, i.input represent its input raw material, and i.output represents the output raw material.

We then check whether the input item has the mineral dictionary of "xxxdustyy".The method is to use item.ores mentioned above.

Finally, a string St, stolowercase (). Contains ("dust") said:

After replacing all ST uppercase letters with a lowercase, there are 4 continuous 4 letters "dust"

 for I in furnace.all {// can can need synthetic table for j in i.input.ores {// can can need ore

If (J.Name.tologyCase (). Contains ("dust") {// You are!Who are you!

Furnace.remove (I.OUTPUT, I.INPUT); // Send you to leave

BREAK; // Next

}

}

}

Fluid pollution of the smelting furnace

1.12.2 Enderio has a alloy called iron alloy, which is very outrageous.It is probably that the messy things in the alloy furnace will become this thing.

Some people often think about a problem. Will so many fluids in the smelting furnace be mixed?In addition, if some people plug that biomass fluid into the smelting furnace, will it be polluted ...

So I got a few outrageous rules here, of course, the proportion was adjusted:

Ordinary metal+special metal = iron alloy

Ordinary metal+water/magma = melting stones

Organic fluid+water/magma = water/magma

Organic fluid+ordinary metal = melting soil

The code is as follows, ... the table is omitted:

 var base = [] as crafttweaker.liquid.iliquestack [];

Var metala = [] as crafttweaker.liquid.iliquidstack [];

Var metalb = [] as crafttweaker.liquid.iliquidstack [];

Var bio = [] as crafttweaker.liquid.iliquidstack [];

Basic+= ;

Basic+= ;

Metalb+= ;

Metalb+= ;

Metala+= ;

Metala+= ;

Metala+= ;

Metala+= ;

Metala+= ;

Metala+= ;

// ...

Bio+= ;

Bio+= ;

Bio+= ;

// ...

For I in Metala {

For j in metalb {

MODS.TCONSTRUCT.ALLOY.Addrecipe (*7, [i*5, J*2]);}

}

For I in Basic {

For j in metala {

Mods.tconStruct.alloy.addrecipe (*13, [i*9, J*4]);

}

For j in metalb {

Mods.tconStruct.alloy.addrecipe (*13, [i*9, J*4]);

}

MODS.TCONSTRUCT.ALLOY.ADDDDDRCIPE (*13, [i*9, *4];);

For j in bio {

Mods.tconStruct.alloy.addrecipe (i*2, [i*1, j*1]);

}

}

For I in bio {

For j in metala {

Mods.tconStruct.alloy.addrecipe (*13, [i*11, J*2]);

}

For j in metalb {

Mods.tconstruct.alloy.addrecipe (*13, [i*11, J*2]);}

MODS.TCONSTRUCT.ALLOY.ADDDDRCIPE (*13, [i*11, *2];);

}

AE2's UU material!

This idea may be relatively extreme, even more 谔谔: Why do a logistics module require so many synthetic tables?

It should be allowed to synthesize most of the things!

However, some lightning protection and leakage are required.

logic:

All the items of AE2 have a counter c from 0

If you want to keep the items of the original synthetic table, then continue; (directly cycle, this cycle is not needed)

C = C+1

Write C into eight -bit tri -in -making, each of which corresponds to a slot in the synthetic table of 3*3, and the groove constant FLUIX in the lower right corner is used to lock technology.

If it is 0 is a round stone, if it is 1 is Certus, if it is 2 is Fluix.

Code:

 Import Crafttweaker.mods.imod;

Import crafttweaker.mods.iloadedmods;

VAL AE2 = LoadedMods ["Appliednergistics2"] as iMod;

var C = 0 as int;

Val M0 = [, , ] as crafttweake.Item.INENGINT [];

Print (ae2.id);

for I in ae2.Items {

Print (c);

If (I.Definition.id.Contains ("FACADE") {{) {{) {{) {

Continue;}

If (I.Definition.id.Contains ("Material") {{) {{) {{) {

Continue;}

If (I.Definition.id.Contains ("SEED") {{) {

Continue;} // ...

If (i.ores.Length <1) {{

C+= 1;

Recipes.remove (i);

Furnace.remove (i);

Var t = c as int;

Var m = [[null, null, null], [null, null, null], [null, null, null]] as crafttweaker.INGREDIENT [] [];

For j in 0 to 9 {{

M [j/3 as int] [j%3] = m0 [t%3];

T/3 as int;

}

M [2] [2] = m0 [2];

Recipes.addshapet (i, m);

}

}

recipes.remove ();

recipes.remove ();

recipes.addshaped (, [...]);

recipes.addshaped (, [...]);

recipes.addshaped (, [...]);

recipes.addshapet (, [...]);

function

The computer function is:

Enter some data, execute some code, and output some data.

So what can we do with it?

Of course, it is to turn the model into a line of code!

Let's take a look at the format first.

 FUCTION name (parameter1 as type, parameter2 as type, ...) as type {

// Todo}

Name is the name of the function.

Type is the type of parameter/return value.

It is not beneficial to say more, look at an example!

Goblin

The NBT of the strange egg is too long, which is unwilling.

Because CRT made an outrageous sampling example of the printer of AE2, saying that the withering skeleton pressing (not consumed) eggs were withered in the skeleton brushing eggs, so the reader was greatly shocked and made the following works.

 Import Mods.appliednergistics2.Incriber;

Import Crafttweaker.Item.INGREDIENT;

Val Egg = ;

function inegg (AS String, B AS INGREDIENT, C As IINGREDIENT = NULL, D as Bool = False) as void {

// Define in Inegg, A is a monster ID, you can hold the monster egg in the game/CT Hand to see

// B and C are both materials, D indicates whether it is a pressure print, if so

Inscriber.addrecipe ( .withtag ({Entitytag: {id: a}}),,

, d, b, c);

}

Inegg ("Minecraft: Chicken", Egg, Egg);

Inegg ("Minecraft: Sheep", , );

INEGG ("Minecraft: Skeleton", , );

Inegg ("Minecraft: Creeper", , ););

Inegg ("Minecraft: Villager", , );

(Digging)

Qi and blood pearl

We want to define the synthesis of the participation of qi and blood orb on a large scale.

Advanced qi and blood orb should be able to complete the task of low -level qi and blood orb.

But a lot of "or" judgment is too complicated every time.

So we can write a function, enter an integer to indicate the minimum level of qi and blood orb, and output a IINGREDIENT, that is, several types of qi and blood orbs that can participate in synthesis.

 Function Orb (n as int = 1) as ieingredient {

VAR ORBS As IINGREDIENT [] = [. Withtag ({ORB: "Bloodmagic: Weak"}),

. Withtag ({Orb: "Bloodmagic: Apprentice"}), . Withtag ({ORB: "Bloodmagic: Magician"}),

.withtag ({orb: "bloodmagic: master"}),

.withtag ({orb: "bloodmagic: Archmage"})];

Var r asiingredient = ORBS [4];

For I in (n-1) to 4 {

R = r.or (ORBS [i]); // O, indicates that if it is the thing in parentheses.

}

Return r;

}

Automatic formula name

1.12.2 The ultimate workbench must fill in the formula name when the formula is added.

However, in most cases, it is troublesome to fill in manually, and it may be written in the same formula of the same formula.

so……

 Static Numberofsarecipes as int [] = [0];

Function Shapedavaritia (O AS IITEMSTACK, I as IINGREDIENT [] []) as int {

Mods.avaritia.extremeCrafting.addshaped ("Artofenigma9c3blv1orb" ~ Numberofsarecipes [0], o, i);

Numberofsarecipes [0] = Numberofsarecipes [0] +1;

Return 1;

}

Type theory

// Todo

event

// Todo