Advertisement
BillBodkin

pbFarm

Aug 12th, 2018
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.57 KB | None | 0 0
  1. args = {...}
  2.  
  3. function round()
  4.     print("Doing a round")
  5.     empty()
  6.     checkFuel()
  7.     checkSeeds()
  8.     overBlock()
  9.     while roundMove() == false do
  10.         --print("lol")
  11.     end
  12.     empty()
  13.     print("done")
  14. end
  15.  
  16. function sow()
  17.     for i=1,16,1 do
  18.         turtle.select(i)
  19.         local data = turtle.getItemDetail()
  20.  
  21.         if data then
  22.             print(data.name)
  23.             if data.name == "minecraft:wheat_seeds" then
  24.                 turtle.placeDown()
  25.                 return
  26.             end
  27.         end
  28.     end
  29. end
  30.  
  31. function overBlock()
  32.     turtle.suckDown(64)
  33.     local success, data = turtle.inspectDown()
  34.  
  35.     if success then
  36.         print(data.name)
  37.         print(data.metadata)
  38.         if data.name == "minecraft:wheat" then
  39.             if data.metadata == 7 then
  40.                 turtle.digDown()
  41.                 turtle.suckDown(64)
  42.                 os.sleep(0.1)
  43.                 turtle.suckDown(64)
  44.                 sow()
  45.             end
  46.         end
  47.     else
  48.         turtle.digDown()
  49.         sow()
  50.     end
  51.     turtle.suckDown(64)
  52. end
  53.  
  54. function roundMove()
  55.     local success, data = turtle.inspect()
  56.     if success then
  57.         print(data.name)
  58.         if data.name == args[1] then
  59.             turtle.turnRight()
  60.             if  turtle.detect() == true then
  61.                 turtle.turnRight()
  62.                 turtle.turnRight()
  63.                 while turtle.detect() == false do
  64.                     turtle.forward()
  65.                 end
  66.                 turtle.turnLeft()
  67.                 while turtle.detect() == false do
  68.                     turtle.forward()
  69.                 end
  70.                 turtle.turnLeft()
  71.                 turtle.turnLeft()
  72.                 return true
  73.             else
  74.                 turtle.forward()
  75.                 overBlock()
  76.                 turtle.turnRight()
  77.             end
  78.         elseif data.name == args[2] then
  79.             turtle.turnLeft()
  80.             turtle.forward()
  81.             overBlock()
  82.             turtle.turnLeft()
  83.         else
  84.             print("wtf")
  85.         end
  86.     else
  87.         turtle.forward()
  88.         overBlock()
  89.     end
  90.     return false
  91. end
  92.  
  93. function checkFuel()
  94.     while turtle.getFuelLevel() < 1000 do
  95.         print("Gimme fuel boiii")
  96.         print(turtle.getFuelLevel())
  97.         turtle.select(1)
  98.         turtle.turnLeft()
  99.         turtle.suck(64)
  100.         turtle.refuel(64)
  101.     turtle.turnRight()
  102.     end
  103. end
  104.  
  105. function checkSeeds()
  106.     for i=1,4,1 do
  107.         turtle.select(i)
  108.         turtle.suckUp(64)
  109.     end
  110. end
  111.  
  112. function empty()
  113.     for i=1,16,1 do
  114.         turtle.select(i)
  115.         local data = turtle.getItemDetail()
  116.  
  117.         if data then
  118.             print(data.name)
  119.             if data.name == "minecraft:wheat_seeds" then
  120.                 turtle.dropUp(64)
  121.             elseif data.name == "minecraft:wheat" then
  122.                
  123.                 http.get("http://tools.cablepost.co.uk/cc/variables/altervariable.php?cmd=add&var=wheat&val="..tostring(turtle.getItemCount(i)))
  124.                 turtle.turnLeft()
  125.                 turtle.turnLeft()
  126.                 turtle.drop(64)
  127.                 turtle.turnLeft()
  128.                 turtle.turnLeft()
  129.             end
  130.         end
  131.     end
  132. end
  133.  
  134.  
  135. print("Sup brethren, this program takes 2 arguments btw, first is border wall on back side, seconds is border wall on front side")
  136. round()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement