Jump to content

Digital Crafter: Difference between revisions

From Advanced Computers Wiki
No edit summary
No edit summary
Line 5: Line 5:


The crafter also come with an inventory of 27 slots from which the ingredients are taken. Extra-results, such as empty buckets when crafting a cake, are returned into this inventory again. The desired output, e.g. the cake, is either pushed upwards (into a block with inventory or ejected), or alternatively returned into the own inventory, depending on the <code>outputIntoOwnInventory</code> argument.
The crafter also come with an inventory of 27 slots from which the ingredients are taken. Extra-results, such as empty buckets when crafting a cake, are returned into this inventory again. The desired output, e.g. the cake, is either pushed upwards (into a block with inventory or ejected), or alternatively returned into the own inventory, depending on the <code>outputIntoOwnInventory</code> argument.
Every crafting operation is instant but may impose a delay that is computed as stated in the description of <code>baseCooldown</code>. The base cooldown of crafting operations is configurable in the mod config.





Revision as of 16:28, 25 August 2026

This page describes unreleased, experimental content that is still in development which might undergo significant changes or be removed entirely.
Digital crafter
Digital crafter
Digital crafter crafting a cake

A block that allows crafting any crafting recipes using a set of Lua functions. Also allows searching for items and looking up recipes by ingredient names or result names.

The crafter also come with an inventory of 27 slots from which the ingredients are taken. Extra-results, such as empty buckets when crafting a cake, are returned into this inventory again. The desired output, e.g. the cake, is either pushed upwards (into a block with inventory or ejected), or alternatively returned into the own inventory, depending on the outputIntoOwnInventory argument.

Every crafting operation is instant but may impose a delay that is computed as stated in the description of baseCooldown. The base cooldown of crafting operations is configurable in the mod config.


Provided component

This block provides the digitalCrafter component, offering the following properties:

DigitalCrafterUD component properties
Name Type Read/Write Description
cooldownRemaining number READ How much more time needs to pass before :craft may be called again.
baseCooldown number READ The base cooldown after each :craft operation. The actual cooldown is given by baseCooldowncraftingRecipeAmount.
DigitalCrafterUD component methods
Name Type Description
:searchRecipesWithIngredient(ingredient:string) recipe[] Returns all crafting recipes that use ingredient as an input. The ingredient needs to be in the format modname:itemname, e.g. minecraft:stick. The result is a table of recipes, where each recipe is again a table that looks like the following:
{
    ingredients={
        {"minecraft:coal","minecraft:charcoal"}, nil, nil,
        {"minecraft:stick"}, nil, nil,
        nil,nil,nil
    },
    result="minecraft:torch",
    resultCount=4
}
The ingredients entry represents a 3x3 grid, left to right, top to bottom.
:searchRecipesWithResult(result:string) recipe[] Returns all crafting recipes that produce the given item.
:searchItemByName(string:partialName) string Returns all item names matching the given query string.
:craft(ingredients:(string|nil)[], resultItem:string, int:amount, boolean:outputIntoOwnInventory) integer If all required items are available, crafts the result. If outputIntoOwnInventory is true the result is put into the own inventory. Otherwise it is pushed into the inventory that may be above, or it is ejected above in-world. Beware that there is no destination check to make sure that there is room in the inventory above, so items may spill if the destination is full.

Ingredients are supplied as a table of entries, similar to the ingredients field in recipes, but with a fixed value instead of a table in each slot. E.g. The recipe above can be supplied as {"minecraft:coal", nil, nil, "minecraft:stick"}. The parameter amount refers to how often this recipe should be crafted. So applying this recipe 3 times and crafting minecraft:torch will try to produce 12 items.

Due to the possibility of recipe.resultCount * amount exceeding the stacksize of the result item, the actual amount of crafted recipes may need to be corrected to be smaller than amount. For ease of use, this corrected, actual amount of crafting iterations is returned. This returned value is referred to as craftingRecipeAmount above.