Jump to content

Digital Crafter

From Advanced Computers Wiki
Revision as of 16:12, 25 August 2026 by GHXX (talk | contribs)
This page describes unreleased, experimental content that is still in development which might undergo significant changes or be removed entirely.

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.

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.