Advertisement
Guest User

kill_aura.lua

a guest
Dec 12th, 2021
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.95 KB | None | 0 0
  1. local modules = peripheral.wrap("back")
  2. if not modules then
  3. error("Cannot find neural interface", 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. local function fire(entity)
  8. local x, y, z = entity.x, entity.y, entity.z
  9. local pitch = -math.atan2(y, math.sqrt(x * x + z * z))
  10. local yaw = math.atan2(-x, z)
  11. modules.fire(math.deg(yaw), math.deg(pitch), 5)
  12. sleep(0.1)
  13. end
  14. local mobNames = {"qwsq"  ,"Creeper", "Zombie", "Skeleton","Spider","Enderman" }
  15. local mobLookup = {}
  16. for i = 1, #mobNames do
  17. mobLookup[mobNames[i]] = true
  18. end
  19. while true do
  20. local mobs = modules.sense()
  21. local candidates = {}
  22. for i = 1, #mobs do
  23. local mob = mobs[i]
  24. if mobLookup[mob.name] then
  25. candidates[#candidates + 1] = mob
  26. end
  27. end
  28. if #candidates > 0 then
  29. local mob = candidates[math.random(1, #candidates)]
  30. fire(mob)
  31. else
  32. sleep(0.1)
  33. end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement