rules54

attack

Jul 21st, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.98 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.         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.       for i=1, 15 do
  28.         if turtle.getItemCount(i) then
  29.           turtle.select(i)
  30.           turtle.dropDown()
  31.         end
  32.       end
  33.       turtle.select(1)
  34.       term.setCursorPos(1,1) term.clear()
  35.       print("Skeletons Killed: ".. mobs)
  36.     end
  37.     os.sleep(.1)
  38.   end
  39.   os.sleep(1)
  40.   term.clear() term.setCursorPos(1,1)
  41.   print("Flip lever to toggle grinding.")
  42. end
Advertisement
Add Comment
Please, Sign In to add comment