Skip to content

配方

獲取配方

GetRecipeSet

lua
recipe = GetRecipeSet(index)

獲取一組配方

提示

需提前在配方管理頁中新建或匯入配方並設為預設

引數

引數型別描述
indexInteger 整數配方索引

返回值

返回值型別描述
recipeTable 表配方,失敗返回nil

切換配方

SwitchRecipe

lua
SwitchRecipe(recipe)

切換到指定的配方

引數

引數型別描述
recipeString 字串配方名

使用配方

假設有如下的配方檔案:

json
{
  "recipe": [
    {
      "pin": 1,
      "PinHeight": 7.95,
      "PinHeightMax": 0.5,
      "PinHeightMin": 0.5,
      "PinHeightSupply": 0,
      "PinPositionX": 26.8,
      "PinPositionXMax": 0.5,
      "PinPositionXMin": 0.5,
      "PinPositionXSupply": 0,
      "PinPositionY": 8.8,
      "PinPositionYMax": 0.5,
      "PinPositionYMin": 0.5,
      "PinPositionYSupply": 0,
      "PinSideX": 3.5,
      "PinSideXMax": 0.3,
      "PinSideXMin": 0.3,
      "PinSideY": 0,
      "PinSideYMax": 0.3,
      "PinSideYMin": 0.3,
      "PinSideHight": 0,
      "PinSideHightMax": 0.3,
      "PinSideHightMin": 0.3
    },
    {
      "pin": 2,
      "PinHeight": 7.95,
      "PinHeightMax": 0.5,
      "PinHeightMin": 0.5,
      "PinHeightSupply": 0,
      "PinPositionX": 23.4,
      "PinPositionXMax": 0.5,
      "PinPositionXMin": 0.5,
      "PinPositionXSupply": 0,
      "PinPositionY": 8.8,
      "PinPositionYMax": 0.5,
      "PinPositionYMin": 0.5,
      "PinPositionYSupply": 0,
      "PinSideX": 3.5,
      "PinSideXMax": 0.3,
      "PinSideXMin": 0.3,
      "PinSideY": 0,
      "PinSideYMax": 0.3,
      "PinSideYMin": 0.3,
      "PinSideHight": 0,
      "PinSideHightMax": 0.3,
      "PinSideHightMin": 0.3
    },
  ]
}

使用配方管理器載入配方,獲取第一組引數中的PinHeight引數的方法如下:

lua
recipe = GetRecipeSet(0)
PinHeight0 = recipe.PinHeight
println(PinHeight0)

輸出

7.95

Vision Studio