DeliciousJaffa

Cobble gen

Nov 16th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. -- XP Turtle program by DeliciousJaffa
  2.  
  3. local amountCut = 0
  4. local waittext = " - Wait"
  5. local tstop
  6. local running = true
  7. local ix, xy
  8.  
  9. function updatestats()
  10.   term.setCursorPos(1,ty)
  11.   term.clearLine()
  12.   term.setCursorPos(1,ty)
  13.   write("Cobble harvested since reboot: " .. amountCut)
  14. end
  15.  
  16. function keywait ()
  17.   while not tstop do
  18.     local event,key = os.pullEvent()
  19.       if (event == "char") and (key == "q") then
  20.         tstop = true
  21.       end
  22.   end
  23. end
  24.  
  25. function stats ()
  26.   tx,ty = term.getCursorPos()
  27.   while not tstop do
  28.     updatestats()
  29.     sleep(5)
  30.   end
  31.   write(waittext)
  32. end
  33.  
  34. --print(m.getLevels())
  35. --enchantBook()
  36.  
  37. function main ()
  38.   turtle.select(1)
  39.   while not tstop do
  40.     if turtle.detect() then
  41.       if turtle.dig() then amountCut = amountCut + 1 end
  42.     end
  43.     if turtle.getItemCount(1) > 0 then
  44.       turtle.dropDown()
  45.     end
  46.     sleep(0.25)
  47.   end
  48. end
  49.  
  50. term.clear()
  51. term.setCursorPos(1,1)
  52. turtle.select(1)
  53. print("Press Q to quit")
  54. parallel.waitForAll(stats,keywait,main)
  55. local mx,my = term.getCursorPos()
  56. term.setCursorPos((mx - string.len(waittext)),my)
  57. updatestats()
  58. print(" \\e/")
Advertisement
Add Comment
Please, Sign In to add comment