Advertisement
guitarplayer616

RemoteControl

Nov 25th, 2019
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.20 KB | None | 0 0
  1. --fly the drone with a tablet in openComputer mod
  2. --table requires internet card + wireless network card while drone requires wireless network card + custom eeprom program
  3. component = require("component")
  4. m = component.modem
  5. m.broadcast(2412,"d=component.proxy( component.list(\"drone\")())")
  6. side = "0"
  7.  
  8. while true do
  9.   table = {coroutine.yield()}
  10.   if table[1] == "key_down" then
  11.     if table[3] == 119 and table[4] == 17 then
  12.       print("w")
  13.       m.broadcast(2412,"d.move(1,0,0)")
  14.     elseif table[3] == 115 and table[4] == 31 then
  15.       print("s")
  16.       m.broadcast(2412,"d.move(-1,0,0)")
  17.     elseif table[3] == 97 and table[4] == 30 then
  18.       print("a")
  19.       m.broadcast(2412,"d.move(0,0,-1)")
  20.     elseif table[3] == 100 and table[4] == 32 then
  21.       print("d")
  22.       m.broadcast(2412,"d.move(0,0,1)")
  23.     elseif table[3] == 32 and table[4] == 57 then
  24.       print("space")
  25.       m.broadcast(2412,"d.move(0,1,0)")
  26.     elseif table[3] == 0 and table[4] == 29 then
  27.       print("ctrl")
  28.       m.broadcast(2412,"d.move(0,-1,0)")
  29.     elseif table[3] == 56 and table[4] == 72 then
  30.       print("forward")
  31.       side = "3"
  32.     elseif table[3] == 0 and table[4] == 203 then
  33.       print("left")
  34.       side = "5"
  35.     elseif table[3] == 54 and table[4] == 77 then
  36.       print("right")
  37.       side = "4"
  38.     elseif table[3] == 50 and table[4] == 80 then
  39.       print("back")
  40.       side = "2"
  41.     elseif table[3] == 57 and table[4] == 73 then
  42.       print("up")
  43.       side = "1"
  44.     elseif table[3] == 51 and table[4] == 81 then
  45.       print("down")
  46.       side = "0"
  47.     elseif table[3] == 49 and table[4] == 2 then
  48.       print("1")
  49.       m.broadcast(2412,"d.select(1)")
  50.     elseif table[3] == 50 and table[4] == 3 then
  51.       print("2")
  52.       m.broadcast(2412,"d.select(2)")
  53.     elseif table[3] == 51 and table[4] == 4 then
  54.       print("3")
  55.       m.broadcast(2412,"d.select(3)")
  56.     elseif table[3] == 52 and table[4] == 5 then
  57.       print("4")
  58.       m.broadcast(2412,"d.select(4)")
  59.     end
  60.   elseif table[1] == "touch" then
  61.     if table[5] == 0 then
  62.       print("left_click")
  63.       m.broadcast(2412,"d.swing("..side..")")      
  64.     elseif table[5] == 1 then
  65.       print("right_click")
  66.       m.broadcast(2412,"d.place("..side..")")
  67.     end
  68.   end      
  69. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement