Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- SECONDARY
- step = 1
- keyc_allowed = true
- keyb_allowed = true
- keyn_allowed = true
- function centerText(text)
- local x,y = term.getSize()
- local x2,y2 = term.getCursorPos()
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
- write(text)
- end
- function writeMainScreen(clr, tittle, p1, p2a, p2b, drawNav)
- term.clear()
- paintutils.drawFilledBox(1, 1, 51, 3, clr)
- term.setCursorPos(2, 2)
- term.setTextColor(colors.white)
- write(tittle)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.gray)
- paintutils.drawFilledBox(1, 4, 51, 19, colors.white)
- term.setCursorPos(3, 6)
- write(p1)
- term.setCursorPos(3, 8)
- write(p2a)
- term.setCursorPos(3, 9)
- write(p2b)
- term.setCursorPos(1, 18)
- term.setTextColor(colors.lightGray)
- if drawNav == "full" then
- centerText("[C] - Cancel [B] - Back [N] - Next")
- keyc_allowed = true
- keyb_allowed = true
- keyn_allowed = true
- end
- if drawNav == "install" then
- centerText("[C] - Cancel [B] - Back [N] - Install")
- keyc_allowed = true
- keyb_allowed = true
- keyn_allowed = true
- end
- if drawNav == "cn" then
- centerText("[C] - Cancel [N] - Next")
- keyc_allowed = true
- keyb_allowed = false
- keyn_allowed = true
- end
- if drawNav == "no" then
- keyc_allowed = false
- keyb_allowed = false
- keyn_allowed = false
- end
- end
- function writeSettingsScreen(clr, tittle, p1, drawNav)
- term.clear()
- paintutils.drawFilledBox(1, 1, 51, 3, clr)
- term.setCursorPos(2, 2)
- term.setTextColor(colors.white)
- write(tittle)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.gray)
- paintutils.drawFilledBox(1, 4, 51, 19, colors.white)
- term.setCursorPos(3, 6)
- write(p1)
- sleep(0.05)
- term.setTextColor(colors.lightGray)
- term.setCursorPos(8, 8)
- write("Password: ")
- term.setCursorPos(3, 10)
- write("Redstone side: ")
- term.setCursorPos(5, 12)
- write("Opened time: ")
- term.setTextColor(colors.gray)
- term.setCursorPos(8, 8)
- write("Password: ")
- term.setTextColor(colors.black)
- password = read("*")
- term.setCursorPos(3, 10)
- term.setTextColor(colors.gray)
- write("Redstone side: ")
- term.setTextColor(colors.black)
- redside = read()
- term.setCursorPos(5, 12)
- term.setTextColor(colors.gray)
- write("Opened time: ")
- term.setTextColor(colors.black)
- opentime = read()
- term.setCursorPos(1, 18)
- term.setTextColor(colors.lightGray)
- if drawNav == "full" then
- centerText("[C] - Cancel [B] - Back [N] - Next")
- keyc_allowed = true
- keyb_allowed = true
- keyn_allowed = true
- end
- if drawNav == "cn" then
- centerText("[C] - Cancel [N] - Next")
- keyc_allowed = true
- keyb_allowed = false
- keyn_allowed = true
- end
- if drawNav == "no" then
- keyc_allowed = false
- keyb_allowed = false
- keyn_allowed = false
- end
- end
- function writeErrorScreen(clr, tittle, p1a, p1b, drawNav)
- is_error = true
- term.clear()
- paintutils.drawFilledBox(1, 1, 51, 3, clr)
- term.setCursorPos(2, 2)
- term.setTextColor(colors.white)
- write(tittle)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.gray)
- paintutils.drawFilledBox(1, 4, 51, 19, colors.white)
- term.setCursorPos(3, 6)
- write(p1a)
- term.setCursorPos(3, 7)
- write(p1b)
- term.setCursorPos(1, 18)
- term.setTextColor(colors.lightGray)
- if drawNav == "full" then
- centerText("[C] - Cancel [B] - Correct")
- keyc_allowed = true
- keyb_allowed = true
- keyn_allowed = false
- end
- if drawNav == "no" then
- keyc_allowed = false
- keyb_allowed = false
- keyn_allowed = false
- end
- end
- function writeInstallScreen(clr, tittle, p1, drawNav)
- term.clear()
- paintutils.drawFilledBox(1, 1, 51, 3, clr)
- term.setCursorPos(2, 2)
- term.setTextColor(colors.white)
- write(tittle)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.gray)
- paintutils.drawFilledBox(1, 4, 51, 19, colors.white)
- term.setCursorPos(3, 6)
- write(p1)
- term.setCursorPos(1, 18)
- term.setTextColor(colors.lightGray)
- if drawNav == "full" then
- centerText("[C] - Cancel")
- keyc_allowed = true
- keyb_allowed = false
- keyn_allowed = false
- end
- if drawNav == "no" then
- keyc_allowed = false
- keyb_allowed = false
- keyn_allowed = false
- end
- term.setCursorPos(3, 8)
- term.setTextColor(colors.gray)
- write("Downloading Codedoor...")
- term.setTextColor(colors.white)
- shell.run("pastebin", "get", "QXkP84KA", "startup.lua")
- sleep(3)
- term.setCursorPos(3, 8)
- term.setTextColor(colors.gray)
- write("Configuring Codedoor...")
- setts = fs.open("/cdsettings.cfg", "w")
- setts.writeLine(password)
- setts.writeLine(redside)
- setts.writeLine(opentime)
- setts.close()
- sleep(2)
- step = step + 1
- end
- function writeFinishScreen(clr, tittle, p1a, p1b, p2a, p2b, drawNav)
- finished = true
- term.clear()
- paintutils.drawFilledBox(1, 1, 51, 3, clr)
- term.setCursorPos(2, 2)
- term.setTextColor(colors.white)
- write(tittle)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.gray)
- paintutils.drawFilledBox(1, 4, 51, 19, colors.white)
- term.setCursorPos(3, 6)
- write(p1a)
- term.setCursorPos(3, 7)
- write(p1b)
- term.setCursorPos(3, 9)
- write(p2a)
- term.setCursorPos(3, 10)
- write(p2b)
- term.setCursorPos(1, 18)
- term.setTextColor(colors.lightGray)
- if drawNav == "full" then
- centerText("[N] - Reboot")
- keyc_allowed = false
- keyb_allowed = false
- keyn_allowed = true
- end
- if drawNav == "no" then
- keyc_allowed = false
- keyb_allowed = false
- keyn_allowed = false
- end
- end
- -- MAIN PROGRAMM
- while true do
- if step < 1 then
- step = 1
- end
- if step > 5 then
- step = 5
- end
- if is_error ~= true then
- if step == 1 then
- writeMainScreen(colors.blue, "Codedoor Installation Wizard", "Welcome to Codedoor Installation Wizard!", "This program will install Codedoor on your", "computer.", "cn")
- end
- if step == 2 then
- writeSettingsScreen(colors.blue, "Codedoor Installation Wizard", "Let's configure your Codedoor!", "full")
- end
- if step == 3 then
- writeMainScreen(colors.blue, "Codedoor Installation Wizard", "Everything is ready for installation!", "Press [N] when you are ready to install", "Codedoor on your computer.", "install")
- end
- if step == 4 then
- writeInstallScreen(colors.cyan, "Codedoor Installation Wizard", "Installing Codedoor on your computer...", "no")
- end
- if step == 5 then
- writeFinishScreen(colors.green, "Codedoor Installation Wizard", "Codedoor successfully installed on your", "computer.", "Press [N] to reboot your computer and start", "using app.", "full")
- end
- end
- while true do
- local event, key = os.pullEvent( "key" )
- if (key == keys.c) and (keyc_allowed == true) then
- writeMainScreen(colors.red, "Codedoor Installation Wizard", "Installation canceled.", "Rebooting system...", "", "no")
- sleep(2)
- os.reboot()
- end
- if (key == keys.b) and (keyb_allowed == true) then
- if is_error ~= true then
- step = step - 1
- else
- is_error = false
- end
- break
- end
- if (key == keys.n) and (keyn_allowed == true) then
- if finished ~= true then
- if step ~= 2 then
- step = step + 1
- else
- if password ~= "" then
- if (redside == "left") or (redside == "right") or (redside == "back") or (redside == "front") or (redside == "top") or (redside == "bottom") then
- if type(tonumber(opentime)) == "number" then
- step = step + 1
- else
- writeErrorScreen(colors.orange, "Codedoor Installation Wizard", "Error: Opened time isn't number.", "", "full")
- end
- else
- writeErrorScreen(colors.orange, "Codedoor Installation Wizard", "Error: Side specified incorrectly.", "(Can: left, right, back, front, top, bottom)", "full")
- end
- else
- writeErrorScreen(colors.orange, "Codedoor Installation Wizard", "Error: Password not set.", "", "full")
- end
- end
- else
- os.reboot()
- end
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment