(recipe, count, craftingTable)
| 9 | let windowCraftingTable |
| 10 | |
| 11 | async function craft (recipe, count, craftingTable) { |
| 12 | assert.ok(recipe) |
| 13 | count = parseInt(count ?? 1, 10) |
| 14 | if (recipe.requiresTable && !craftingTable) { |
| 15 | throw new Error('Recipe requires craftingTable, but one was not supplied: ' + JSON.stringify(recipe)) |
| 16 | } |
| 17 | |
| 18 | try { |
| 19 | for (let i = 0; i < count; i++) { |
| 20 | await craftOnce(recipe, craftingTable) |
| 21 | } |
| 22 | |
| 23 | if (windowCraftingTable) { |
| 24 | bot.closeWindow(windowCraftingTable) |
| 25 | windowCraftingTable = undefined |
| 26 | } |
| 27 | } catch (err) { |
| 28 | if (windowCraftingTable) { |
| 29 | bot.closeWindow(windowCraftingTable) |
| 30 | windowCraftingTable = undefined |
| 31 | } |
| 32 | throw new Error(err) |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | async function craftOnce (recipe, craftingTable) { |
| 37 | if (craftingTable) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…