Snowdingerr

SnowCenter - Channel14

May 27th, 2021 (edited)
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.24 KB | None | 0 0
  1. -- Register Computer
  2.  
  3. -- Channels
  4. local BANK_SERVER = 12
  5. local REGISTER_COMPUTER = 14
  6. local IMAGE_SERVER = 17
  7. local EVENT_MANAGER = 18
  8. local TURTLESCREEN_COMS = 19
  9. local CARDREADER = 21
  10. rednet.open("bottom")
  11.  
  12. -- Libs
  13.  
  14. -- Code
  15.  
  16. function register(user,name)
  17.     newline()
  18.     term.write("sending request to server")
  19.     rednet.send(BANK_SERVER, {type="registeruser", user=user, name=name}, "bank")
  20.     newline()
  21.     term.write("waiting for server confirmation")
  22.     rednet.receive("bank")
  23.     return
  24. end
  25.  
  26. local drive = peripheral.wrap("top")
  27.  
  28. function newline()
  29.     local cX,cY = term.getCursorPos()
  30.     term.setCursorPos(1,cY+1)
  31. end
  32.  
  33. while true do
  34.     term.clear()
  35.     term.setCursorPos(1,1)
  36.     term.setTextColor(colors.lime)
  37.     term.write("Username")
  38.     term.setCursorPos(1,2)
  39.     term.write("> ")
  40.     term.setTextColor(colors.white)
  41.     local input = read()
  42.     term.setTextColor(colors.lime)
  43.     newline()
  44.     term.write("registering account for user "..input)
  45.     local user = drive.getDiskID()
  46.     register(user, input)
  47.     drive.setDiskLabel("SnowCenter - " .. input)
  48.     local filePath = fs.combine(drive.getMountPath(), "bal")
  49.     file = fs.open(filePath, "w")
  50.     file.write("0")
  51.     file.close()
  52. end
Add Comment
Please, Sign In to add comment