balloonanimal

stripminer (cyanideepic)

Apr 13th, 2013
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.95 KB | None | 0 0
  1. --[[Copyright PrinceTommen - Script developed for CyanideEpic (twitch.tv/cyanideepic)]]--
  2. --[[Everyone is allowed to use it as long as you don't pretend it's yours]]--
  3. --[[Have fun !]]--
  4.  
  5. local function setFacingAngle(FacingAngle, WishedFacingAngle)
  6.   if FacingAngle < WishedFacingAngle then
  7.     for DiffFacingAngle = 1, (WishedFacingAngle - FacingAngle) do
  8.       turtle.turnRight()
  9.       FacingAngle = FacingAngle + 1
  10.     end
  11.   elseif FacingAngle > WishedFacingAngle then
  12.     for DiffFacingAngle = 1, (FacingAngle - WishedFacingAngle) do
  13.       turtle.turnLeft()
  14.       FacingAngle = FacingAngle - 1
  15.     end  
  16.   end
  17.   return FacingAngle
  18. end
  19.  
  20. local function refuel(coal_slot)
  21.   turtle.select(coal_slot)
  22.   boolRefuel = turtle.refuel(1)
  23.   if boolRefuel then
  24.     refuel_count = 0
  25.     print("Successfully Refueled")
  26.   else
  27.     print("Out of fuel")
  28.     while not(turtle.refuel(1)) do
  29.       setFacingAngle(FacingAngle, FacingAngle + 2)
  30.       setFacingAngle(FacingAngle, FacingAngle - 2)
  31.     end    
  32.   end
  33.   turtle.select(1)  
  34.   return refuel_count  
  35. end
  36.  
  37. local function moveForward(FacingAngle, Boolfb, moving_integer, digUpBool, digDownBool, refuel_count)
  38. local moving_count = 1
  39.   for moving_count=1,moving_integer do
  40.     if (refuel_count == 80) then
  41.       refuel_count = refuel(2)
  42.     end
  43.     Bool1 = false
  44.     while not(Bool1) do
  45.       if (Boolfb) then
  46.         turtle.dig()
  47.         Bool1 = turtle.forward()
  48.         if (digUpBool) then
  49.           turtle.digUp()
  50.         end
  51.         if (digDownBool) then
  52.           turtle.digDown()
  53.         end  
  54.       else
  55.         Bool1 = turtle.back()
  56.         if not(Bool1) then
  57.           setFacingAngle(FacingAngle, (FacingAngle + 2))
  58.           turtle.dig()
  59.           setFacingAngle(FacingAngle, (FacingAngle - 2))
  60.         end
  61.       end    
  62.     end
  63.     moving_count = moving_count + 1
  64.     refuel_count = refuel_count + 1
  65.   end
  66. return refuel_count  
  67. end
  68.  
  69. local function moveUp(Boolud, moving_integer, refuel_count)
  70. local moving_count = 1
  71.   for moving_count=1, moving_integer do
  72.     if (refuel_count == 80) then
  73.       refuel_count = refuel(2)
  74.     end
  75.     Bool2 = false
  76.     while not(Bool2) do
  77.       if (Boolud) then
  78.         turtle.digUp()   
  79.         Bool2 = turtle.up()
  80.       else
  81.         turtle.digDown()
  82.         Bool2 = turtle.down()
  83.       end
  84.     end
  85.     moving_count = moving_count + 1
  86.     refuel_count = refuel_count + 1
  87.   end
  88. return refuel_count
  89. end
  90.  
  91. local function inventoryManagement(saved_slots,refuel_count)
  92.   turtle.select(1)
  93.   n = saved_slots + 1
  94.  
  95.   repeat
  96.     item_count = turtle.getItemCount(n)
  97.     if (item_count ~= 0) then      
  98.       boolSlotOccupied = true
  99.       n = n + 1  
  100.     else
  101.       boolSlotOccupied = false  
  102.     end  
  103.   until (boolSlotOccupied == false) or (n == 17)
  104.   if (n == 17) then
  105.     print("Inventory full")
  106.     FacingAngle = setFacingAngle(FacingAngle, (FacingAngle - 1))
  107.     refuel_count = moveForward(FacingAngle, true, 1, true, false, refuel_count)
  108.     refuel_count = moveForward(FacingAngle, false, 1, false, false, refuel_count)
  109.     turtle.select(3)
  110.     turtle.place()
  111.     for u=(saved_slots+1),16 do
  112.       turtle.select(u)
  113.       turtle.drop()
  114.     end
  115.     turtle.select(1)
  116.     FacingAngle = setFacingAngle(FacingAngle, (FacingAngle + 1))
  117.   end
  118.   return refuel_count  
  119. end
  120.  
  121.  
  122. FacingAngle = 2
  123. coal_slot = 2
  124. print("Please place torches in the first slot (upper-left corner), coal in the second one and chests in the third one")
  125. print("How many parallel tunnels are you willing to dig ?")
  126. tunnels_integer = read()
  127. print("How long do you want each tunnel to be ?")
  128. tunnels_lenght = read()
  129. print("How many blocks do you want between two tunnels ?")
  130. tunnels_separation = read()
  131. print("Your patient and efficient servant is starting his work !")
  132. local a = 1
  133. local i = 1
  134. local refuel_count = 0
  135. refuel(2)
  136. refuel_count = moveUp(true, 1, refuel_count)
  137. for a=1,(tunnels_integer) do
  138.   for i=1,(tunnels_lenght) do
  139.     refuel_count = moveForward(FacingAngle, true, 1, true, true, refuel_count)
  140.     if (0 == i%5) then
  141.       turtle.turnRight()
  142.       turtle.dig()
  143.       turtle.place()
  144.       turtle.turnLeft()
  145.     end
  146.     refuel_count = inventoryManagement(3,refuel_count)
  147.   end
  148.   refuel_count = moveForward(FacingAngle, false, tunnels_lenght, true, true, refuel_count)
  149.   FacingAngle = setFacingAngle(FacingAngle, (FacingAngle - 1))
  150.   refuel_count = moveForward(FacingAngle, true, (tunnels_separation+1), true, true, refuel_count)
  151.   FacingAngle = setFacingAngle(FacingAngle, (FacingAngle - 1))
  152.   refuel_count = moveForward(FacingAngle, true, 1, true, true, refuel_count)
  153.   FacingAngle = setFacingAngle(FacingAngle, (FacingAngle - 1))
  154.   refuel_count = moveForward(FacingAngle, true, (tunnels_separation), true, true, refuel_count)
  155.   refuel_count = moveForward(FacingAngle, false, (tunnels_separation), true, true, refuel_count)
  156.   FacingAngle = setFacingAngle(FacingAngle, (FacingAngle + 1))
  157.   refuel_count = moveForward(FacingAngle, false, 1, true, true, refuel_count)
  158.   turtle.select(1)
  159.   turtle.place()
  160.   FacingAngle = setFacingAngle(FacingAngle, (FacingAngle + 2))
  161. end
Add Comment
Please, Sign In to add comment