Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Apr 6th, 2020 164 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local modules = peripheral.wrap("back")
  2. if not modules then
  3.     error("Cannot find manipulator", 0)
  4. end
  5.  
  6. if not modules.hasModule("plethora:laser") then error("Cannot find laser", 0) end
  7. if not modules.hasModule("plethora:sensor") then error("Cannot find entity sensor", 0) end
  8.  
  9. local function fire(entity)
  10.     local x, y, z = entity.x, entity.y, entity.z
  11.     local pitch = -math.atan2(y, math.sqrt(x * x + z * z))
  12.     local yaw = math.atan2(-x, z)
  13.  
  14.     modules.fire(math.deg(yaw), math.deg(pitch), 5)
  15.     sleep(0.2)
  16. end
  17.  
  18. local mobNames = { "Tesadorn" }
  19. local mobLookup = {}
  20. for i = 1, #mobNames do
  21.     mobLookup[mobNames[i]] = true
  22. end
  23.  
  24. local turretState = false
  25.  
  26. while true do
  27.     parallel.waitForAny(
  28.         function()
  29.             event, key = os.pullEvent("key")
  30.                 if key == keys.p then
  31.                     if turretState then
  32.                         turretState = false
  33.                     else
  34.                         turretState = true
  35.                     end
  36.             end
  37.         end,
  38.         function()
  39.             while true do
  40.                
  41.                
  42.                 while turretState do
  43.                     local mobs = modules.sense()
  44.  
  45.                     local candidates = {}
  46.                     for i = 1, #mobs do
  47.                         local mob = mobs[i]
  48.                         if mob.name ~= "Tesadorn" then
  49.                             candidates[#candidates + 1] = mob
  50.                         end
  51.                     end
  52.  
  53.                     if #candidates > 0 then
  54.                         local mob = candidates[math.random(1, #candidates)]
  55.                         fire(mob)
  56.                     else
  57.                         sleep(.1)
  58.                     end
  59.                 end
  60.  
  61.  
  62.                 sleep(.1)
  63.             end
  64.         end
  65.     )
  66. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top