Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clear()
- term.clear()
- term.setCursorPos(1, 1)
- end
- function drawlist(title, list, num)
- clear()
- term.setTextColor(colors.lime)
- print(title.."\n")
- for i,v in pairs(list) do
- if i == num then
- term.setTextColor(colors.white)
- write("[")
- term.setTextColor(colors.lime)
- write("-")
- term.setTextColor(colors.white)
- write("]")
- term.setTextColor(colors.lime)
- print(" "..v)
- else
- term.setTextColor(colors.white)
- print("[ ] "..v)
- end
- end
- end
- function getKey()
- local rt = nil
- function lop()
- local e, a1 = os.pullEvent("key")
- if a1 == 200 then
- rt = "up"
- elseif a1 == 208 then
- rt = "down"
- elseif a1 == 28 then
- rt = "enter"
- else
- lop()
- end
- end
- lop()
- repeat sleep(0) until rt ~= nil
- return rt
- end
- function ch(title, list)
- clear()
- local ind = 1
- drawlist(title, list, ind)
- local rt = nil
- cycle = function()
- local ke = getKey()
- if ke == "up" then
- if ind > 1 then
- ind = ind - 1
- else
- ind = #list
- end
- drawlist(title, list, ind)
- cycle()
- elseif ke == "down" then
- if ind < #list then
- ind = ind + 1
- else
- ind = 1
- end
- drawlist(title, list, ind)
- cycle()
- elseif ke == "enter" then
- rt = ind
- end
- end
- cycle()
- repeat sleep(0) until rt ~= nil
- return ind
- end
- function main()
- local lts = ch("Main menu", {"Login", "Create account", "Pay user", "Check money"})
- if lts == 1 then
- clear()
- term.setTextColor(colors.lime)
- print("Login:\n")
- term.setTextColor(colors.white)
- write("Username: ")
- term.setTextColor(colors.lime)
- local user = tostring(read())
- term.setTextColor(colors.white)
- write("Password: ")
- term.setTextColor(colors.lime)
- local pass = tostring(read("*"))
- term.setTextColor(colors.white)
- clear()
- elseif lts == 2 then
- clear()
- term.setTextColor(colors.lime)
- print("Create account:\n")
- term.setTextColor(colors.white)
- write("Username: ")
- term.setTextColor(colors.lime)
- local user = tostring(read())
- term.setTextColor(colors.white)
- write("Password: ")
- term.setTextColor(colors.lime)
- local pass = tostring(read("*"))
- term.setTextColor(colors.white)
- write("Confirm password: ")
- term.setTextColor(colors.lime)
- local pass2 = tostring(read("*"))
- term.setTextColor(colors.white)
- if pass == pass2 then
- end
- clear()
- end
- end
- main()
Add Comment
Please, Sign In to add comment