Advertisement
jnsstnbrg

Living

Dec 6th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.48 KB | None | 0 0
  1. local slotFuel = 1
  2. local slotStone = 2
  3. local slotWood = 3
  4. local slotLivingrock = 4
  5. local slotLivingwood = 5
  6.  
  7. local livingrock = "Botania:livingrock"
  8. local livingwood = "Botania:livingwood"
  9.  
  10. local stopBlock = livingrock
  11.  
  12. local numPureDaisies = 4
  13. local numBlocks = (numPureDaisies * 3) + 1
  14.  
  15. local timeToKill = false
  16.  
  17. function refuel()
  18.   if (turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1) then
  19.     turtle.select(slotFuel)
  20.     turtle.suckDown(64)
  21.     turtle.refuel(64)
  22.   end
  23. end
  24.  
  25. function pickUpStone(numWood)
  26.   turtle.turnRight()
  27.   turtle.select(slotStone)
  28.   turtle.drop(64)
  29.   turtle.suck(numBlocks + (numBlocks - numWood))
  30.  
  31.   return turtle.getItemCount(slotStone)
  32. end
  33.  
  34. function pickUpWood(numStone)
  35.   turtle.turnRight()
  36.   turtle.select(slotWood)
  37.   turtle.drop(64)
  38.   turtle.suck(numBlocks + (numBlocks - numStone))
  39.   turtle.turnRight()
  40.   turtle.turnRight()
  41.  
  42.   return turtle.getItemCount(slotWood)
  43. end
  44.  
  45. function resupply()
  46.   numStone = pickUpStone(numBlocks)
  47.   numWood = pickUpWood(numStone)
  48.  
  49.   if (numStone > 0 and numWood < numBlocks) then
  50.     numStone = pickUpStone(numWood)
  51.     turtle.turnLeft()
  52.   end
  53. end
  54.  
  55. function dumpItems()
  56.   turtle.turnRight()
  57.   turtle.forward()
  58.   turtle.turnRight()
  59.   for (i = 4, 16) do
  60.     turtle.select(i)
  61.     turtle.drop(64)
  62.   end
  63.   turtle.turnRight()
  64. end
  65.  
  66. function mine()
  67.   local blockInfront, blockData = turtle.inspectDown()
  68.   if (blockData.name == livingrock) then
  69.     turtle.select(slotLivingrock)
  70.   elseif (blockData.name == livingwood) then
  71.     turtle.select(slotLivingwood)
  72.   end
  73.  
  74.   if (blockData.name == livingwood or blockData.name == livingrock) then
  75.     turtle.digDown()
  76.   end
  77. end
  78.  
  79. function place()
  80.   turtle.select(slotStone)
  81.   if (turtle.getItemCount(slotStone) == 0) then
  82.     turtle.select(slotWood)
  83.   end
  84.   turtle.placeDown()
  85. end
  86.  
  87. refuel()
  88. resupply()
  89.  
  90. while true do
  91.   local blockInfront, blockData = turtle.inspect()
  92.  
  93.   if (blockInfront and blockData.name == stopBlock) then
  94.     dumpItems()
  95.     refuel()
  96.     resupply()
  97.  
  98.     if (timeToKill) then
  99.       print("Shutting down...")
  100.       return
  101.     end
  102.  
  103.     if (numStone == 0 and numWood == 0) then
  104.       print("Sleeping for 60 seconds, shutting down after next round - out of wood and stone")
  105.       timeToKill = true
  106.       sleep(20)
  107.     end
  108.     sleep(48 - (numPureDaisies * 2))
  109.   end
  110.  
  111.   turtle.forward()
  112.   if (blockData.name == livingwood) then
  113.     turtle.turnLeft()
  114.   else
  115.     mine()
  116.     place()
  117.   end
  118. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement