Advertisement
serafim7

Remoute Control Tablet [OpenComputers]

Jun 10th, 2017
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.20 KB | None | 0 0
  1. --[[ OpenComputers Удалённое управление роботом by serafim
  2.      http://pastebin.com/MY7qcets
  3.  
  4. с защитой от угона при помощи авторизации
  5. программа для планшета или пк !
  6.  
  7. требования:
  8. планшет первого уровня, карта wi-fi
  9.  
  10. ]]--
  11.  
  12. local comp = require("component")
  13. local event = require("event")
  14. local term = require("term")
  15. local gpu = comp.gpu
  16.  
  17. local x_max, y_max = gpu.maxResolution()
  18. local x_min, y_min = 2, 1
  19. local full = false
  20. local port = 123
  21.  
  22. if comp.isAvailable("modem") then
  23.   modem = comp.modem
  24. else
  25.   print("Нет модема !")
  26.   os.exit()
  27. end
  28.  
  29. local function info()
  30. term.clear()
  31. print("\n".."\n"..[[
  32. 1 подключиться
  33. E разрушить                         вверх
  34. R поставить                    W    Space
  35. F использовать                A D
  36. X поворот на 180               S    вниз
  37. C изменить цвет                     LShift
  38. T забрать все вещи
  39. G выбросить все вещи
  40. V вкл/выкл редстоун сигнал
  41. Z уменьшить/увеличить экран
  42. Q выход
  43. ]])
  44. end
  45.  
  46. local function link()
  47.   term.clear()
  48.   term.write("Введите pin ")
  49.   io.write(">>")
  50.   modem.broadcast(port,io.read())
  51.   local e = {event.pull(1,'modem_message')}
  52.   if e[6] == "false" then
  53.     term.write("pin не верный !")
  54.     os.sleep(1)
  55.     term.clear()
  56.     link()
  57.   elseif e[6] == "true" then
  58.     term.write("Подключен !")
  59.   else
  60.     term.write("Нет ответа !")
  61.   end
  62.   os.sleep(1)
  63. end
  64.  
  65. modem.open(port)
  66. link()
  67. info()
  68.  
  69. while true do
  70.   local e = {event.pull('key_down')}
  71.   modem.broadcast(port, e[4])
  72.   term.setCursor(1,1)
  73.   term.clearLine()
  74.   term.write(e[4])
  75.   if e[4] == 44 then
  76.     full = not full
  77.     if full then
  78.       gpu.setResolution(x_min,y_min)
  79.     else
  80.       gpu.setResolution(x_max,y_max)
  81.       info()
  82.     end
  83.   elseif e[4] == 16 then
  84.     gpu.setResolution(x_max,y_max)
  85.     term.write("  Выход")
  86.     os.sleep(1)
  87.     term.clear()
  88.     os.exit()
  89.   elseif e[4] == 2 then
  90.     link()
  91.     info()
  92.   end
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement