Advertisement
Guest User

startup

a guest
Feb 23rd, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.50 KB | None | 0 0
  1. modem = peripheral.wrap("top")
  2. usersApp = fs.open("users", "a")
  3. term.clear()
  4. term.setCursorPos(1, 1)
  5. users = {}
  6. channel1 = 4826
  7. channel2 = 3984
  8. function openPort(port)
  9.   if not modem.isOpen(port) then modem.open(port)
  10.   end
  11. end
  12.  
  13. args = {...}
  14.  
  15. if args[1] == "-mkuser" and #args < 3 then
  16. print("You are missing arguments.")
  17. os.reboot()
  18. end
  19.  
  20. if args[1] == "-mkuser" and #args == 3 then
  21. users[#users+1] = args[2].." "..args[3]
  22. print("User successfully created!")
  23. os.reboot()
  24. end
  25.  
  26. if args[1] == "-delUsers" and args[2] == "u778p" then
  27. usersApp = fs.open("users", "w")
  28. usersApp.write("")
  29. end
  30.  
  31.  
  32. function reset()
  33. term.clear()
  34. term.setCursorPos(1, 1)
  35. end
  36.  
  37. print("Booting")
  38. sleep(0.5)
  39. reset()
  40. print("Booting.")
  41. sleep(0.5)
  42. reset()
  43. print("Booting..")
  44. sleep(0.5)
  45. reset()
  46. print("Booting...")
  47. sleep(1)
  48. reset()
  49.  
  50. openPort(channel1)
  51. openPort(channel2)
  52.  
  53.  
  54. function getInfo(usr, pswd)
  55. while usr == 0 or pswd == 0 do
  56.   event, side, frequency, replyFrequency,
  57.   message, distance =
  58.   os.pullEvent("modem_message")
  59.   if event == "modem_message" then
  60.     if frequency == channel1 then
  61.       username = message
  62.       sendChannel1 = replyFrequency
  63.       usr = 1
  64.       end
  65.       if frequency == channel2 then
  66.       password = message
  67.       sendChannel2 = replyFrequency
  68.       pswd = 1
  69.       end
  70.     end
  71.   end
  72. end
  73.  
  74. function saveUsers(username, password)
  75. usersApp.writeLine(username.." "..password)
  76. usersApp.flush()
  77. end
  78.  
  79. while true do
  80. getInfo(0, 0)
  81. saveUsers(username, password)
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement