Advertisement
karelvysinka

Crafting Chest

Nov 26th, 2023 (edited)
901
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.28 KB | None | 0 0
  1. -- Funkce pro umístění materiálu do crafting gridu z určitého slotu
  2. local function placeInCraftingSlot(fromSlot, toSlot, quantity)
  3.     turtle.select(fromSlot)
  4.     turtle.transferTo(toSlot, quantity)
  5. end
  6.  
  7. -- Funkce pro vykraftění dřevěné truhly
  8. local function craftChest()
  9.     -- Umístění dřevěných desek do crafting gridu z slotu 4.
  10.     -- Řada 1
  11.     placeInCraftingSlot(4, 1, 1)
  12.     placeInCraftingSlot(4, 2, 1)
  13.     placeInCraftingSlot(4, 3, 1)
  14.  
  15.     -- Řada 2
  16.     placeInCraftingSlot(4, 5, 1)
  17.     placeInCraftingSlot(4, 7, 1)
  18.  
  19.     -- Řada 3
  20.     placeInCraftingSlot(4, 9, 1)
  21.     placeInCraftingSlot(4, 10, 1)
  22.     placeInCraftingSlot(4, 11, 1)
  23.  
  24.     -- Spuštění craftingu
  25.     return turtle.craft()
  26. end
  27.  
  28. -- Kontrola, zda je dostatek materiálu
  29. local function checkMaterials()
  30.     turtle.select(4)
  31.     return turtle.getItemCount() >= 8
  32. end
  33.  
  34. -- Hlavní program
  35. if checkMaterials() then
  36.     if craftChest() then
  37.         -- Přesun vykraftované truhly do slotu 8
  38.         turtle.select(1) -- slot, kde se obvykle objeví vyrobený předmět
  39.         turtle.transferTo(8)
  40.         print("Chest was crafted and moved to slot 8.")
  41.     else
  42.         print("Crafting failed. Check the setup.")
  43.     end
  44. else
  45.     print("Not enough materials in slot 4.")
  46. end
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement