MineMcMine

LaserSentry

Mar 30th, 2022 (edited)
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.73 KB | None | 0 0
  1. --[[
  2.     pastebin run Rq71t2Ya
  3. ]]--
  4.  
  5.  
  6. laser = peripheral.wrap("right")
  7. sensor = peripheral.wrap("left")
  8. monitor = peripheral.wrap( "back" )
  9.  
  10. monitor.setTextScale(2)
  11.  
  12.  
  13. local function fire(entity)
  14.     local x, y, z = entity.x, entity.y, entity.z
  15.     local pitch = -math.atan2(y, math.sqrt(x * x + z * z))
  16.     local yaw = math.atan2(-x, z)
  17.  
  18.     laser.fire(math.deg(yaw), math.deg(pitch), 5)
  19.     sleep(0.2)
  20. end
  21.  
  22.  
  23. while(true) do
  24.    
  25.     local mobs = sensor.sense()
  26.     for _, mob in pairs(mobs) do
  27.         if(mob.displayName == "Guardian of Gaia") then
  28.             local metaData = sensor.getMetaByID(mob.id)
  29.             if(metaData ~= nil) then
  30.                 monitor.setCursorPos(1,1)
  31.                 monitor.write("Health: " .. metaData.health)
  32.             end
  33.             os.sleep(1)
  34.         end
  35.     end
  36. end
  37.    
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment