TR1T0N_

Registration

May 18th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.77 KB | None | 0 0
  1. rednet.open("back")
  2.     --create 30 character long key
  3. local random
  4. function randomize()
  5.   random = math.floor(math.random(36))
  6. end
  7. function generate()
  8.  randomize()
  9. charset = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}
  10.  
  11. str = ""; --it has
  12. for i = 1, 30 do
  13. randomize()
  14. str = str..charset[random]
  15. end
  16. createdir()
  17. end
  18.   --create directorys
  19. function createdir()
  20. print("creating user directorys")
  21.   fs.makeDir("usernames/"..str)
  22.   fs.makeDir("userpins/"..str)
  23.   fs.makeDir("userbalance/"..str)
  24.   fs.makeDir("accountlogs/"..str)
  25.   reg()
  26. end
  27.   --request account info
  28. function reg()
  29.   print("input disk")
  30.   event, side = os.pullEvent()
  31.   if event == "disk" and side == "bottom" then
  32.   print("enter name")
  33.   name = read()
  34.   print("enter pin")
  35.   pin = read("*")
  36.   adddata()
  37. end
  38. end
  39.   --add account info to file
  40. function adddata()  
  41. print("adding data to user directorys")
  42.     h = fs.open("usernames/"..str.."/name", "w")
  43.       h.write(name)
  44.     h.close()
  45.   print("username done")
  46.     h = fs.open("userpins/"..str.."/pin", "w")
  47.       h.write(pin)
  48.     h.close()
  49.   print("user pin done")  
  50.     h = fs.open("userbalance/"..str.."/balance", "w")
  51.       h.write(100)
  52.     h.close()
  53.   print("user balance done")
  54.     h = fs.open("accountlogs/"..str.."/transactionlogs", "w")
  55.      h.write("| time | day | ammount | account |")
  56.     h.close()
  57.   print("account logs done")
  58.   print(str)
  59.     h = fs.open("disk/keycode", "w")
  60.      h.write(str)
  61.     h.close()
  62.     disk.eject("bottom")
  63.   print("account created")
  64. end
  65. function backup()
  66. sleep(10)
  67. print("done")
  68. end --but it should have done an error after 10 secs,,, weird
  69. while true do
  70.   generate()
  71. end
Advertisement
Add Comment
Please, Sign In to add comment