Advertisement
SpaceRanger4321

Untitled

Mar 26th, 2022
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. local modules = peripheral.find("manipulator")
  2. if not modules then
  3. error("Cannot find manipulator", 0)
  4. end
  5. if not modules.hasModule("plethora:laser") then error("Cannot find laser", 0) end
  6. if not modules.hasModule("plethora:sensor") then error("Cannot find entity sensor", 0) end
  7.  
  8. local function fire(entity)
  9. local x, y, z = entity.x, entity.y, entity.z
  10. local pitch = -math.atan2(y, math.sqrt(x * x + z * z))
  11. local yaw = math.atan2(-x, z)
  12.  
  13. modules.fire(math.deg(yaw), math.deg(pitch), 5)
  14. sleep(0.2)
  15. end
  16. local mobNames = { "Creeper", "Zombie", "Skeleton" }
  17. local mobLookup = {}
  18. for i = 1, #mobNames do
  19. mobLookup[mobNames[i]] = true
  20. end
  21. while true do
  22. local mobs = modules.sense()
  23. local candidates = {}
  24. for i = 1, #mobs do
  25. local mob = mobs[i]
  26. if mobLookup[mob.name] then
  27. candidates[#candidates + 1] = mob
  28. end
  29. end
  30. if #candidates > 0 then
  31. local mob = candidates[math.random(1, #candidates)]
  32. fire(mob)
  33. else
  34. sleep(1)
  35. end
  36. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement