Advertisement
NanoBob

apricorn

Jul 28th, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.58 KB | None | 0 0
  1. if fs.exists("event")==false then shell.run("pastebin get UKPy4iiE event") end
  2. if os.loadAPI("event") == false then error("Failed to load event API") end
  3.  
  4. if fs.exists("utils") == false then shell.run("pastebin get dyvydHtK utils") end
  5. if os.loadAPI("utils") == false then error("Failed to load utils API") end
  6.  
  7. if fs.exists("data") == false then shell.run("pastebin get LnvzL7ur data") end
  8. if os.loadAPI("data") == false then error("Failed to load data API") end
  9.  
  10.  
  11. if fs.exists("button") == false then shell.run("pastebin get UmerzDUF button") end
  12. if os.loadAPI("button") == false then error("Failed to load button API") end
  13.  
  14. local monitor
  15. local ultraButton
  16. local quickButton
  17.  
  18. function attachMonitor()
  19.     monitor = peripheral.wrap("top")
  20.     button.setMonitor(monitor)
  21. end
  22.  
  23. function ultra()
  24.     local discard = "pixelmon:item.Blue_Apricorn"
  25.     getItems(discard)
  26.     turtle.down()
  27.     turtle.down()
  28. end
  29.  
  30. function quick()
  31.     local discard = "pixelmon:item.Black_Apricorn"
  32.     getItems(discard)
  33.     turtle.down()
  34.     turtle.down()
  35.     turtle.turnRight()
  36.     turtle.turnRight()
  37. end
  38.  
  39. function getItems(discard)
  40.     turtle.turnRight()
  41.     turtle.turnRight()
  42.     for i=1,16 do
  43.         turtle.suck()
  44.     end
  45.     turtle.turnRight()
  46.     turtle.turnRight()
  47.     convertCapricorn(discard)
  48.     local count = fillFurnaces(discard)
  49.     fuelFurnaces(count)
  50.     emptyFurnaces()
  51.     attachMonitor()
  52.     button.drawAllButtons()
  53. end
  54.  
  55. function convertCapricorn(target)
  56.     turtle.down()
  57.     turtle.down()
  58.     for i=1,16 do
  59.         local detail = turtle.getItemDetail(i)
  60.         if detail ~= nil and detail.name == target then
  61.             turtle.select(i)
  62.             for i=1,turtle.getItemCount(i) do
  63.                 turtle.place()
  64.                 turtle.dig()
  65.             end
  66.         end
  67.     end
  68. end
  69.  
  70. function fillFurnaces(discard)
  71.     local itemCount = 0
  72.     for b=1,4 do
  73.         turtle.back()
  74.         for i=1,16 do
  75.             local detail = turtle.getItemDetail(i)
  76.             if detail ~= nil and detail.name ~= discard and detail.name ~= "minecraft:log" then
  77.                 turtle.select(i)
  78.                 itemCount = itemCount + math.ceil(turtle.getItemCount(i)/1.5)
  79.                 turtle.dropDown(22)
  80.                 break
  81.             end
  82.         end
  83.     end
  84.     for i=1,4 do
  85.         turtle.forward()
  86.     end
  87.     return itemCount
  88. end
  89.  
  90. function fuelFurnaces(count)
  91.     turtle.down()
  92.     turtle.down()
  93.     for i=1,16 do
  94.         local detail = turtle.getItemDetail(i)
  95.         if detail ~= nil and detail.name == "minecraft:log" then
  96.             turtle.select(i)
  97.             turtle.transferTo(6)
  98.         end
  99.     end
  100.     turtle.select(1)
  101.     turtle.craft()
  102.     for b=1,4 do
  103.         turtle.back()
  104.         for i=1,16 do
  105.             local detail = turtle.getItemDetail(i)
  106.             if detail ~= nil and detail.name == "minecraft:planks" then
  107.                 turtle.select(i)
  108.                 turtle.dropUp(count)
  109.                 break
  110.             end
  111.         end
  112.     end
  113.     turtle.turnRight()
  114.     turtle.turnRight()
  115.     for i=1,16 do
  116.         if turtle.getItemCount(i)>0 then
  117.             turtle.select(i)
  118.             turtle.drop()
  119.             break
  120.         end
  121.     end
  122.     sleep(22*10)
  123. end
  124.  
  125. function emptyFurnaces()
  126.     turtle.suckUp()
  127.     for i=1,3 do
  128.         turtle.back()
  129.         turtle.suckUp()
  130.     end
  131.     for i=1,3 do
  132.         turtle.forward()
  133.     end
  134.     turtle.turnRight()
  135.     for i=1,16 do
  136.         if turtle.getItemCount(i)>0 then
  137.             turtle.select(i)
  138.             turtle.drop()
  139.         end
  140.     end
  141.     turtle.turnRight()
  142.     turtle.forward()
  143.     turtle.forward()
  144.     turtle.forward()
  145.     turtle.forward()
  146.     turtle.up()
  147.     turtle.up()
  148.     turtle.up()
  149.     turtle.up()
  150. end
  151.  
  152. function clicked(button)
  153.     if button == ultraButton then
  154.         ultra()
  155.     elseif button == quickButton then
  156.         quick()
  157.     end
  158. end
  159.  
  160. function init()
  161.     attachMonitor()
  162.     ultraButton = button.addButton(0,0,1.1,0.5,"Ultra ball",false,true)
  163.     quickButton = button.addButton(0,0.5,1.1,0.5,"Quick ball",false,true)
  164.     event.addHandler("onButtonClick",clicked)
  165.     while true do
  166.         event.handleCCEvents()
  167.     end
  168. end
  169. init()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement