Advertisement
Karnel

Server

Jul 14th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.40 KB | None | 0 0
  1. local com = require("component")
  2. local thread = require("thread")
  3. local event = require("event")
  4. local modem = com.modem
  5. local gpu = com.gpu
  6. local port = 666   ---------> используемый порт
  7. local pass = "gogo"
  8. thread.init()
  9.  
  10. local doit = {}
  11. doit[54] = "up"
  12. doit[157] = "down"
  13. doit[203] = "left"
  14. doit[205] = "right"
  15. doit[200] = "forward"
  16. doit[208] = "back"
  17. doit[48] = "swing"
  18. doit[47] = "swingUp"
  19. doit[49] = "swingDown"
  20. doit[45] = "use"
  21. doit[44] = "useUp"
  22. doit[46] = "useDown"
  23. doit[51] = "place"
  24. doit[50] = "placeUp"
  25. doit[52] = "placeDown"
  26. doit[31] = "suck"
  27. doit[30] = "suckUp"
  28. doit[32] = "suckDown"
  29. doit[16] = "drop"
  30. doit[41] = "password"
  31. doit[28] = "hide"
  32.  
  33. modem.close()
  34. modem.open(port)
  35. modem.setStrength(500)
  36.  
  37. modem.broadcast(port, pass)
  38.  
  39. local _, _, _, _, _, clientAddr = event.pull("modem_message", nil, nil, port)
  40.     print(clientAddr)
  41.  
  42. local function msgRead()
  43.     while true do
  44.         local _, _, _, _, _, msg = event.pull("modem_message", nil, clientAddr, port)
  45.         print(">>"..tostring(msg))
  46.     end
  47. end
  48.  
  49. thread.create(msgRead)
  50. while true do
  51.     local _, _, _, k, _ = event.pull("key_up")
  52.     if doit[tonumber(k)] ~= "hide" then
  53.         modem.send(clientAddr, port, doit[tonumber(k)])
  54.         print(doit[k])
  55.     else
  56.         local _, res = gpu.getResolution()
  57.         if res == 25 then
  58.             gpu.setResolution(10, 3)
  59.         else
  60.             gpu.setResolution(80, 25)
  61.         end
  62.     end
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement