Advertisement
AlexOfKing

Suka

May 1st, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. local component = require('component')
  2. local keyboard = require('keyboard')
  3. local shl = require('shell')
  4. local event = require('event')
  5. local robot = require('robot')
  6. local m = component.modem -- get primary modem component
  7.  
  8. local list = {
  9. --движение робота
  10. ['w'] = function(name_key) robot.forward() end,
  11. ['s']= function(name_key) robot.back() end,
  12. ['a']= function(name_key) robot.turnRight() end,
  13. ['d']= function(name_key) robot.turnLeft() end,
  14. ['lshift']= function(name_key) robot.up() end,
  15. ['lcontrol']= function(name_key) robot.down() end
  16. }
  17.  
  18. function Start()
  19. m.open(6791)
  20. m.setWakeMessage('')
  21. m.setStrength(50000)
  22. CheckPort()
  23. end
  24.  
  25. function CheckPort()
  26. if m.isOpen(6791) then
  27. print("Порты открыты. можно работать.")
  28. else
  29. print("Ошибка в открытии порта.")
  30. os.exit()
  31. end
  32. end
  33.  
  34.  
  35. Start()
  36. while true do
  37. e, _, _, code, _, msg = event.pull()
  38.  
  39. if e == 'key_down' then
  40. os.sleep(0.2)
  41. name_key = tostring(keyboard.keys[code])
  42. if list[name_key] then
  43. list[name_key]()
  44. end
  45. elseif e == 'modem_message' then
  46. if msg == "StartFarm" then
  47. shl.execute("pastebin run eDssVHzT")
  48. end
  49. end
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement