An IMachine is the actual machine object, you can get it from the IMachineRegistry.

Импорт пакета

Link to импорт-пакета

It might be required for you to import the class.
You usually only need to import a class when directly using the name, such as in casting or Array Declarations but better be safe than sorry and add the import.

ZenScript
Copy
import extrautilities2.Tweaker.IMachine;

There are two methods for adding recipes, one uses a probability map for the outputs, one allows for the use of WeightedItemStack and WeightedLiquidStack objects.
Both methods use maps with strings as indices.
These strings will be the names of the input/output slots given, which is why you should not have two slots with the same name in a machine.

Using a probability map

Link to using-a-probability-map

ZenScript
Copy
myMachine.addRecipe(inputs, outputs, energy, time, probabilities);

This method uses the following parameters:

НазваниеТип
Название
inputs
Тип
IIngredient[string]
Название
outputs
Тип
IIngredient[string]
Название
energy
Тип
int
Название
time
Тип
int
Название
probabilities
Тип
float[string]

Using only the outputs map

Link to using-only-the-outputs-map

You can also only use the outputs map, then ExtUtils2 will check for any WeightedItemStack and WeightedLiquidStack objects and use their chances.
Remember, that adding anything other than those two or IIngredient as mapped value, will have no effect.

ZenScript
Copy
myMachine.addRecipe(inputs, outputs, energy, time);

This method uses the following parameters:

НазваниеТип
Название
inputs
Тип
IIngredient[string]
Название
outputs
Тип
Object[string]
Название
energy
Тип
int
Название
time
Тип
int

You can also remove recipes. Again, you use maps with strings as indices.

There are two methods, one uses IIngredient as values, and one that accepts a map with IItemStack and a map with ILiquidStack values.

Using IIngredient

Link to using-iingredient

ZenScript
Copy
myMachine.removeRecipe(inputs);
НазваниеТип
Название
inputs
Тип
IIngredient[string]

Using separate maps for Items and Liquids

Link to using-separate-maps-for-items-and-liquids

ZenScript
Copy
myMachine.removeRecipe(items, liquids);
НазваниеТип
Название
items
Тип
IItemStack[string]
Название
liquids
Тип
ILiquidStack[string]

Retrieving machine information

Link to retrieving-machine-information

You can also retrieve some information on the machine using the following methods:

  • getInputSlots(): Returns all input slots as a List of IMachineSlot.
  • getOutputSlots(): Returns all output slots as a List of IMachineSlot.
  • getSlot(): Returns the IMachineSlot matching the name.

Naming the machine

Link to naming-the-machine

So far, all our machines will be named machine.crafttweaker:your_machine_name where your_machine_name is whatever name you used to create the machine.

If you want the machine name localized, use either CrT's IGame capabilities or a custom lang file.

So if your machine name was time_machine, you would need to either call this in a script:

ZenScript
Copy
game.setLocalization("machine.crafttweaker:time_machine", "Space Time distorter (Time machine)");

Or add this to a lang file:

Copy
machine.crafttweaker:time_machine=Space Time distorter (Time machine)