Jump to content

Digital Crafter: Difference between revisions

From Advanced Computers Wiki
Created page with "{{Template:Future Content}}Description == Provided component == This block provides the <code>autoCrafter</code> component, offering the following properties: {| class="wikitable" |+AutoCrafterUD component properties !Name !Type !Read/Write !Description |- |<code>containsMainboard</code> |<code>boolean</code> |READ |Returns whether a mainboard is located in the GUI slot. If this is false, most methods will throw an error. |} {| class="wikitable" |+AutoCrafterUD componen..."
 
No edit summary
 
(17 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Template:Future Content}}Description
[[File:Digital crafter block.png|alt=Digital Crafter block|thumb|Digital Crafter block]]
[[File:Digital crafter inventory comparison.png|thumb|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 <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.
 
 


== Provided component ==
== Provided component ==
This block provides the <code>autoCrafter</code> component, offering the following properties:
This block provides the <code>digitalCrafter</code> component, offering the following properties:
{| class="wikitable"
{| class="wikitable"
|+AutoCrafterUD component properties
|+DigitalCrafterUD component properties
!Name
!Name
!Type
!Type
Line 10: Line 18:
!Description
!Description
|-
|-
|<code>containsMainboard</code>
|<code>cooldownRemaining</code>
|<code>boolean</code>
|<code>number</code>
|READ
|How much more time needs to pass before <code>:craft</code> may be called again.
|-
|<code>baseCooldown</code>
|<code>number</code>
|READ
|READ
|Returns whether a mainboard is located in the GUI slot. If this is false, most methods will throw an error.
|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"
|+AutoCrafterUD component methods
|+DigitalCrafterUD component methods
!Name
!Name
!Type
!Type
!Description
!Description
|-
|-
| style="white-space: nowrap;" |<code>:getMainboardTier()</code>
| style="white-space: nowrap;" |<code>:searchRecipesWithIngredient(ingredient:string)</code>
|<code>integer</code>
|<code>recipe[]</code>
|Returns the tier of the mainboard, ranging from 1 to 3.
|Returns all crafting recipes that use <code>ingredient</code> as an input. The ingredient needs to be in the format <code>modname:itemname</code>, e.g. <code>minecraft:stick</code>.
The result is a table of recipes, where each recipe is again a table that looks like the following:<syntaxhighlight lang="lua">{
    ingredients={
        {"minecraft:coal","minecraft:charcoal"}, nil, nil,
        {"minecraft:stick"}, nil, nil,
        nil,nil,nil
    },
    result="minecraft:torch",
    resultCount=4
}</syntaxhighlight>The <code>ingredients</code> entry represents a 3x3 grid, left to right, top to bottom.
|-
|-
| style="white-space: nowrap;" |<code>:setUefiData(data:string)</code>
| style="white-space: nowrap;" |<code>:searchRecipesWithResult(result:string)</code>
|<code>void</code>
|<code>recipe[]</code>
|Sets the executable [[UEFI]] data to the given string.
|Returns all crafting recipes that produce the given item.
|-
|-
| style="white-space: nowrap;" |<code>:getUefiData()</code>
| style="white-space: nowrap;" |<code>:searchItemByName(string:partialName)</code>
|<code>string</code>
|<code>string</code>
|Returns the executable UEFI data.
|Returns all item names matching the given query string.
|-
|<code><nowiki>:craft(ingredients:(string|nil)[], resultItem:string, int:amount, boolean:outputIntoOwnInventory)</nowiki></code>
|<code>integer</code>
|If all required items are available, crafts the result. If <code>outputIntoOwnInventory</code> is <code>true</code> 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 <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. This returned value is referred to as <code>craftingRecipeAmount</code> above.
|}
|}
{{Navbox content}}

Latest revision as of 14:00, 26 August 2026

Digital Crafter block
Digital Crafter block
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.