Advertisement
klindley

carriage

Jan 30th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. -- Turbolift Carriage Client
  2. -- For use in NCC-1701-D
  3. -- This client resides in the carriage
  4. -- it talks to the server to operate
  5. -- the lift. Computer is configured
  6. -- with a modem and a chat listener.
  7.  
  8. function loadSettings()
  9. settings = json.decode("/sys/turbolift/conf.json")
  10. if settings == nil then
  11. settings = {modemSide = "top", rsSide = "left", chatterSide = "right", name = "", deck = ""}
  12. end
  13. end
  14.  
  15. function writeSettings()
  16. local s = fs.open("/sys/turbolift/conf.json", "w")
  17. s.write(json.encode(settings))
  18. s.close()
  19. end
  20.  
  21. -- transporter cab waits patiently for
  22. -- someone to talk.
  23. function onChat(p, m)
  24. local req = {cmd = "findDoor", player = p, cabId = settings.cabId, query = m}
  25. rednet.send(settings.serv, json.encode(req)
  26. end
  27.  
  28. function onDoorFound(d)
  29. local req = {cmd = "set", dst = d, cabId = settings.cabId}
  30. rednet.send(settings.serv, json.encode(req))
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement