Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Loading some variables.
- local ChoiceA = 0
- h = fs.open("Storage/user","r")
- local user = h.readAll()
- h.close()
- local what = false
- -- Functions
- function readd1(num,secret)
- word = nil
- what = true
- term.setCursorBlink(true)
- local times = tonumber(num)
- while true do
- local x, y = term.getCursorPos()
- local event1, param1, param2, param3 = os.pullEvent()
- if event1 == "char" then
- if word == nil then
- word = param1
- else
- word = (word..param1)
- end
- if secret == nil then
- term.write(param1)
- else
- term.write(secret)
- end
- term.setCursorPos(x + 1,y)
- times = times - 1
- elseif event1 == "key" then
- if param1 == 28 then
- break
- end
- if (param1 == 14) and (string.len(word) > 0) then
- word = string.sub(word,1,-2)
- term.setCursorPos(x - 1,y)
- term.write(" ")
- term.setCursorPos(x - 1,y)
- times = times + 1
- end
- elseif event1 == "mouse_click" then
- if param1 == 1 then
- if (param2 == 51) and (param3 == 1) then
- MenuB = 0
- term.setCursorBlink(false)
- shell.run("OS/.desktop")
- elseif not ((param2 > 12 and param2 < 23) and (param3 == 3)) then
- break
- end
- end
- end
- if times == 0 then
- break
- end
- end
- term.setCursorBlink(false)
- return word,succes
- end
- function readd2(num,secret)
- what = false
- term.setCursorBlink(true)
- local times = tonumber(num)
- while true do
- local x, y = term.getCursorPos()
- local event1, param1, param2, param3 = os.pullEvent()
- if event1 == "char" then
- if word == nil then
- word = param1
- else
- word = (word..param1)
- end
- if secret == nil then
- term.write(param1)
- else
- term.write(secret)
- end
- term.setCursorPos(x + 1,y)
- times = times - 1
- elseif event1 == "key" then
- if param1 == 28 then
- break
- end
- if (param1 == 14) and (string.len(word) > 0) then
- word = string.sub(word,1,-2)
- term.setCursorPos(x - 1,y)
- term.write(" ")
- term.setCursorPos(x - 1,y)
- times = times + 1
- end
- elseif event1 == "mouse_click" then
- if param1 == 1 then
- if (param2 == 51) and (param3 == 1) then
- MenuB = 0
- term.setCursorBlink(false)
- shell.run("OS/.desktop")
- elseif (param2 > 12 and param2 < 23) and (param3 == 3) then
- term.setCursorPos(13,4)
- term.write(" ")
- term.setCursorPos(13,3)
- what = false
- word,what = readd1(10)
- break
- end
- end
- end
- if times == 0 then
- break
- end
- end
- term.setCursorBlink(false)
- return word,what
- end
- function drawinterface1()
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- term.setCursorPos(1,1)
- if fs.exists("Storage/Accounts/"..user.."/.paint/.editBG") then
- EditBG = paintutils.loadImage("Storage/Accounts/" ..user.."/.paint/.editBG")
- paintutils.drawImage(EditBG, 1, 1)
- else
- BaseBG = paintutils.loadImage("Storage/.paint/.baseBG")
- paintutils.drawImage(BaseBG, 1, 1)
- end
- term.setCursorPos(47,1)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.write(" Edit")
- term.setCursorPos(1,19)
- term.setBackgroundColor(colors.yellow)
- term.clearLine()
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.write("Menu")
- term.setCursorPos(1,1)
- end
- function drawmenu1()
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(1,15)
- term.setTextColor(colors.gray)
- term.write("Settings")
- term.setCursorPos(1,16)
- term.setTextColor(colors.gray)
- term.write("Programs")
- term.setCursorPos(1,17)
- term.setTextColor(colors.gray)
- term.write("Reboot ")
- term.setCursorPos(1,18)
- term.setTextColor(colors.gray)
- term.write("Close ")
- end
- function drawSettings1()
- term.setBackgroundColor(colors.lightBlue)
- term.clear()
- paintutils.drawBox(1, 1, 51, 19, colors.yellow)
- term.setBackgroundColor(colors.yellow)
- term.setTextColor(colors.green)
- term.setCursorPos(1,1)
- term.write("Settings")
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.white)
- term.setCursorPos(51,1)
- term.write("X")
- term.setBackgroundColor(colors.lightBlue)
- term.setTextColor(colors.cyan)
- term.setCursorPos(3,3)
- term.write("Username:")
- term.setCursorPos(13,3)
- term.setBackgroundColor(colors.white)
- term.write(" ")
- term.setBackgroundColor(colors.lightBlue)
- term.setCursorPos(3,4)
- term.write("Password:")
- term.setBackgroundColor(colors.white)
- term.setCursorPos(13,4)
- term.write(" ")
- end
- -- Creating the interface.
- drawinterface1()
- if MenuB == 1 then
- drawmenu1()
- end
- local function checkevents()
- -- Handling the events.
- while true do
- local event, button, x, y = os.pullEvent("mouse_click")
- if button == 1 then
- if (x == 1 or x == 2 or x == 3 or x == 4) and (y == 19) then
- MenuB = 1
- drawmenu1()
- end
- if (x > 0 and x < 9) and (MenuB == 1) and (y < 19 and y > 14) then
- if (y == 18) and (x < 9) then
- ChoiceA = 2
- break
- elseif (y == 17) and (x < 9) then
- ChoiceA = 3
- break
- elseif (y == 16) and (x < 9) then
- ChoiceA = 4
- break
- elseif (y == 15) and (x < 9) then
- ChoiceA = 5
- drawSettings1()
- break
- end
- end
- if (ChoiceA ~= 5) and (x == 47 or x == 48 or x == 49 or x == 50 or x == 51) and (y == 1) then
- ChoiceA = 1
- break
- end
- end
- end
- -- Outcome for the events.
- if ChoiceA == 1 then
- MenuB = 0
- shell.run("paint","Storage/Accounts/"..user.. "/.paint/.editBG")
- shell.run("OS/.desktop")
- elseif ChoiceA == 2 then
- MenuB = 0
- shell.run("OS/.desktop")
- term.clear()
- sleep(3)
- elseif ChoiceA == 3 then
- MenuB = 0
- os.reboot()
- elseif ChoiceA == 4 then
- MenuB = 0
- shell.run("OS/.programmefinder")
- shell.run("OS/.desktop")
- elseif ChoiceA == 5 then
- drawSettings1()
- while true do
- drawSettings1()
- local event, button, x, y = os.pullEvent("mouse_click")
- if button == 1 then
- if (x > 12 and x < 23) and (y == 3) then
- term.setBackgroundColor(colors.pink)
- term.setCursorPos(13,3)
- local newUsername,succes = readd1(10)
- if newUsername ~= nil then
- if succes == true then
- shell.run("rename","Storage/Accounts/"..user,"Storage/Accounts/"..newUsername)
- local h = fs.open("Storage/user","w")
- h.write(newUsername)
- h.close()
- end
- end
- term.setCursorPos(3,2)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.lime)
- if succes == true then
- term.write("Succesfully changed to: "..newUsername)
- end
- sleep(1)
- drawSettings1()
- elseif (x > 12 and x < 23) and (y == 4) then
- term.setBackgroundColor(colors.pink)
- term.setCursorPos(13,4)
- local newPassword,what = readd2(10,"*")
- if what == true then
- shell.run("rename","Storage/Accounts/"..user,"Storage/Accounts/"..newPassword)
- local h = fs.open("Storage/user","w")
- h.write(newPassword)
- h.close()
- end
- if what == false then
- local h =
- fs.open("Storage/Accounts/"..user.."/password","w")
- h.write(newPassword)
- h.close()
- end
- term.setCursorPos(3,2)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.lime)
- if what == false then
- term.write("Succesfully changed password!")
- end
- if what == true then
- term.write("Succesfully changed to: " .. (newPassword))
- end
- sleep(1)
- drawSettings1()
- elseif (x == 51) and (y == 1) then
- MenuB = 0
- shell.run("OS/.desktop")
- end
- end
- end
- end
- end
- checkevents()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement