Advertisement
Arc13

Code Drone

Jul 19th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. local drone = component.proxy(component.list("drone")())
  2. local wireless = component.proxy(component.list("modem")())
  3. local leash = component.proxy(component.list("leash")())
  4.  
  5. local authorizedComputers = {"416b"}
  6. local result = false
  7.  
  8. drone.setLightColor(0xDEDE6C)
  9.  
  10. local clock = os.clock
  11.     function sleep(n)  -- seconds
  12.         local t0 = clock()
  13.         while clock() - t0 <= n do
  14.     end
  15. end
  16.  
  17. wireless.open(1337)
  18.  
  19. computer.beep()
  20. sleep(0.05)
  21. computer.beep()
  22.  
  23. drone.setLightColor(0x4C99B2)
  24.  
  25. while true do
  26.     result = false
  27.     event, receiver, sender, port, distance, msg, a1, a2, a3 = computer.pullSignal()
  28.     drone.setLightColor(0x7FCC19)
  29.     drone.setStatusText(sender)
  30.  
  31.     for k, v in pairs(authorizedComputers) do
  32.         if string.find(sender, v) then
  33.             result = true
  34.         end
  35.     end
  36.  
  37.     if msg and result then
  38.         if msg == "move" and tonumber(a1) and tonumber(a2) and tonumber(a3) then
  39.             drone.move(tonumber(a1), tonumber(a2), tonumber(a3))
  40.         elseif msg == "leash" then
  41.             for i = 0, 5 do
  42.                 leash.leash(i)
  43.             end
  44.         elseif msg == "unleash" then
  45.             leash.unleash()
  46.         end
  47.     end
  48.  
  49.     computer.beep()
  50.     drone.setLightColor(0x4C99B2)
  51. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement