minif

setup1.1

Jan 25th, 2020
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.09 KB | None | 0 0
  1. --Minif OS Setup
  2. --Functions and Variables
  3. osSetupUser = ""
  4. osSetupPassword = ""
  5.  
  6. local function createUser(user,password)
  7. local pref = fs.open("/system/user/".. user.."/config", "w")
  8. pref.writeLine("/system/images/minif")
  9. pref.writeLine("true")
  10. pref.close()
  11.  
  12. local pref = fs.open("/system/user/".. user.."/.pass", "w")
  13. pref.writeLine(password)
  14. pref.close()
  15.  
  16. fs.delete("/user/".. user)
  17. fs.makeDir("/user/".. user)
  18. fs.delete("/system/user/".. user.."/icon")
  19. if fs.exists("system/images/user1") then
  20. fs.copy("system/images/user1","/system/user/".. user.."/icon")
  21. end
  22. end
  23.  
  24. local function drawUser()
  25. paintutils.drawFilledBox(3,5,mos.osScreenSizeX-2,mos.osScreenSizeY-4,colors.white)
  26. paintutils.drawBox(2,4,mos.osScreenSizeX-1,mos.osScreenSizeY-3,colors.black)
  27. term.setBackgroundColor(colors.white)
  28. term.setTextColor(colors.black)
  29. term.setCursorPos(5,7)
  30. term.write("Create User: ")
  31. paintutils.drawBox(4,9,mos.osScreenSizeX-3,9,colors.lightBlue)
  32. term.setTextColor(colors.black)
  33. term.setCursorPos(5,9)
  34. if osSetupUser == "" then
  35. term.write("Set Username")
  36. else
  37. term.write(osSetupUser)
  38. end
  39. paintutils.drawBox(4,11,mos.osScreenSizeX-3,11, colors.lightBlue)
  40. term.setTextColor(colors.black)
  41. term.setCursorPos(5,11)
  42. if osSetupPassword == "" then
  43. term.write("Set Password")
  44. else
  45. term.write("********")
  46. end
  47. paintutils.drawBox(4,13,mos.osScreenSizeX-3,13,colors.lightBlue)
  48. term.setTextColor(colors.black)
  49. term.setCursorPos(5,13)
  50. term.write("Create User")
  51. end
  52.  
  53. local function runUser()
  54. while true do
  55. drawUser()
  56. osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
  57. if osPX >= 3 and osPX <= mos.osScreenSizeX-2 then
  58. if osPY == 9 then
  59. paintutils.drawBox(4,9,mos.osScreenSizeX-3,9,colors.lightBlue)
  60. term.setTextColor(colors.black)
  61. term.setCursorPos(5,9)
  62. osSetupUser = read()
  63. else
  64. if osPY == 11 then
  65. paintutils.drawBox(4,11,mos.osScreenSizeX-3,11,colors.lightBlue)
  66. term.setTextColor(colors.black)
  67. term.setCursorPos(5,11)
  68. local temppass = read("*")
  69.  
  70. paintutils.drawBox(4,11,mos.osScreenSizeX-3,11,colors.lightBlue)
  71. term.setTextColor(colors.black)
  72. term.setCursorPos(5,11)
  73. term.write("Confirm: ")
  74. local temppassc = read("*")
  75.  
  76. if temppass == temppassc then
  77. osSetupPassword = temppass
  78. end
  79. else
  80. if osPY == 13 then
  81. if osSetupUser == "" then else
  82. createUser(osSetupUser, osSetupPassword)
  83. if fs.exists("/user/".. osSetupUser) then
  84. term.setBackgroundColor(colors.white)
  85. term.setTextColor(colors.black)
  86. term.setCursorPos(5,15)
  87. term.write("User ".. osSetupUser .. " Created!")
  88. local data = fs.open("system/setupdata","w")
  89. data.writeLine("User Created!")
  90. data.close()
  91. sleep(2)
  92. return
  93. end
  94. end
  95. end
  96. end
  97. end
  98. end
  99. end
  100. end
  101.  
  102. --Execution
  103.  
  104. drawUser()
  105. runUser()
Advertisement
Add Comment
Please, Sign In to add comment