Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Minif OS Setup
- --Functions and Variables
- osSetupUser = ""
- osSetupPassword = ""
- local function createUser(user,password)
- local pref = fs.open("/system/user/".. user.."/config", "w")
- pref.writeLine("/system/images/minif")
- pref.writeLine("true")
- pref.close()
- local pref = fs.open("/system/user/".. user.."/.pass", "w")
- pref.writeLine(password)
- pref.close()
- fs.delete("/user/".. user)
- fs.makeDir("/user/".. user)
- fs.delete("/system/user/".. user.."/icon")
- if fs.exists("system/images/user1") then
- fs.copy("system/images/user1","/system/user/".. user.."/icon")
- end
- end
- local function drawUser()
- paintutils.drawFilledBox(3,5,mos.osScreenSizeX-2,mos.osScreenSizeY-4,colors.white)
- paintutils.drawBox(2,4,mos.osScreenSizeX-1,mos.osScreenSizeY-3,colors.black)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos(5,7)
- term.write("Create User: ")
- paintutils.drawBox(4,9,mos.osScreenSizeX-3,9,colors.lightBlue)
- term.setTextColor(colors.black)
- term.setCursorPos(5,9)
- if osSetupUser == "" then
- term.write("Set Username")
- else
- term.write(osSetupUser)
- end
- paintutils.drawBox(4,11,mos.osScreenSizeX-3,11, colors.lightBlue)
- term.setTextColor(colors.black)
- term.setCursorPos(5,11)
- if osSetupPassword == "" then
- term.write("Set Password")
- else
- term.write("********")
- end
- paintutils.drawBox(4,13,mos.osScreenSizeX-3,13,colors.lightBlue)
- term.setTextColor(colors.black)
- term.setCursorPos(5,13)
- term.write("Create User")
- end
- local function runUser()
- while true do
- drawUser()
- osPEvent, osPB, osPX, osPY = os.pullEvent("mouse_click")
- if osPX >= 3 and osPX <= mos.osScreenSizeX-2 then
- if osPY == 9 then
- paintutils.drawBox(4,9,mos.osScreenSizeX-3,9,colors.lightBlue)
- term.setTextColor(colors.black)
- term.setCursorPos(5,9)
- osSetupUser = read()
- else
- if osPY == 11 then
- paintutils.drawBox(4,11,mos.osScreenSizeX-3,11,colors.lightBlue)
- term.setTextColor(colors.black)
- term.setCursorPos(5,11)
- local temppass = read("*")
- paintutils.drawBox(4,11,mos.osScreenSizeX-3,11,colors.lightBlue)
- term.setTextColor(colors.black)
- term.setCursorPos(5,11)
- term.write("Confirm: ")
- local temppassc = read("*")
- if temppass == temppassc then
- osSetupPassword = temppass
- end
- else
- if osPY == 13 then
- if osSetupUser == "" then else
- createUser(osSetupUser, osSetupPassword)
- if fs.exists("/user/".. osSetupUser) then
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.setCursorPos(5,15)
- term.write("User ".. osSetupUser .. " Created!")
- local data = fs.open("system/setupdata","w")
- data.writeLine("User Created!")
- data.close()
- sleep(2)
- return
- end
- end
- end
- end
- end
- end
- end
- end
- --Execution
- drawUser()
- runUser()
Advertisement
Add Comment
Please, Sign In to add comment