Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
component:crafting:zh [2023/11/03 20:10]
hfsr [Example]
component:crafting:zh [2023/12/10 15:19] (current)
hfsr [函数]
Line 1: Line 1:
 组件:合成 组件:合成
 ================= =================
-此组件由[[item:​crafting_upgrade:​zh|合成升级]]提供,让机器人得以合成物品。此组件可通过`component.crafting`访问。 +此组件由[[item:​crafting_upgrade:​zh|合成升级]]提供,让机器人得以合成物品。此组件可通过`component.crafting`访问。 ​  
- +   
-当组件启用时,机器人会将物品栏的左上角当作合成区域,并尝试在此区域中通过摆放的材料合成物品。若要成功合成,材料的摆放需要与使用合成台合成时完全一致。+当组件启用时,机器人会将物品栏的左上角视为合成区域,并尝试在此区域中通过摆放的材料合成物品。若要成功合成,材料的摆放需要与使用合成台合成时完全一致。 ​ 
  
 {{component:​crafting_area.png|Crafting area}}\\ {{component:​crafting_area.png|Crafting area}}\\
-//(图中的空余槽位即为合成区域)// +**(图中的空余槽位即为合成区域)**
- +
-推荐(但不必须)将此升级与[[item:​inventory_controller_upgrade:​zh|物品栏控制器升级]]配合使用。这样做可以读取物品的名称和类型,以便于找到所需的合成资源。 +
-===== Functions ===== +
-`craft([count:​ number]): boolean` +
-Crafts up to count numbers or a full stack. +
- +
-**count** - How many items to craft. I f omitted then the robot will craft as many items as possible. In any case the robot will never craft more than one full stack of crafting result items at once.\\ +
-**Returns:** `true` if at least one item was crafted, `false` otherwise.\\+
  
-Note that if you specify an amount of items to be crafted that is lower than the minimum resulting stack size (i.E. order to craft 1 stick, but minimum result stack size is 4), then nothing will be crafted, however this will still return true.+推荐(但并非必须)将此升级与[[item:​inventory_controller_upgrade:​zh|物品栏控制器升级]]配合使用。这样做可以读取物品的名称和类型,以便于找到所需的合成资源。 
 +=====函数===== 
 +`craft([count: number]): boolean` ​  
 +合成至多指定数量或一整组物品。
  
-If successful the crafting result will be placed in the currently selected slot, or (if occupied by something else) will be placed into the next slot containing similar items or in the next free slot. This can be one of the slots of the crafting area, which would make it impossible to craft the same item again until that area is cleared.+**count** - 要合成多少物品。若不指定则机器人会尽可能多的合成。任何情况下机器人都不会一次性合成超过一组产物。\\ 
 +**返回值:** 若至少合成了一个物品则返回`true`,其他情况下返回`false`。\\ 
 +   
 +请注意如果你指定的物品合成数小于最低产出数(例如要求合成1根木棍,但是一次最少合成4根),那么将不会合成物品,但是函数仍然会返回`true`。 ​  
 +   
 +若成功进行了合成,产物会被放置到当前选定槽位,或者(若槽位被其他物品占用)放置到下一个有相同物品的槽位,又或者下一个空闲槽位。空闲槽位也有可能在合成区域中,这会使得合成无法继续,直到清空合成区域。
  
 ====样例==== ====样例====