Home Getting Started With Scripts Using this wiki Commands CTGUI Global functions Bracket Handlers

IMachine

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

Importing the package

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.

script.zs
import extrautilities2.Tweaker.IMachine;

Add Recipes

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

script.zs
myMachine.addRecipe(inputs, outputs, energy, time, probabilities);

This method uses the following parameters:

NameType
Name
inputs
Type
IIngredient[string]
Name
outputs
Type
IIngredient[string]
Name
energy
Type
int
Name
time
Type
int
Name
probabilities
Type
float[string]

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.

script.zs
myMachine.addRecipe(inputs, outputs, energy, time);

This method uses the following parameters:

NameType
Name
inputs
Type
IIngredient[string]
Name
outputs
Type
Object[string]
Name
energy
Type
int
Name
time
Type
int

Remove recipes

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

script.zs
myMachine.removeRecipe(inputs);
NameType
Name
inputs
Type
IIngredient[string]

Using separate maps for Items and Liquids

script.zs
myMachine.removeRecipe(items, liquids);
NameType
Name
items
Type
IItemStack[string]
Name
liquids
Type
ILiquidStack[string]

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

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:

script.zs
game.setLocalization("machine.crafttweaker:time_machine", "Space Time distorter (Time machine)");

Or add this to a lang file:

script.zs
machine.crafttweaker:time_machine=Space Time distorter (Time machine)