Advertisement
AR2000

leashDrone.lua

May 24th, 2022
740
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local drone = component.proxy(component.list('drone')())
  2. local leash = component.proxy(component.list('leash')())
  3.  
  4.  
  5. local RED = 0xff0000
  6. local GREEN = 0x00ff00
  7. local YELLOW = 0xffff00
  8. local BLUE = 0x0000ff
  9.  
  10. local targetName = ""
  11.  
  12. drone.setLightColor(GREEN)
  13. leash.unleash()
  14.  
  15. while true do
  16.   local e,ad,x,y,z,entityName = computer.pullSignal(1,"motion")
  17.   if(not e) then
  18.     drone.setLightColor(YELLOW)
  19.     for i=0,5 do
  20.       if(leash.leash(i)) then
  21.         drone.setLightColor(BLUE)
  22.         while true do
  23.           computer.beep(500)
  24.           computer.beep(800)
  25.         end
  26.       end
  27.     end
  28.   else
  29.     drone.setStatusText(string.format("%s",targetName))
  30.     if(entityName ~= "AR2000AR") then
  31.       if(targetName == "") then targetName = entityName end
  32.       if(targetName == entityName) then
  33.         computer.beep()
  34.         drone.setLightColor(RED)
  35.         drone.move(x/2,(y/2)+1.5,z/2)
  36.       end
  37.     else
  38.       drone.setLightColor(GREEN)
  39.     end
  40.   end
  41. end
Advertisement
RAW Paste Data Copied
Advertisement