Advertisement
WarPie90

speed-test-turtle

Mar 25th, 2023 (edited)
1,182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.77 KB | None | 0 0
  1. local time1 = os.clock()
  2. for i = 1, 15 do
  3.   turtle.forward()
  4. end
  5. local time2 = os.clock()
  6. local tTime = time2 - time1
  7.  
  8. print("for ->  " .. (tTime / 15) .. "s per block")
  9.  
  10.  
  11.  
  12. local time1 = os.clock()
  13. for i = 1, 15 do
  14.   turtle.detect()
  15.   turtle.forward()
  16. end
  17. local time2 = os.clock()
  18. local tTime = time2 - time1
  19.  
  20. print("det+for -> " .. (tTime / 15) .. "s per block")
  21.  
  22.  
  23. --====================================================--
  24.  
  25. -- miner constants
  26. FACE_N = 0
  27. FACE_E = 1
  28. FACE_S = 2
  29. FACE_W = 3
  30.  
  31. miner        = {} -- the turtle
  32. miner['direction'] = 0
  33. miner['x']   = 0
  34. miner['y']   = 0
  35. miner['z']   = 0
  36.  
  37. miner['start_x'], miner['start_z'], miner['start_y'] = miner['x'], miner['z'], miner['y']
  38. miner['start_direction'] = miner['direction']
  39.  
  40.  
  41. function miner.updateHz(n)
  42.   n = n or 1
  43.   if     miner['direction'] == FACE_N then miner['z'] = miner['z'] - n
  44.   elseif miner['direction'] == FACE_S then miner['z'] = miner['z'] + n
  45.   elseif miner['direction'] == FACE_W then miner['x'] = miner['x'] - n
  46.   elseif miner['direction'] == FACE_E then miner['x'] = miner['x'] + n
  47.   end
  48. end
  49.  
  50.  
  51. function miner.forward(n)
  52.   n = n or 1
  53.   for i=1,n do
  54.     if (not turtle.forward()) then return false end
  55.     miner.updateHz(1)
  56.   end
  57.   return true
  58. end
  59.  
  60.  
  61.  
  62. local time1 = os.clock()
  63. for i=1,15 do
  64.   if turtle.getFuelLevel() < 1 then
  65.     print(123)
  66.   end
  67.  
  68.   if (not miner.forward()) then
  69.     -- this needs to be looped in case of airdrops (sand, gravel etc)
  70.     -- also to wait for despawn?
  71.     while turtle.detect() do
  72.       turtle.dig()
  73.       os.sleep(0.1)
  74.     end
  75.    
  76.     while not miner.forward()  do
  77.       turtle.attack()
  78.     end
  79.   end
  80. end
  81. local time2 = os.clock()
  82. local tTime = time2 - time1
  83.  
  84. print("det+dig+for -> " .. (tTime / 15) .. "s per block")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement