MDKed

digdownV3.5

Jul 3rd, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. heading = 1
  2.  
  3. pos = vector.new(0,0,0)
  4.  
  5. tgted = false
  6. tgt = vector.new(0,0,0)
  7.  
  8. itmQ = 0
  9.  
  10. waypoints = {}
  11. waypoints['dockUnl'] = vector.new(-2,0,2)
  12. waypoints['unload'] = vector.new(-2,0,1)
  13.  
  14. function moveToTgt()
  15.  if pos.x > tgt.x then
  16.  
  17.  end
  18. end
  19.  
  20. function move(Int, Bool)
  21.  if (Int == 1) then
  22.    
  23.  end
  24. end
  25.  
  26. function rotB(Bool)
  27.  if Bool then
  28.   turtle.turnRight()
  29.   heading = heading + 1
  30.  else
  31.   turtle.turnLeft()
  32.   heading = heading - 1
  33.  end
  34.  if heading > 4 then
  35.    heading = 1
  36.   elseif heading < 1 then
  37.    heading = 4
  38.   end
  39. end
  40.  
  41. function rot(Int)
  42.  while Int ~= heading do
  43.   turtle.turnRight()
  44.   heading = heading + 1
  45.   if heading > 4 then
  46.    heading = 1
  47.   elseif heading < 1 then
  48.    heading = 4
  49.   end
  50.  end
  51. end
  52.  
  53. function swapBool(Bool)
  54.  if Bool then
  55.   return false
  56.  else
  57.   return true
  58.  end
  59. end
  60.  
  61. function chngCoord(Int)
  62.  if Int == 1 then
  63.    pos.z = pos.z + 1
  64.  elseif Int == 2 then
  65.    pos.x = pos.x + 1
  66.  elseif Int == 3 then
  67.     pos.z = pos.z - 1
  68.  elseif Int == 4 then
  69.    pos.x = pos.x - 1
  70.  elseif Int == 5 then
  71.    pos.y = pos.y - 1
  72.  elseif Int == 6 then
  73.    pos.y = pos.y + 1
  74.  end
  75. end
  76.  
  77. function ChkFuel()
  78.  if turtle.getFuelLevel() == 0 then
  79.   turtle.select(1)
  80.   if turtle.refuel(1) == true then
  81.    print('Dozapravke na ',pos.x, "x",pos.y, "x",pos.z)
  82.   end
  83.  end
  84. end
  85.  
  86. function Fwd(Int)
  87.   for a = 1, Int  do
  88.    turtle.dig()
  89.    ChkFuel()
  90.    turtle.forward()
  91.     chngCoord(heading)
  92.    print('moving ',pos.x, "x",pos.y, "x",pos.z)
  93.   end
  94. end
  95.  
  96. function Turn(Bool)
  97.   if Bool then
  98.    rotB(true)
  99.   Fwd(1)
  100.    rotB(true)
  101.   return false
  102.  else
  103.    rotB(false)
  104.   Fwd(1)
  105.    rotB(false)
  106.   return true
  107.   end
  108. end
  109.  
  110. function down()
  111.  turtle.digDown()
  112.  turtle.down()
  113.   chngCoord(5)
  114.  rotB(false)
  115.  rotB(false)
  116. end
  117.  
  118. print('Vvedite Shiriny')
  119. mX = tonumber(read())
  120. print('Vvedite glubinu')
  121. mY = tonumber(read())
  122.  
  123. print('  Starting at ',pos.x, "x",pos.y, "x",pos.z)
  124.  
  125. Fwd(1)
  126.  rotB(false)
  127. Fwd(mX/2)
  128.  rotB(true)
  129.  
  130.  
  131. for c=1, 2 do
  132.  turtle.digUp()
  133.  turtle.up()
  134.   chngCoord(6)
  135. end
  136.  
  137.  
  138. print('  Dig down at ',pos.x, "x",pos.y, "x",pos.z)
  139.  
  140. turn = true
  141.  
  142.  
  143. for y = 1, mY+3 do
  144.  if y > 1 then
  145.   down()
  146.  end
  147.   for x = 1,  mX do
  148.    if mX > 1 then
  149.     Fwd(mX - 1)
  150.    else
  151.     Fwd(mX)
  152.    end
  153.    if x ~= mX then
  154.     turn = Turn(turn)
  155.    end
  156.   end
  157.  end
  158.  
  159. print('Begin dig up, steps up = ', mY, "\n   ", pos.x, "x",pos.y, "x",pos.z)
  160.  
  161.  
  162. for b=1, mY do
  163.   turtle.digUp()
  164.   turtle.up()
  165.    chngCoord(6)
  166. end
  167. print('Ending operation ', pos.x, "x",pos.y, "x",pos.z)
Advertisement
Add Comment
Please, Sign In to add comment