Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local fs = require("filesystem")
- local gpu = require("component").gpu
- local term = require("term")
- local event = require("event")
- local io = require("io")
- local unicode = require("unicode")
- local computer = require("computer")
- local shell = require("shell")
- arg = shell.parse(...)
- if arg[1] == "res" then res = true else res = false end
- function draw(mas)
- for i = 1, #mas do
- if mas [i][9] ~= false then
- local posX = mas[i][1] + mas[i][3] / 2 - unicode.wlen(mas[i][7]) / 2
- local posY = mas[i][2] + mas[i][4] / 2
- gpu.setBackground(mas[i][5])
- gpu.setForeground(mas[i][6])
- gpu.fill(mas[i][1], mas[i][2], mas[i][3], mas[i][4], " ")
- gpu.set(posX, posY, mas[i][7])
- end
- end
- end
- function ev(...)
- local args = {...}
- local close = false
- while not close do
- local _, _, x, y = event.pull(0, "touch")
- if x ~= nil and y ~= nil then
- for i = 1, #args do
- local mas = args[i]
- for j = 1, #mas do
- if x >= mas[j][1] and x <= mas[j][1] + mas[j][3] - 1 and y >= mas[j][2] and y <= mas[j][2] + mas[j][4] - 1 and mas[j][9] ~= false then mas[j][8]() end
- end
- if mas.close == true then close = true end
- end
- end
- end
- end
- function getPassword(path)
- file = io.open(path, "r")
- password = file:read()
- file:close()
- return password
- end
- function setPassword(path, password)
- file = io.open(path, "w")
- file:write(password)
- file:close()
- end
- pass = ""
- function pClear()
- pass = ""
- pField[2][5] = 0x86ff80
- pField[1][7] = pass
- draw(pField)
- os.sleep(0.2)
- pField[2][5] = 0x00ff00
- draw(pField)
- end
- pField = {
- {1, 1, 4, 1, 0xffffff, 0x000000, pass, justFunction},
- {9, 1, 4, 1, 0x00ff00, 0xffffff, "CL", pClear},
- {17, 1, 2, 1, 0xffffff, 0x000000, "", checkPass},
- {19, 1, 2, 1, 0x000000, 0x000000, "", settings}
- }
- sField = {
- {1, 1, 14, 1, 0x323232, 0xffffff, "Password: " .. getPassword("/home/Data/password"), changePassword},
- {1, 3, 2, 1, 0xff8000, 0xffffff, "OK", returnToNump}
- }
- function justFunction() end
- function settings()
- if pass == getPassword("/home/Data/password") then
- if not res then gpu.setResolution(14, 3) end
- pass = ""
- buttons1.close = true
- gpu.setBackground(0x323232)
- term.clear()
- draw(sField)
- ev(sField)
- end
- end
- function returnToNump()
- buttons1.close = false
- pass = ""
- pField[1][7] = ""
- sField.close = true
- for i = 1, #pField do pField[i][9] = true end
- if not res then gpu.setResolution(20, 17) end
- pField[3][8] = checkPass
- gpu.setBackground(0x323232)
- term.clear()
- draw(buttons1)
- draw(pField)
- ev(buttons1, pField)
- end
- function pDone()
- buttons1.close = true
- sField.close = false
- setPassword("/home/Data/password", pass)
- sField[1][7] = "Password: " .. pass
- if not res then gpu.setResolution(14, 3) end
- gpu.setBackground(0x323232)
- term.clear()
- draw(sField)
- ev(sField)
- end
- function changePassword()
- if not res then gpu.setResolution(20, 17) end
- gpu.setBackground(0x323232)
- term.clear()
- pField[4][9] = false
- draw(buttons1)
- draw(pField)
- sField.close = true
- buttons1.close = false
- pField[3][8] = pDone
- ev(buttons1, pField)
- end
- function checkPass()
- if pass == getPassword("/home/Data/password") then
- pass = ""
- pField[1][7] = pass
- draw(pField)
- pField[3][5] = 0x00ff00
- draw(pField)
- os.sleep(0.2)
- pField[3][5] = 0xffffff
- draw(pField)
- assert(loadfile("/home/Data/Unlock"))()
- else
- pField[3][5] = 0xff0000
- draw(pField)
- os.sleep(0.2)
- pField[3][5] = 0xffffff
- draw(pField)
- end
- end
- function b1()
- buttons1[1][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[1][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "1" end
- pField[1][7] = pass
- draw(pField)
- end
- function b2()
- buttons1[2][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[2][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "2" end
- pField[1][7] = pass
- draw(pField)
- end
- function b3()
- buttons1[3][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[3][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "3" end
- pField[1][7] = pass
- draw(pField)
- end
- function b4()
- buttons1[4][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[4][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "4" end
- pField[1][7] = pass
- draw(pField)
- end
- function b5()
- buttons1[5][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[5][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "5" end
- pField[1][7] = pass
- draw(pField)
- end
- function b6()
- assert(loadfile("/bin/mkdir.lua"))()
- buttons1[6][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[6][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "6" end
- pField[1][7] = pass
- draw(pField)
- end
- function b7()
- buttons1[7][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[7][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "7" end
- pField[1][7] = pass
- draw(pField)
- end
- function b8()
- buttons1[8][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[8][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "8" end
- pField[1][7] = pass
- draw(pField)
- end
- function b9()
- buttons1[9][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[9][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "9" end
- pField[1][7] = pass
- draw(pField)
- end
- function b10()
- buttons1[10][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[10][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "*" end
- pField[1][7] = pass
- draw(pField)
- end
- function b11()
- buttons1[11][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[11][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "0" end
- pField[1][7] = pass
- draw(pField)
- end
- function b12()
- buttons1[12][5] = 0xffd15c
- draw(buttons1)
- os.sleep(0.2)
- buttons1[12][5] = 0xff8000
- draw(buttons1)
- if unicode.wlen(pass) < 4 then pass = pass .. "#" end
- pField[1][7] = pass
- draw(pField)
- end
- buttons1 = {
- {1, 3, 6, 3, 0xff8000, 0xffffff, "1", b1},
- {8, 3, 6, 3, 0xff8000, 0xffffff, "2", b2},
- {15, 3, 6, 3, 0xff8000, 0xffffff, "3", b3},
- {1, 7, 6, 3, 0xff8000, 0xffffff, "4", b4},
- {8, 7, 6, 3, 0xff8000, 0xffffff, "5", b5},
- {15, 7, 6, 3, 0xff8000, 0xffffff, "6", b6},
- {1, 11, 6, 3, 0xff8000, 0xffffff, "7", b7},
- {8, 11, 6, 3, 0xff8000, 0xffffff, "8", b8},
- {15, 11, 6, 3, 0xff8000, 0xffffff, "9", b9},
- {1, 15, 6, 3, 0xff8000, 0xffffff, "*", b10},
- {8, 15, 6, 3, 0xff8000, 0xffffff, "0", b11},
- {15, 15, 6, 3, 0xff8000, 0xffffff, "#", b12}
- }
- ------------------------------------------------------------------------------------
- if not res then gpu.setResolution(20, 17) end
- gpu.setBackground(0x323232)
- term.clear()
- draw(buttons1)
- draw(pField)
- ev(buttons1, pField)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement