Advertisement
MDKed

digdownV3

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