Digital Crafter: Difference between revisions
No edit summary |
No edit summary |
||
| Line 14: | Line 14: | ||
|READ | |READ | ||
|How much more time needs to pass before <code>:craft</code> may be called again. | |How much more time needs to pass before <code>:craft</code> may be called again. | ||
|- | |||
|<code>baseCooldown</code> | |||
|<code>number</code> | |||
|READ | |||
|The base cooldown after each <code>:craft</code> operation. The actual cooldown is given by <math>baseCooldown \cdot \sqrt{craftingRecipeAmount}</math>. | |||
|} | |} | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 47: | Line 52: | ||
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 <code>{"minecraft:coal", nil, nil, "minecraft:stick"}</code>. The parameter <code>amount</code> refers to how often this recipe should be crafted. So applying this recipe 3 times and crafting <code>minecraft:torch</code> will try to produce 12 items. | 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 <code>{"minecraft:coal", nil, nil, "minecraft:stick"}</code>. The parameter <code>amount</code> refers to how often this recipe should be crafted. So applying this recipe 3 times and crafting <code>minecraft:torch</code> will try to produce 12 items. | ||
Due to the possibility of <code>recipe.resultCount * amount</code> exceeding the stacksize of the result item, the actual amount of crafted recipes may need to be corrected to be smaller than <code>amount</code>. For ease of use, this corrected, actual amount of crafting iterations is returned. | Due to the possibility of <code>recipe.resultCount * amount</code> exceeding the stacksize of the result item, the actual amount of crafted recipes may need to be corrected to be smaller than <code>amount</code>. For ease of use, this corrected, actual amount of crafting iterations is returned. This returned value is referred to as <code>craftingRecipeAmount</code> above. | ||
|} | |} | ||
Revision as of 16:12, 25 August 2026
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:
| 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 .
|
| 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
}
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 Due to the possibility of |