Advertisement
Himeki

Attack Loop

Feb 6th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 KB | None | 0 0
  1. -- config
  2. local KillCount = 0
  3. local WaitStage = 0
  4. local Unloaded = 0
  5.  
  6. -- functions
  7. function clear()
  8.   term.clear()
  9.   term.setCursorPos(1,1)
  10. end
  11.  
  12. local function waiting()
  13.   if WaitStage == 0 then
  14.     print("Waiting")
  15.     WaitStage = WaitStage+1
  16.   elseif WaitStage == 1 then
  17.     print("Waiting.")
  18.     WaitStage = WaitStage+1
  19.   elseif WaitStage == 2 then
  20.     print("Waiting..")
  21.     WaitStage = WaitStage+1
  22.   elseif WaitStage == 3 then
  23.     print("Waiting...")
  24.     WaitStage = 0
  25.   end
  26. end
  27.  
  28. local function readout()
  29.     clear()
  30.     print("Swings Taken: " .. KillCount )
  31.     print("Unloaded Items: " .. Unloaded )
  32. end
  33.  
  34. local function unload()
  35.     for n=1,4 do
  36.         Unloaded = Unloaded + turtle.getItemCount(n)
  37.         turtle.select(n)
  38.         turtle.dropUp()
  39.         readout()
  40.     end
  41.     turtle.select(1)
  42. end
  43.  
  44. -- run code
  45. clear()
  46. while true do
  47.   if turtle.attack() == true then
  48.     KillCount = KillCount+1
  49.     unload()
  50.   else
  51.     readout()
  52.     waiting()
  53.     os.sleep(.25)
  54.   end
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement