Advertisement
Niseg

simple turtle attack with back signal enable

Mar 15th, 2013
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. local atk=false
  2. local cycle=0
  3. local function dump()
  4. for i=1,16 do
  5. if(turtle.getItemCount(i)>0) then
  6. turtle.select(i)
  7. turtle.drop()
  8. end
  9. end
  10. turtle.select(1)
  11. end
  12.  
  13. while true do
  14. if redstone.getInput("back") then
  15. if not atk then
  16. print("attacking")
  17. atk=true
  18. end
  19. for i=1,4 do turtle.attack() end
  20. cycle=cycle+1;
  21. cycle=cycle%8
  22. if(cycle ==0) then dump() end
  23.  
  24. else
  25. if(atk) then
  26. print("sleeping")
  27. dump()
  28. atk=false
  29. end
  30. end
  31. sleep(1)
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement