rules54

Attack Updated

Jul 12th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. s = sensor.wrap("top")
  3.  
  4. function playerRange(range)
  5. local result = nil
  6. x = s.getTargets()
  7. for k, v in pairs(x) do
  8. if v.Name == "Player" then
  9. local x = math.floor(math.abs(v.Position.X))
  10. local z = math.floor(math.abs(v.Position.Z))
  11. local y = math.floor(math.abs(v.Position.Y))
  12. if (x <= range) or (y <= range) or (z <= range) then
  13. local result = true
  14. else local result = false
  15. end
  16. end
  17. end
  18. return result
  19. end
  20.  
  21. mobs = 0
  22.  
  23. while true do
  24. while playerRange(5) do
  25. if turtle.attack() then
  26. mobs = mobs + 1
  27. term.setCursorPos(1,1) term.clear()
  28. print("Skeletons Killed: ".. mobs)
  29. end
  30. os.sleep(.1)
  31. end
  32. os.sleep(1)
  33. term.clear() term.setCursorPos(1,1)
  34. print("Flip lever to toggle grinding.")
  35. end
Advertisement
Add Comment
Please, Sign In to add comment