Advertisement
Barnet

Minecraft Turtle: BakeCake

Apr 24th, 2016 (edited)
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.76 KB | None | 0 0
  1. -----------Written by Barnet-----------
  2. ------------Introduction---------------
  3. -- This is a program to bake cake.   --
  4. -- You need to place one chest on    --
  5. -- each side of the turtle (thats    --
  6. -- 6 in total). They need to be      --
  7. -- filled as followed:               --
  8. ---------------------------------------
  9. --  Front: Milk Buckets              --
  10. --   Left: Wheat                     --
  11. --  Right: Sugar                     --
  12. --    Top: Eggs                      --
  13. -- Bottom: Empty (for empty buckets) --
  14. --   Back: Empty (for the cakes)     --
  15. ---------------------------------------
  16. -- Now just start the program and    --
  17. -- watch how this turtle is baking   --
  18. -- those sweet sweet cakes.          --
  19. ---------------------------------------
  20. -- (Please do NOT fill the turtle    --
  21. -- per hand. This could cause some   --
  22. -- problems.)                        --
  23. ---------------------------------------
  24.  
  25. --functions----------------------------
  26.  
  27. function Next()
  28.   x = turtle.getSelectedSlot()
  29.   x=x+1
  30.   turtle.select(x)
  31. end
  32.  
  33. function CheckSlot()
  34.   Item = turtle.getItemDetail()
  35.   if Item.name == "" then
  36.     return true
  37.   else
  38.     return false
  39.   end
  40. end
  41.  
  42. function CheckBucket()
  43.   Item = turtle.getItemDetail()
  44.   if Item.name == "minecraft:bucket" then
  45.     return true
  46.   else
  47.     return false
  48.   end
  49. end
  50.  
  51. function RefillMilk()
  52.   local o = 1
  53.   while o<4 do
  54.     turtle.select(o)
  55.     if pcall(CheckSlot) == true then
  56.       if CheckBucket() == true then
  57.         turtle.dropDown(1)
  58.         turtle.suck(1)
  59.       end
  60.     else
  61.       turtle.suck(1)
  62.     end
  63.     if pcall(CheckSlot) == false then
  64.       print("Missing milk!")
  65.       error()
  66.     end
  67.     o=o+1
  68.   end
  69. end
  70.  
  71. function RefillSugar()
  72.   turtle.select(5)
  73.   if pcall(CheckSlot) == false then
  74.     turtle.turnRight()
  75.     turtle.suck()
  76.     turtle.select(7)
  77.     turtle.suck()
  78.     turtle.turnLeft()
  79.     if pcall(CheckSlot) == false then
  80.       print("Missing sugar!")
  81.       error()
  82.     end
  83.   end
  84. end
  85.  
  86. function RefillEgg()
  87.   turtle.select(6)
  88.   if pcall(CheckSlot) == false then
  89.     turtle.suckUp()
  90.     if pcall(CheckSlot) == false then
  91.       print("Missing eggs!")
  92.       error()
  93.     end
  94.   end
  95. end
  96.  
  97. function RefillWheat()
  98.   turtle.select(9)
  99.   if pcall(CheckSlot) == false then
  100.     turtle.turnLeft()
  101.     turtle.suck()
  102.     turtle.suck()
  103.     turtle.suck()
  104.     turtle.turnRight()
  105.     turtle.select(11)
  106.     if pcall(CheckSlot) == false then
  107.       print("Missing wheat!")
  108.       error()
  109.     end
  110.   end
  111. end
  112.  
  113. --main---------------------------------
  114.  
  115. while true do
  116.   RefillMilk()
  117.   RefillSugar()
  118.   RefillEgg()
  119.   RefillWheat()
  120.   turtle.craft()
  121.   turtle.turnRight()
  122.   turtle.turnRight()
  123.   turtle.select(12)
  124.   turtle.drop()
  125.   turtle.turnRight()
  126.   turtle.turnRight()
  127. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement