Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Code by Max Wason
- monitorSide = "right"
- wirelessRedstoneSide = "back"
- wirelessModemSide = "right"
- mystcraftTurtleID = 3
- AEcomputerID = 14
- tankComputerID = 16
- powerComputerID = 6
- --wr = peripheral.wrap(wirelessRedstoneSide)
- --rednet.open(wirelessModemSide)
- monitor = peripheral.wrap(monitorSide)
- print(monitor.getSize())
- os.loadAPI("touchpointEdited")
- -- local page1 = touchpointEdited.new(monitorSide)
- -- local page2 = touchpointEdited.new(monitorSide)
- local loginPage = touchpointEdited.new(monitorSide) --Login
- local mainPage = touchpointEdited.new(monitorSide) --Main screen after login
- local accountPage = touchpointEdited.new(monitorSide)
- local changePasswordPage = touchpointEdited.new(monitorSide)
- local changeAccessPage = touchpointEdited.new(monitorSide)
- local changeAddUserPage = touchpointEdited.new(monitorSide)
- local changeRemoveUserPage = touchpointEdited.new(monitorSide)
- local mystcraftPage = touchpointEdited.new(monitorSide)
- local mystcraftInterlinkingPage = touchpointEdited.new(monitorSide)
- local mystcraftIntralinkingPage = touchpointEdited.new(monitorSide)
- local powerPage = touchpointEdited.new(monitorSide)
- local oreProcessingPage = touchpointEdited.new(monitorSide)
- local aePage = touchpointEdited.new(monitorSide)
- local nuclearControlPage = touchpointEdited.new(monitorSide)
- local t
- --*******************************************************Profile Class********************************************************************
- Profile = {}
- Profile.__index = Profile
- function Profile.create(name, password, access)
- local profile = {}
- setmetatable(profile,Profile)
- profile.name = name
- profile.password = password
- profile.access = access
- return profile
- end
- --********************************************************END OF PROFILE CLASS*************************************************************
- --*******************************************************FILE IO************************************************************************
- fileName = "userData.txt"
- function file_exists(name)
- local f=io.open(name,"r")
- if f~=nil then io.close(f) return true else return false end
- end
- local write, writeIndent, writers, refCount;
- persistence =
- {
- store = function (path, ...)
- local file, e = io.open(path, "w");
- if not file then
- return error(e);
- end
- local n = select("#", ...);
- -- Count references
- local objRefCount = {}; -- Stores reference that will be exported
- for i = 1, n do
- refCount(objRefCount, (select(i,...)));
- end;
- -- Export Objects with more than one ref and assign name
- -- First, create empty tables for each
- local objRefNames = {};
- local objRefIdx = 0;
- file:write("-- Persistent Data\n");
- file:write("local multiRefObjects = {\n");
- for obj, count in pairs(objRefCount) do
- if count > 1 then
- objRefIdx = objRefIdx + 1;
- objRefNames[obj] = objRefIdx;
- file:write("{};"); -- table objRefIdx
- end;
- end;
- file:write("\n} -- multiRefObjects\n");
- -- Then fill them (this requires all empty multiRefObjects to exist)
- for obj, idx in pairs(objRefNames) do
- for k, v in pairs(obj) do
- file:write("multiRefObjects["..idx.."][");
- write(file, k, 0, objRefNames);
- file:write("] = ");
- write(file, v, 0, objRefNames);
- file:write(";\n");
- end;
- end;
- -- Create the remaining objects
- for i = 1, n do
- file:write("local ".."obj"..i.." = ");
- write(file, (select(i,...)), 0, objRefNames);
- file:write("\n");
- end
- -- Return them
- if n > 0 then
- file:write("return obj1");
- for i = 2, n do
- file:write(" ,obj"..i);
- end;
- file:write("\n");
- else
- file:write("return\n");
- end;
- file:close();
- end;
- load = function (path)
- local f, e = loadfile(path);
- if f then
- return f();
- else
- return nil, e;
- end;
- end;
- }
- -- Private methods
- -- write thing (dispatcher)
- write = function (file, item, level, objRefNames)
- writers[type(item)](file, item, level, objRefNames);
- end;
- -- write indent
- writeIndent = function (file, level)
- for i = 1, level do
- file:write("\t");
- end;
- end;
- -- recursively count references
- refCount = function (objRefCount, item)
- -- only count reference types (tables)
- if type(item) == "table" then
- -- Increase ref count
- if objRefCount[item] then
- objRefCount[item] = objRefCount[item] + 1;
- else
- objRefCount[item] = 1;
- -- If first encounter, traverse
- for k, v in pairs(item) do
- refCount(objRefCount, k);
- refCount(objRefCount, v);
- end;
- end;
- end;
- end;
- -- Format items for the purpose of restoring
- writers = {
- ["nil"] = function (file, item)
- file:write("nil");
- end;
- ["number"] = function (file, item)
- file:write(tostring(item));
- end;
- ["string"] = function (file, item)
- file:write(string.format("%q", item));
- end;
- ["boolean"] = function (file, item)
- if item then
- file:write("true");
- else
- file:write("false");
- end
- end;
- ["table"] = function (file, item, level, objRefNames)
- local refIdx = objRefNames[item];
- if refIdx then
- -- Table with multiple references
- file:write("multiRefObjects["..refIdx.."]");
- else
- -- Single use table
- file:write("{\n");
- for k, v in pairs(item) do
- writeIndent(file, level+1);
- file:write("[");
- write(file, k, level+1, objRefNames);
- file:write("] = ");
- write(file, v, level+1, objRefNames);
- file:write(";\n");
- end
- writeIndent(file, level);
- file:write("}");
- end;
- end;
- ["function"] = function (file, item)
- -- Does only work for "normal" functions, not those
- -- with upvalues or c functions
- local dInfo = debug.getinfo(item, "uS");
- if dInfo.nups > 0 then
- file:write("nil --[[functions with upvalue not supported]]");
- elseif dInfo.what ~= "Lua" then
- file:write("nil --[[non-lua function not supported]]");
- else
- local r, s = pcall(string.dump,item);
- if r then
- file:write(string.format("loadstring(%q)", s));
- else
- file:write("nil --[[function could not be dumped]]");
- end
- end
- end;
- ["thread"] = function (file, item)
- file:write("nil --[[thread]]\n");
- end;
- ["userdata"] = function (file, item)
- file:write("nil --[[userdata]]\n");
- end;
- }
- if file_exists(fileName) then
- profileArray = persistence.load(fileName);
- else
- profileArray = {
- Profile.create("gr8pefish", "temporary", 1),
- Profile.create("admin", "pass", 1),
- Profile.create("guest", "password", 3),
- Profile.create("Test Account", "Pass 123", 1)
- }
- persistence.store(fileName, profileArray)
- end
- --***************************************************EDN OF FILE IO************************************************************************
- --********************************************************KEYBOARD/LOGIN********************************************************************
- username = ""
- password = ""
- input = ""
- useUppercase = false
- useUsername = true
- usePassword = false
- usernameSubmittedExists = false
- loginPasswordExists = false
- loginUsernameExists = false
- loginPassword = ""
- loginUsername = ""
- currentUser = nil
- valid = false
- function checkValid()
- if (loginPasswordExists and loginUsernameExists) then
- for key, value in pairs(profileArray) do
- if loginUsername == value.name then
- usernameSubmittedExists = true
- if loginPassword == value.password then
- valid = true
- currentUser = value
- else
- valid = false
- end
- end
- end
- drawMessage()
- end
- end
- function checkValidUsernameAndPassword(confirm)
- if confirm == "goOn" then
- t = mainPage
- elseif confirm == "backToPassword" then
- drawPassword()
- elseif confirm == "backToUsername" then
- drawUsername()
- elseif confirm == "password" then
- confirmPassword()
- checkValid()
- elseif confirm == "username" then
- confirmUsername()
- checkValid()
- end
- end
- function confirmPassword()
- loginPassword = input
- loginPasswordExists = true
- input = ""
- usePassword = false
- useUsername = true
- drawUsername()
- doBackspace()
- end
- function confirmUsername()
- loginUsername = input
- loginUsernameExists = true
- input = ""
- useUsername = false
- usePassword = true
- drawPassword()
- doBackspace()
- end
- local inputTable = {
- " ",
- " ",
- label = "inputLabel",
- }
- local ArrowTable = {
- "-->",
- label = "ArrowLabel",
- }
- local additionalOkayTable = {
- "Okay",
- label = "additionalOkayLabel"
- }
- local loginTable = {
- " Please Login ",
- " ",
- "Enter your username and password.",
- "Press okay to confirm each. ",
- label = "loginTableLabel",
- }
- local infoTableUsername = {
- "Enter your username: ",
- label = "infoLabel"
- }
- function drawMessage()
- if valid then
- infoTableContinue = {"Welcome Back!", label = "infoLabel"}
- loginPage:rename("infoLabel", infoTableContinue)
- inputTableContinue = {currentUser.name,"Access Level: "..currentUser.access, label = "inputLabel"}
- loginPage:rename("inputLabel", inputTableContinue)
- key = "goOn"
- elseif usernameSubmittedExists then
- infoTableContinue = {"You seem to have entered", label = "infoLabel"}
- loginPage:rename("infoLabel", infoTableContinue)
- inputTableContinue = {"the wrong password",loginUsername, label = "inputLabel"}
- loginPage:rename("inputLabel", inputTableContinue)
- loginPasswordExists = false
- useUsername = false
- usePassword = true
- input = ""
- key = "backToPassword"
- else
- infoTableContinue = {"There is no username called", label = "infoLabel"}
- loginPage:rename("infoLabel", infoTableContinue)
- inputTableContinue = {loginUsername," ", label = "inputLabel"}
- loginPage:rename("inputLabel", inputTableContinue)
- loginPasswordExists = false
- loginUsernameExists = false
- useUsername = true
- usePassword = false
- input = ""
- key = "backToUsername"
- end
- end
- function drawUsername()
- key = "username"
- loginPage:rename("infoLabel", infoTableUsername)
- doBackspace()
- end
- function drawPassword()
- key = "password"
- infoTablePassword = {"Enter your password: ", label = "infoLabel"}
- loginPage:rename("infoLabel", infoTablePassword)
- doBackspace()
- end
- function updateUsernameOutput(input)
- if (#input < 16) then
- input = (input..(string.rep(" ",(16-#input))))
- end
- newInput = {input," ", label = "inputLabel"}
- loginPage:rename("inputLabel", newInput, true)
- end
- function addToInput(char)
- if useUppercase then char = char:upper() end
- if (#input >= 16) then
- input = input:sub(0,16)
- else
- input = (input..char)
- end
- if useUsername then
- updateUsernameOutput(input)
- else
- updatePasswordOutput(input)
- end
- end
- function updatePasswordOutput(input)
- input2 = string.rep("*", #input)
- if (#input < 16) then
- input = (input..(string.rep(" ",(16-#input))))
- end
- newInput = {input2," ", label = "inputLabel"}
- loginPage:rename("inputLabel", newInput, true)
- end
- key = "username"
- loginPage:add(loginTable, nil, 3, 35, 2, 5, colors.black, colors.black, colors.brown)
- loginPage:add(infoTableUsername, nil, 5, 28, 9, 9, colors.black, colors.black, colors.lightGray)
- loginPage:add(ArrowTable, nil, 1, 4, 10, 10, colors.black, colors.black, colors.brown)
- loginPage:add(inputTable, nil, 5, 22, 10, 11, colors.black, colors.black, colors.lightGray)
- loginPage:add("Okay", function() checkValidUsernameAndPassword(key) end, 25, 30, 10, 10, colors.black, colors.black, colors.cyan)
- loginPage:add("1", function() addToInput("1") end, 5, 5, 14, 14, colors.black, colors.black, colors.lightGray)
- loginPage:add("2", function() addToInput("2") end, 7, 7, 14, 14, colors.black, colors.black, colors.lightGray)
- loginPage:add("3", function() addToInput("3") end, 9, 9, 14, 14, colors.black, colors.black, colors.lightGray)
- loginPage:add("4", function() addToInput("4") end, 11, 11, 14, 14, colors.black, colors.black, colors.lightGray)
- loginPage:add("5", function() addToInput("5") end, 13, 13, 14, 14, colors.black, colors.black, colors.lightGray)
- loginPage:add("6", function() addToInput("6") end, 15, 15, 14, 14, colors.black, colors.black, colors.lightGray)
- loginPage:add("7", function() addToInput("7") end, 17, 17, 14, 14, colors.black, colors.black, colors.lightGray)
- loginPage:add("8", function() addToInput("8") end, 19, 19, 14, 14, colors.black, colors.black, colors.lightGray)
- loginPage:add("9", function() addToInput("9") end, 21, 21, 14, 14, colors.black, colors.black, colors.lightGray)
- loginPage:add("0", function() addToInput("0") end, 23, 23, 14, 14, colors.black, colors.black, colors.lightGray)
- loginPage:add("Q", function() addToInput("q") end, 5, 5, 15, 15, colors.black, colors.black, colors.lightGray)
- loginPage:add("W", function() addToInput("w") end, 7, 7, 15, 15, colors.black, colors.black, colors.lightGray)
- loginPage:add("E", function() addToInput("e") end, 9, 9, 15, 15, colors.black, colors.black, colors.lightGray)
- loginPage:add("R", function() addToInput("r") end, 11, 11, 15, 15, colors.black, colors.black, colors.lightGray)
- loginPage:add("T", function() addToInput("t") end, 13, 13, 15, 15, colors.black, colors.black, colors.lightGray)
- loginPage:add("Y", function() addToInput("y") end, 15, 15, 15, 15, colors.black, colors.black, colors.lightGray)
- loginPage:add("U", function() addToInput("u") end, 17, 17, 15, 15, colors.black, colors.black, colors.lightGray)
- loginPage:add("I", function() addToInput("i") end, 19, 19, 15, 15, colors.black, colors.black, colors.lightGray)
- loginPage:add("O", function() addToInput("o") end, 21, 21, 15, 15, colors.black, colors.black, colors.lightGray)
- loginPage:add("P", function() addToInput("p") end, 23, 23, 15, 15, colors.black, colors.black, colors.lightGray)
- loginPage:add("A", function() addToInput("a") end, 6, 6, 16, 16, colors.black, colors.black, colors.lightGray)
- loginPage:add("S", function() addToInput("s") end, 8, 8, 16, 16, colors.black, colors.black, colors.lightGray)
- loginPage:add("D", function() addToInput("d") end, 10, 10, 16, 16, colors.black, colors.black, colors.lightGray)
- loginPage:add("F", function() addToInput("f") end, 12, 12, 16, 16, colors.black, colors.black, colors.lightGray)
- loginPage:add("G", function() addToInput("g") end, 14, 14, 16, 16, colors.black, colors.black, colors.lightGray)
- loginPage:add("H", function() addToInput("h") end, 16, 16, 16, 16, colors.black, colors.black, colors.lightGray)
- loginPage:add("J", function() addToInput("j") end, 18, 18, 16, 16, colors.black, colors.black, colors.lightGray)
- loginPage:add("K", function() addToInput("k") end, 20, 20, 16, 16, colors.black, colors.black, colors.lightGray)
- loginPage:add("L", function() addToInput("l") end, 22, 22, 16, 16, colors.black, colors.black, colors.lightGray)
- loginPage:add("Z", function() addToInput("z") end, 7, 7, 17, 17, colors.black, colors.black, colors.lightGray)
- loginPage:add("X", function() addToInput("x") end, 9, 9, 17, 17, colors.black, colors.black, colors.lightGray)
- loginPage:add("C", function() addToInput("c") end, 11, 11, 17, 17, colors.black, colors.black, colors.lightGray)
- loginPage:add("V", function() addToInput("v") end, 13, 13, 17, 17, colors.black, colors.black, colors.lightGray)
- loginPage:add("B", function() addToInput("b") end, 15, 15, 17, 17, colors.black, colors.black, colors.lightGray)
- loginPage:add("N", function() addToInput("n") end, 17, 17, 17, 17, colors.black, colors.black, colors.lightGray)
- loginPage:add("M", function() addToInput("m") end, 19, 19, 17, 17, colors.black, colors.black, colors.lightGray)
- loginPage:add("Shift",function() doShift() end, 29, 35, 15, 15, colors.cyan, colors.green, colors.white)
- loginPage:add("Backspace", function() doBackspace() end, 26, 39, 17, 17, colors.black, colors.black, colors.cyan)
- loginPage:add("Space", function() addToInput(" ") end, 29, 35, 16, 16, colors.black, colors.black, colors.cyan)
- function doBackspace()
- input = input:sub(0, #input-1)
- if useUsername then updateUsernameOutput(input) else updatePasswordOutput(input) end
- end
- function doShift()
- loginPage:toggleButton("Shift")
- if (loginPage.buttonList["Shift"].active) then useUppercase = true else useUppercase = false end
- end
- --**************************************************END OF KEYBOARD/PAGE 3**************************************************************************
- --****************************************************START OF ACCOUNT PAGE***********************************************************************
- local mainTOaccount = {
- "View Account",
- " Details",
- label = "mainToaccountLabel",
- }
- function addmainPage()
- --Add these for everyone
- welcomeMainScreenXPos = ((20) - ((8 + currentUser.name:len())/2))
- if math.floor(welcomeMainScreenXPos) <= 0 then welcomeMainScreenXPos = 1 end
- -- print("printing name at x="..welcomeMainScreenXPos)
- mainPage:add("Welcome "..currentUser.name, nil, math.floor(welcomeMainScreenXPos), math.floor((welcomeMainScreenXPos)+(9+currentUser.name:len())), 2, 2, colors.black, colors.black, colors.brown)
- mainPage:add(mainTOaccount, mainToAccountPage, 5,18, 5,6, colors.black, colors.black, colors.cyan)
- --Add these if the access level is high enough
- --[[if (currentUser.access < 3) then
- mainPage:add(mainTOae, mainTOaePage, 7,18, 15,16, colors.black, colors.black, colors.cyan)
- end]]
- end
- function mainToAccountPage() t = accountPage end
- --*************************************************END OF ACCOUNT PAGE*************************************************************************
- --**************************************************START OF ACCOUNT PAGE*****************************************************************
- goBack = {
- "<-",
- label = "goBackLabel",
- }
- local accountChangePasswordTable = {
- "Change your",
- " password ",
- label = "accountChangePasswordLabel"
- }
- local accountChangeAccessPermissionsTable = {
- "Change Access",
- " Permissions ",
- label = "accountChangeAccessPermissionsLabel",
- }
- local accountCreateNewUserTable = {
- " Create a ",
- "New Profile",
- label = "accountCreateNewUserLabel",
- }
- local accountRemoveUserTable = {
- " Remove an ",
- "existing user",
- label = "accountRemoveUserLabel",
- }
- function addAccountPage()
- accountPagePasswordTable = {
- "Password: "..currentUser.password.."",
- label = "accountPagePasswordLabel",
- }
- accountPageAccessTable = {
- "Access Level: "..currentUser.access,
- label = "accountPageAccessLabel",
- }
- accountPage:add(goBack, goBackMain, 2,3, 2,2, colors.black, colors.black, colors.cyan)
- accountPage:add("Account Information", nil, 10, 30, 2, 2, colors.black, colors.black, colors.brown)
- accountPage:add("Name: "..currentUser.name, nil, 2, tonumber(9+currentUser.name:len()), 6, 6, colors.black, colors.black, colors.lightGray)
- accountPage:add(accountPagePasswordTable, nil, 3, 25, 8,8, colors.black, colors.black, colors.lightGray)
- accountPage:add(accountPageAccessTable, nil, 3, 19, 10, 10, colors.black, colors.black, colors.lightGray)
- if currentUser.name ~= "guest" then
- accountPage:add(accountChangePasswordTable, accountToChangePassword, 5, 15, 13, 14, colors.black, colors.black, colors.cyan)
- end
- accountPage:add("Log out", logOut, 27, 35, 8, 8, colors.black, colors.black, colors.cyan)
- if (currentUser.access < 2) then--if highest access level
- accountPage:add(accountChangeAccessPermissionsTable, accountToChangeAccessPermissions, 22, 38, 13, 14, colors.black, colors.black, colors.cyan)
- accountPage:add(accountCreateNewUserTable, accountToCreateNewUser, 5,15, 17,18, colors.black, colors.black, colors.cyan)
- accountPage:add(accountRemoveUserTable, accountToRemoveUser, 22,38, 17,18, colors.black, colors.black, colors.cyan)
- end
- end
- function goBackMain()
- mainPage = nil
- mainPageNotDrawn = true
- mainPage = touchpointEdited.new(monitorSide)
- t = mainPage
- end
- function logOut() os.reboot() end
- function accountToChangePassword() t = changePasswordPage end
- function accountToChangeAccessPermissions() t = changeAccessPage end
- function accountToCreateNewUser()
- if (#profileArray <= 5) then
- t = changeAddUserPage
- end
- end
- function accountToRemoveUser() t = changeRemoveUserPage end
- --*************************************************END OF ACCOUNT PAGE*******************************************************************
- --*************************************************START OF CHANGE PASSWORD PAGE*********************************************************
- function addChangePasswordPage()
- passkey = "firstEntry"
- input = ""
- useUppercase = false
- useNewPassword = true
- useConfirmPassword = false
- newPasswordConfirmed = false
- confirmedPasswordConfirmed = false
- changePasswordPageCurrentPasswordTable = {
- "Your current password is: "..currentUser.password,
- label = "changePasswordPageCurrentPasswordLabel",
- }
- newPasswordInputTable = {
- " ",
- label = "newPasswordInputLabel",
- }
- local changePasswordTitleTable = {
- "Please enter your",
- "desired password:",
- label = "changePasswordTitleLabel",
- }
- changePasswordPage:add(goBack, goBackAccessPage, 2,3, 2,2, colors.black, colors.black, colors.cyan)
- changePasswordPage:add("Change Password", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
- changePasswordPage:add(changePasswordPageCurrentPasswordTable, nil, 2,35, 5,5, colors.black, colors.black, colors.brown)
- changePasswordPage:add(changePasswordTitleTable, nil, 4,39, 8,9, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add(ArrowTable, nil, 1, 4, 10, 10, colors.black, colors.black, colors.brown)
- changePasswordPage:add(newPasswordInputTable, nil, 5, 22, 10, 10, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("Okay", function() confirmNewPassword(passkey) end, 25, 30, 10, 10, colors.black, colors.black, colors.cyan)
- changePasswordPage:add("1", function() addToPasswordInput("1") end, 5, 5, 14, 14, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("2", function() addToPasswordInput("2") end, 7, 7, 14, 14, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("3", function() addToPasswordInput("3") end, 9, 9, 14, 14, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("4", function() addToPasswordInput("4") end, 11, 11, 14, 14, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("5", function() addToPasswordInput("5") end, 13, 13, 14, 14, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("6", function() addToPasswordInput("6") end, 15, 15, 14, 14, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("7", function() addToPasswordInput("7") end, 17, 17, 14, 14, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("8", function() addToPasswordInput("8") end, 19, 19, 14, 14, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("9", function() addToPasswordInput("9") end, 21, 21, 14, 14, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("0", function() addToPasswordInput("0") end, 23, 23, 14, 14, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("Q", function() addToPasswordInput("q") end, 5, 5, 15, 15, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("W", function() addToPasswordInput("w") end, 7, 7, 15, 15, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("E", function() addToPasswordInput("e") end, 9, 9, 15, 15, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("R", function() addToPasswordInput("r") end, 11, 11, 15, 15, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("T", function() addToPasswordInput("t") end, 13, 13, 15, 15, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("Y", function() addToPasswordInput("y") end, 15, 15, 15, 15, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("U", function() addToPasswordInput("u") end, 17, 17, 15, 15, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("I", function() addToPasswordInput("i") end, 19, 19, 15, 15, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("O", function() addToPasswordInput("o") end, 21, 21, 15, 15, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("P", function() addToPasswordInput("p") end, 23, 23, 15, 15, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("A", function() addToPasswordInput("a") end, 6, 6, 16, 16, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("S", function() addToPasswordInput("s") end, 8, 8, 16, 16, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("D", function() addToPasswordInput("d") end, 10, 10, 16, 16, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("F", function() addToPasswordInput("f") end, 12, 12, 16, 16, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("G", function() addToPasswordInput("g") end, 14, 14, 16, 16, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("H", function() addToPasswordInput("h") end, 16, 16, 16, 16, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("J", function() addToPasswordInput("j") end, 18, 18, 16, 16, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("K", function() addToPasswordInput("k") end, 20, 20, 16, 16, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("L", function() addToPasswordInput("l") end, 22, 22, 16, 16, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("Z", function() addToPasswordInput("z") end, 7, 7, 17, 17, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("X", function() addToPasswordInput("x") end, 9, 9, 17, 17, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("C", function() addToPasswordInput("c") end, 11, 11, 17, 17, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("V", function() addToPasswordInput("v") end, 13, 13, 17, 17, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("B", function() addToPasswordInput("b") end, 15, 15, 17, 17, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("N", function() addToPasswordInput("n") end, 17, 17, 17, 17, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("M", function() addToPasswordInput("m") end, 19, 19, 17, 17, colors.black, colors.black, colors.lightGray)
- changePasswordPage:add("Shift",function() doPasswordShift() end, 29, 35, 15, 15, colors.cyan, colors.green, colors.white)
- changePasswordPage:add("Backspace", function() doPasswordBackspace() end, 26, 39, 17, 17, colors.black, colors.black, colors.cyan)
- changePasswordPage:add("Space", function() addToPasswordInput(" ") end, 29, 35, 16, 16, colors.black, colors.black, colors.cyan)
- end
- function goBackAccessPage()
- accountPage = nil
- accountPageNotDrawn = true
- accountPage = touchpointEdited.new(monitorSide)
- t = accountPage
- end
- function confirmNewPassword(Key)
- if (Key == "firstEntry") then
- print("Changing "..currentUser.name.."'s password to: "..input)
- currentUser.password = input
- persistence.store(fileName, profileArray)
- newPasswordTable = {
- "Your current password is: "..currentUser.password,
- label = "changePasswordPageCurrentPasswordLabel",
- }
- changePasswordPage:rename("changePasswordPageCurrentPasswordLabel", newPasswordTable)
- for i = 0, 16 do doPasswordBackspace() end
- elseif (Key == "confrimEntry") then
- print("confirming entry")
- end
- end
- function doPasswordShift()
- changePasswordPage:toggleButton("Shift")
- if (changePasswordPage.buttonList["Shift"].active) then useUppercase = true else useUppercase = false end
- end
- function doPasswordBackspace()
- input = input:sub(0, #input-1)
- updateChangePasswordOutput(input)
- end
- function updateChangePasswordOutput(input)
- input2 = string.rep("*", #input)
- if (#input < 16) then
- input = (input..(string.rep(" ",(16-#input))))
- end
- newInput = {input2, label = "newPasswordInputLabel"}
- changePasswordPage:rename("newPasswordInputLabel", newInput, true)
- end
- function addToPasswordInput(char)
- if useUppercase then char = char:upper() end
- if (#input >= 16) then
- input = input:sub(0,16)
- else
- input = (input..char)
- end
- updateChangePasswordOutput(input)
- end
- --************************************************END OF CHANGE PASSWORD PAGE*************************************************************
- --***********************************************START OF ADD USER PAGE****************************************************************
- function addAddUserPage()
- local addUserTable1 = {
- "1",
- label = "addUserLabel1",
- }
- local addUserTable2 = {
- "2",
- label = "addUserLabel2",
- }
- local addUserTable3 = {
- "3",
- label = "addUserLabel3",
- }
- local addUserInfoTable = {
- "Note: The password will",
- " default to 'password' ",
- label = "addUserInfoLabel",
- }
- local additionalArrowTable = {
- "-->",
- label = "additionalArrowLabel",
- }
- local addUserCreateProfileTable = {
- "Create",
- "Profile",
- label = "addUserCreateProfileLabel",
- }
- newUserInputTable = {
- " ",
- label = "newUserInputLabel",
- }
- useUppercase = false
- input = ""
- tempNewUserAccess = nil
- changeAddUserPage:add("Add New User", nil, 5, 35, 2, 2, colors.black, colors.black, colors.brown)
- changeAddUserPage:add(addUserInfoTable, nil, 9,22, 4,5, colors.black, colors.black, colors.brown)
- changeAddUserPage:add(goBack, goBackAccessPage, 2,3, 2,2, colors.black, colors.black, colors.cyan)
- changeAddUserPage:add("Enter the desired username:", nil, 3, 33, 10, 10, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add(ArrowTable, nil, 1, 4, 11,11, colors.black, colors.black, colors.brown)
- changeAddUserPage:add(newUserInputTable, nil, 5, 22, 11, 11, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add(addUserCreateProfileTable, function() checkValidNewUser() end, 29, 39, 11, 12, colors.black, colors.black, colors.cyan)
- changeAddUserPage:add("Choose the access level:", nil, 1,33, 7, 7, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add(additionalArrowTable, nil, 1,4, 8, 8, colors.black, colors.black, colors.brown)
- changeAddUserPage:add(addUserTable1, function() getNewUserAccessLevel(1) end, 5,5, 8,8, colors.black, colors.black, colors.cyan, colors.green)
- changeAddUserPage:add("(highest)", nil, 6,16, 8,8, colors.black, colors.black, colors.brown)
- changeAddUserPage:add(addUserTable2, function() getNewUserAccessLevel(2) end, 19,19, 8,8, colors.black, colors.black, colors.cyan, colors.green)
- changeAddUserPage:add(addUserTable3, function() getNewUserAccessLevel(3) end, 25,25, 8,8, colors.black, colors.black, colors.cyan, colors.green)
- changeAddUserPage:add("(lowest)", nil, 26,35, 8,8, colors.black, colors.black, colors.brown)
- changeAddUserPage:add("1", function() addToAddUserInput("1") end, 5, 5, 14, 14, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("2", function() addToAddUserInput("2") end, 7, 7, 14, 14, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("3", function() addToAddUserInput("3") end, 9, 9, 14, 14, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("4", function() addToAddUserInput("4") end, 11, 11, 14, 14, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("5", function() addToAddUserInput("5") end, 13, 13, 14, 14, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("6", function() addToAddUserInput("6") end, 15, 15, 14, 14, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("7", function() addToAddUserInput("7") end, 17, 17, 14, 14, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("8", function() addToAddUserInput("8") end, 19, 19, 14, 14, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("9", function() addToAddUserInput("9") end, 21, 21, 14, 14, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("0", function() addToAddUserInput("0") end, 23, 23, 14, 14, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("Q", function() addToAddUserInput("q") end, 5, 5, 15, 15, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("W", function() addToAddUserInput("w") end, 7, 7, 15, 15, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("E", function() addToAddUserInput("e") end, 9, 9, 15, 15, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("R", function() addToAddUserInput("r") end, 11, 11, 15, 15, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("T", function() addToAddUserInput("t") end, 13, 13, 15, 15, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("Y", function() addToAddUserInput("y") end, 15, 15, 15, 15, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("U", function() addToAddUserInput("u") end, 17, 17, 15, 15, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("I", function() addToAddUserInput("i") end, 19, 19, 15, 15, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("O", function() addToAddUserInput("o") end, 21, 21, 15, 15, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("P", function() addToAddUserInput("p") end, 23, 23, 15, 15, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("A", function() addToAddUserInput("a") end, 6, 6, 16, 16, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("S", function() addToAddUserInput("s") end, 8, 8, 16, 16, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("D", function() addToAddUserInput("d") end, 10, 10, 16, 16, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("F", function() addToAddUserInput("f") end, 12, 12, 16, 16, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("G", function() addToAddUserInput("g") end, 14, 14, 16, 16, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("H", function() addToAddUserInput("h") end, 16, 16, 16, 16, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("J", function() addToAddUserInput("j") end, 18, 18, 16, 16, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("K", function() addToAddUserInput("k") end, 20, 20, 16, 16, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("L", function() addToAddUserInput("l") end, 22, 22, 16, 16, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("Z", function() addToAddUserInput("z") end, 7, 7, 17, 17, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("X", function() addToAddUserInput("x") end, 9, 9, 17, 17, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("C", function() addToAddUserInput("c") end, 11, 11, 17, 17, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("V", function() addToAddUserInput("v") end, 13, 13, 17, 17, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("B", function() addToAddUserInput("b") end, 15, 15, 17, 17, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("N", function() addToAddUserInput("n") end, 17, 17, 17, 17, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("M", function() addToAddUserInput("m") end, 19, 19, 17, 17, colors.black, colors.black, colors.lightGray)
- changeAddUserPage:add("Shift",function() doAddUserShift() end, 29, 35, 15, 15, colors.cyan, colors.green, colors.white)
- changeAddUserPage:add("Backspace", function() doAddUserBackspace() end, 26, 39, 17, 17, colors.black, colors.black, colors.cyan)
- changeAddUserPage:add("Space", function() addToAddUserInput(" ") end, 29, 35, 16, 16, colors.black, colors.black, colors.cyan)
- end
- function addToAddUserInput(char)
- if useUppercase then char = char:upper() end
- if (#input >= 16) then
- input = input:sub(0,16)
- else
- input = (input..char)
- end
- updateAddUserOutput(input)
- end
- function getNewUserAccessLevel(num)
- if (num == 1) then
- changeAddUserPage:toggleButton("addUserLabel1")
- if changeAddUserPage.buttonList["addUserLabel1"].active then
- tempNewUserAccess = num
- end
- if changeAddUserPage.buttonList["addUserLabel2"].active then changeAddUserPage:toggleButton("addUserLabel2") end
- if changeAddUserPage.buttonList["addUserLabel3"].active then changeAddUserPage:toggleButton("addUserLabel3") end
- elseif (num == 2) then
- changeAddUserPage:toggleButton("addUserLabel2")
- if changeAddUserPage.buttonList["addUserLabel2"].active then
- tempNewUserAccess = num
- end
- if changeAddUserPage.buttonList["addUserLabel1"].active then changeAddUserPage:toggleButton("addUserLabel1") end
- if changeAddUserPage.buttonList["addUserLabel3"].active then changeAddUserPage:toggleButton("addUserLabel3") end
- elseif (num == 3) then
- changeAddUserPage:toggleButton("addUserLabel3")
- if changeAddUserPage.buttonList["addUserLabel3"].active then
- tempNewUserAccess = num
- end
- if changeAddUserPage.buttonList["addUserLabel2"].active then changeAddUserPage:toggleButton("addUserLabel2") end
- if changeAddUserPage.buttonList["addUserLabel1"].active then changeAddUserPage:toggleButton("addUserLabel1") end
- end
- end
- function doAddUserShift()
- changeAddUserPage:toggleButton("Shift")
- if (changeAddUserPage.buttonList["Shift"].active) then useUppercase = true else useUppercase = false end
- end
- function doAddUserBackspace()
- input = input:sub(0, #input-1)
- updateAddUserOutput(input)
- end
- function updateAddUserOutput(input)
- if (#input < 16) then
- input = (input..(string.rep(" ",(16-#input))))
- end
- newInput = {input, label = "newUserInputLabel"}
- changeAddUserPage:rename("newUserInputLabel", newInput, true)
- end
- function checkValidNewUser()
- if (tempNewUserAccess ~= nil) and (input ~= "") then
- profileArray[#profileArray+1] = (Profile.create(input, "password", tempNewUserAccess))
- persistence.store(fileName, profileArray)
- for i = 0, 16 do doAddUserBackspace() end
- if changeAddUserPage.buttonList["addUserLabel1"].active then changeAddUserPage:toggleButton("addUserLabel1") end
- if changeAddUserPage.buttonList["addUserLabel2"].active then changeAddUserPage:toggleButton("addUserLabel2") end
- if changeAddUserPage.buttonList["addUserLabel3"].active then changeAddUserPage:toggleButton("addUserLabel3") end
- goBackAccessPage()
- useUppercase = false
- input = ""
- tempNewUserAccess = nil
- end
- end
- --***********************************************END OF ADD USER PAGE********************************************************************
- --***********************************************START OF REMOVE USER PAGE****************************************************************
- function addRemoveUserPage()
- local RemoveUsertitleTable = {
- "Name: Access Level:",
- label = "RemoveUsertitleLabel",
- }
- changeRemoveUserPage:add(goBack, goBackAccessPage3, 2,3, 2,2, colors.black, colors.black, colors.cyan)
- changeRemoveUserPage:add("Remove Users", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
- changeRemoveUserPage:add(RemoveUsertitleTable, nil, 8,30, 5,5, colors.black, colors.black, colors.brown)
- yposAccess = 7
- tableYPOSspot = 1
- for key, value in ipairs(profileArray) do
- local accessValueTable = {
- value.access,
- label = tostring(yposAccess),
- }
- local removeTable = {
- "Remove",
- label = tostring(yposAccess).."remove",
- }
- changeRemoveUserPage:add(value.name, nil, 3,19, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
- changeRemoveUserPage:add(accessValueTable, nil, 25,26, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
- -- changeRemoveUserPage:add(removeTable, function() removeUsers(key) end, 30,30, yposAccess,yposAccess, colors.black, colors.black, colors.red)
- changeRemoveUserPage:add(removeTable, function() removeUsers(key) end, 30,35, yposAccess,yposAccess, colors.black, colors.black, colors.red)
- yposAccess = yposAccess + 2
- end
- end
- function goBackAccessPage3()
- changeRemoveUserPage = nil
- changeRemoveUserPageNotDrawn = true
- changeRemoveUserPage = touchpointEdited.new(monitorSide)
- accountPage = nil
- accountPageNotDrawn = true
- accountPage = touchpointEdited.new(monitorSide)
- t = accountPage
- end
- function testPrint()
- print("Testing debug")
- end
- function removeUsers(aPos)
- print("Removing "..profileArray[aPos].name)
- -- profileArray[aPos] = nil
- table.remove(profileArray, aPos)
- persistence.store(fileName, profileArray)
- changeRemoveUserPage = nil
- changeRemoveUserPageNotDrawn = true
- changeRemoveUserPage = touchpointEdited.new(monitorSide)
- t = changeRemoveUserPage
- end
- --***********************************************END OF REMOVE USER PAGE********************************************************************
- --***********************************************START OF CHANGE ACCESS PERMISSIONS*******************************************************
- function addAccessPermissionsPage()
- local AccesstitleTable = {
- "Name: Access Level:",
- label = "AccesstitleLabel",
- }
- changeAccessPage:add(goBack, goBackAccessPage2, 2,3, 2,2, colors.black, colors.black, colors.cyan)
- changeAccessPage:add("Access Permissions", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
- changeAccessPage:add(AccesstitleTable, nil, 8,30, 5,5, colors.black, colors.black, colors.brown)
- yposAccess = 7
- tableYPOSspot = 1
- for key, value in ipairs(profileArray) do
- local accessValueTable = {
- value.access,
- label = tostring(yposAccess),
- }
- local minusTable = {
- "-",
- label = tostring(yposAccess).."-",
- }
- local plusTable = {
- "+",
- label = tostring(yposAccess).."+",
- }
- changeAccessPage:add(value.name, nil, 3,19, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
- changeAccessPage:add(accessValueTable, nil, 25,26, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
- if value.access > 1 then changeAccessPage:add(minusTable, function() accessChange("minus", key) end, 30,30, yposAccess,yposAccess, colors.black, colors.black, colors.cyan) end
- if value.access < 3 then changeAccessPage:add(plusTable, function() accessChange("plus", key) end, 32,32, yposAccess,yposAccess, colors.black, colors.black, colors.cyan) end
- yposAccess = yposAccess + 2
- end
- end
- function goBackAccessPage2()
- changeAccessPage = nil
- changeAccessPageNotDrawn = true
- changeAccessPage = touchpointEdited.new(monitorSide)
- accountPage = nil
- accountPageNotDrawn = true
- accountPage = touchpointEdited.new(monitorSide)
- t = accountPage
- end
- function accessChange(str, aPos)
- if str == "plus" then
- profileArray[aPos].access = profileArray[aPos].access + 1
- elseif str == "minus" then
- profileArray[aPos].access = profileArray[aPos].access - 1
- end
- persistence.store(fileName, profileArray)
- changeAccessPage = nil
- changeAccessPageNotDrawn = true
- changeAccessPage = touchpointEdited.new(monitorSide)
- t = changeAccessPage
- end
- --***********************************************END OF CHANGE ACCESS PERMISSIONS*********************************************************
- ---**********************************************************MAIN***************************************************************************
- function checkPages()
- if (currentUser ~= nil) then
- if (t == mainPage) and (mainPageNotDrawn) then
- print("initializing main page for "..currentUser.name)
- addmainPage()
- mainPageNotDrawn = false
- elseif (t == accountPage) and (accountPageNotDrawn) then
- print("initializing account page for "..currentUser.name)
- addAccountPage()
- accountPageNotDrawn = false
- elseif(t == accountPage) and (not accountPageNotDrawn) then
- local AnewPasswordTable = {
- "Password: "..currentUser.password,
- label = "accountPagePasswordLabel"
- }
- accountPage:rename("accountPagePasswordLabel", AnewPasswordTable)
- local newAccessTable = {
- "Access Level: "..currentUser.access,
- label = "accountPageAccessLabel",
- }
- accountPage:rename("accountPageAccessLabel", newAccessTable)
- elseif (t == changePasswordPage) and (changePasswordPageNotDrawn) then
- print("initializing changePasswordPage for "..currentUser.name)
- addChangePasswordPage()
- changePasswordPageNotDrawn = false
- elseif (t == changePasswordPage) and (not changePasswordPageNotDrawn) then
- local newPasswordTable = {
- "Your current password is: "..currentUser.password,
- label = "changePasswordPageCurrentPasswordLabel",
- }
- changePasswordPage:rename("changePasswordPageCurrentPasswordLabel", newPasswordTable)
- elseif (t==changeAccessPage) and (changeAccessPageNotDrawn) then
- print("initializing changeAccessPage for "..currentUser.name)
- addAccessPermissionsPage()
- changeAccessPageNotDrawn = false
- elseif (t==changeAddUserPage) and (changeAddUserPageNotDrawn) then
- print("initializing AddUserPage for "..currentUser.name)
- addAddUserPage()
- changeAddUserPageNotDrawn = false
- elseif (t==changeRemoveUserPage) and (changeRemoveUserPageNotDrawn) then
- print("initializing RemoveUserPage for "..currentUser.name)
- addRemoveUserPage()
- changeRemoveUserPageNotDrawn = false
- end
- end
- end
- function callButton(name)
- if t.buttonList[name].func ~= nil then
- t.buttonList[name].func()
- end
- end
- mainPageNotDrawn = true
- accountPageNotDrawn = true
- changePasswordPageNotDrawn = true
- changeAccessPageNotDrawn = true
- changeAddUserPageNotDrawn = true
- changeRemoveUserPageNotDrawn = true
- mystcraftPageNotDrawn = true
- aePageNotDrawn = true
- powerPageNotDrawn = true
- -- t = mainPage
- -- currentUser = profileArray[4]
- t = loginPage
- -- for i=1,#profileArray do
- -- print(profileArray[i].name) --array(profile)
- -- end
- -- for key,value in ipairs(profileArray) do
- -- print(key) --number
- -- print(value.name) --array(profile)
- -- end
- while true do
- checkPages()
- t:draw()
- local event = {t:handleEvents(os.pullEvent())}
- if event[1] == "button_click" then
- callButton(event[2])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement