Advertisement
Callumpy

ComputerCraft Door Client-Inside

Apr 28th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. -- CLIENT-INSIDE
  2.  
  3. -- Put a modem on this client and set it's side below.
  4. -- Enter the ID of the server computer, type 'id' to find.
  5. -- Server deals with password and door opening mechanics.
  6.  
  7. -----------------------------------------------------------
  8.  
  9. local serverId = CHANGE_THIS
  10. local modemSide = "back"
  11.  
  12. -----------------------------------------------------------
  13.  
  14. local welcome = [[
  15. **************************************************
  16. *                                                *
  17. *         Goodbye from Nuke Corp Facility        *
  18. *                                                *
  19. *                   DRIVE SAFE                   *
  20. *                                                *
  21. *              Press RETURN to leave             *
  22. *                                                *
  23. **************************************************
  24. ]]
  25.  
  26. function clearTerm()
  27.   term.clear()
  28.   term.setCursorPos(1, 1)
  29. end
  30.  
  31. rednet.open(modemSide)
  32.  
  33. while true do
  34.   clearTerm()
  35.   print(welcome)
  36.   local pass = read("*")
  37.   clearTerm()
  38.   textutils.slowPrint("Waiting for response from server.")
  39.  
  40.   local id, access
  41.   repeat
  42.     rednet.send(serverId, pass)
  43.     id, access, doorTime, alarmTime = rednet.receive()
  44.   until id == serverId
  45.   if access == "granted" then
  46.     clearTerm()
  47.     textutils.slowPrint("Doors open for ".. doorTime .." seconds.")
  48.     sleep(doorTime)
  49.   end
  50. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement