Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tFiles = {}
- local tDirs = {}
- local cSelected = 1
- local oLevel = 0
- local currentDir = ""
- local inDir = true
- local w, h = term.getSize()
- local x, y = term.getSize()
- local correctPass = "larp"
- blit = function( txt, txtcol, backcol)
- term.setBackgroundColor(backcol)
- term.setTextColor(txtcol)
- term.write(txt)
- end
- --[[COROUTINE BASED INTRO SEQUENCE]]--
- local slowWrite
- local coDone = false
- function resetWrite()
- slowWrite = coroutine.create(function (str, speed, delay)
- for i = 1, #str do
- local index = 1
- if not coDone then
- write(str:sub(i, i))
- coroutine.yield(1/speed)
- end
- end
- return true, delay
- end)
- end
- function blink(speed)
- if not speed then
- speed = .4
- end
- local a,b = term.getCursorPos()
- uWords(" ", a, b, _, colors.lime)
- coroutine.yield(speed)
- uWords(" ", a, b, _, colors.black)
- coroutine.yield(speed)
- term.setCursorPos(a,b)
- end
- local messages = {
- {"WELCOME TO ROBCO INDUSTRIES (TM) TERMLINK", 1, 1, 160, .05},
- {">", 1, 2, 160, 1},
- {"SET TERMINAL/INQUIRE", 2, 2, 30, .75},
- {"RIT-V300", 1, 4, 30, .05},
- {">", 1, 6, 160, 1},
- {"SET FILE/PROTECTION-OWNER:RWED ACCOUNTS.F", 2, 6, 30, .05},
- {">", 1, 7, 160, 1},
- {"SET HALT RESTART/MAINT", 2, 7, 30, .5},
- {"Initializing Robco Industries(TM) MF Boot Agent", 1, 9, 160, .1},
- {"RETROS BIOS", 1, 10, 160, .1},
- {"RBIOS-4.02.08.00 52EE5.E7.E8", 1, 11, 160, .1},
- {"Copyright 2201-2201 Robco Ind.", 1, 12, 160, .1},
- {"Uppermem: 64 KB", 1, 13, 160, .1},
- {"Root (5AB)", 1, 14, 160, .1},
- {"Maintenance Mode", 1, 15, 160, .05},
- {">", 1, 17, 160, 1},
- {"RUN DEBUG/ACCOUNTS.F", 2, 17, 30, 1}
- }
- local cMsg = 1
- local writeTimer, blinkTimer
- function txt()
- term.setCursorBlink(true)
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.lime)
- term.clear()
- term.setCursorPos(1, 1)
- resetWrite()
- _, length = coroutine.resume(slowWrite, messages[cMsg][1], messages[cMsg][4], messages[cMsg][5])
- writeTimer = os.startTimer(length)
- while true do
- local events = {os.pullEvent()}
- if events[1] == "timer" then
- if events[2] == writeTimer then
- _, length, delay = coroutine.resume(slowWrite, messages[cMsg][1], messages[cMsg][4], messages[cMsg][5])
- if delay then
- term.setCursorBlink(true)
- writeTimer = os.startTimer(delay)
- cMsg = cMsg + 1
- if cMsg > #messages then
- sleep(delay)
- break
- end
- resetWrite()
- term.setCursorPos(messages[cMsg][2], messages[cMsg][3])
- else
- term.setCursorBlink(false)
- writeTimer = os.startTimer(length)
- end
- end
- elseif events[1] == "key" or events[1] == "mouse_click" then
- os.cancelTimer(writeTimer)
- coDone = true
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- break
- end
- end
- term.setCursorBlink(false)
- end
- --[[PASSWORD COLLECTION]]--
- function password()
- shell.run("clear")
- textutils.slowPrint("ROBCO INDUSTRIES (TM) TERMLINK PROTOCOL",i)
- textutils.slowPrint("ENTER PASSWORD NOW",i)
- local c,d = term.getCursorPos()
- textutils.slowWrite("4 ATTEMPT(S) LEFT: ")
- boxes("slow",4)
- for i=1,5 do
- for i=1,3 do
- term.setCursorPos(c,d+2+i)
- term.clearLine()
- end
- term.setCursorPos(c,d+2)
- term.clearLine()
- term.write("> ")
- term.setCursorBlink(false)
- local pass = read("*")
- if pass:lower() ~= correctPass and i == 5 then
- textutils.slowWrite(">Entry Denied",80)
- blinkN(1)
- textutils.slowWrite(">Lockout in progress")
- blinkN(1)
- scroll()
- while true do
- term.setCursorPos((x/2)-(7),(y/2)-1)
- term.write("TERMINAL LOCKED")
- term.setCursorPos((x/2)-(15),(y/2)+1)
- term.write("PLEASE CONTACT AN ADMINISTRATOR")
- sleep(1)
- end
- elseif pass:lower() ~= correctPass then
- textutils.slowWrite(">Entry Denied",80)
- blinkN(1)
- local mem = NumCorrect(pass)
- textutils.slowWrite(">"..mem.." correct",80)
- blinkN(1)
- else
- textutils.slowWrite(">Exact Match!",80)
- blinkN(1)
- textutils.slowPrint(">Please Wait",80)
- textutils.slowPrint(">while system",80)
- textutils.slowPrint(">is accessed",80)
- blinkN(1)
- scroll()
- break
- end
- term.setCursorPos(c,d)
- term.clearLine()
- term.write(tostring(4-i).." ATTEMPT(S) LEFT: ")
- boxes(nil,4-i)
- end
- end
- function scroll()
- local g,h = term.getCursorPos()
- for i=1,h+1 do
- term.scroll(1)
- sleep(.1)
- end
- end
- function NumCorrect(pass)
- local count = 0
- for i=1,#correctPass do
- if pass:sub(i,i) == correctPass:sub(i,i) then
- count = count + 1
- end
- end
- return tostring(count).."/"..tostring(#correctPass)
- end
- function boxes(a,f)
- if a == "slow" then
- for i=1,f do
- term.setBackgroundColor(colors.lime)
- textutils.slowWrite(" ")
- term.setBackgroundColor(colors.black)
- textutils.slowWrite(" ")
- end
- print(nil)
- elseif a == nil then
- for i=1,f do
- term.setBackgroundColor(colors.lime)
- term.write(" ")
- term.setBackgroundColor(colors.black)
- term.write(" ")
- end
- end
- end
- function blinkN(p,s)
- if not s then
- s = .4
- end
- local a,b = term.getCursorPos()
- for i = 1,p do
- sleep(s)
- term.setCursorPos(a,b)
- blit(" ",colors.lime,colors.lime)
- sleep(s)
- term.setCursorPos(a,b)
- blit(" ",colors.lime,colors.black)
- end
- term.setCursorPos(1,b+1)
- end
- --local blink = coroutine.create(blink)
- txt()
- password()
- --[[FILE EXPLORER]]--
- function uWords(string, x, y, txtcol, bakcol)
- string = string or ""
- txtcol = txtcol or colors.white
- bakcol = bakcol or colors.black
- if not tonumber(x) then
- x = x:gsub(" ", "")
- if x:sub(1, 1) == "l" then
- if x:find("+") then
- offset = tonumber(x:sub(x:find("+") + 1))
- term.setCursorPos(1 + offset, y)
- else
- term.setCursorPos(1, y)
- end
- elseif x:sub(1, 1) == "c" then
- if x:find("+") then
- offset = tonumber(x:sub(x:find("+") + 1))
- term.setCursorPos(w/2 - #string/2 + 1 + offset, y)
- elseif x:find("-") then
- offset = tonumber(x:sub(x:find("-") + 1))
- term.setCursorPos(w/2 - #string/2 + 1 - offset, y)
- else
- term.setCursorPos(w/2 - #string/2 + 1, y)
- end
- elseif x:sub(1, 1) == "r" then
- if x:find("-") then
- offset = tonumber(x:sub(x:find("-") + 1))
- term.setCursorPos(w - #string + 1 - offset, y)
- else
- term.setCursorPos(w - #string + 1, y)
- end
- end
- else
- term.setCursorPos(x, y)
- end
- term.setBackgroundColor(bakcol)
- term.setTextColor(txtcol)
- term.write(string)
- end
- local function draw(string, xPos, yPos, txtcol, bakcol)
- local string = string or ""
- local txtcol = txtcol or colors.white
- local bakcol = bakcol or colors.black
- term.setCursorPos(xPos, yPos)
- term.setBackgroundColor(bakcol)
- term.setTextColor(txtcol)
- term.write(string)
- end
- function clearTable(t)
- for i = 1, #t do
- t[i] = nil
- end
- end
- function updateFiles(f)
- clearTable(f)
- for _, file in ipairs(fs.list(currentDir)) do
- f[#f + 1] = {}
- f[#f].name = file
- if fs.isDir(fs.combine(currentDir, file)) then
- f[#f].type = "directory"
- else
- f[#f].type = "file"
- end
- end
- --table.sort(f)
- end
- local tFiles = {}
- function displayScreen(level, update)
- term.setBackgroundColor(colors.black)
- term.clear()
- uWords("ROBCO INDUSTRIES UNIFIED OPERATING SYSTEM", "c", 1, colors.lime)
- uWords("COPYRIGHT 2075-2077 ROBCO INDUSTRIES", "c", 2, colors.lime)
- uWords("-Server " .. os.getComputerID() .. "-", "c", 3, colors.lime)
- uWords(os.getComputerLabel() and os.getComputerLabel() .. currentDir or currentDir, 1, 4, colors.lime)
- uWords("----------", 1, 5, colors.lime)
- uWords(" ", "r", h-1, colors.lime, colors.red)
- uWords(" ", "r", h, colors.lime, colors.red)
- term.setBackgroundColor(colors.black)
- if update then
- updateFiles(tFiles)
- inDir = false
- end
- for i = 1, #tFiles - level do
- local pre = tFiles[i + level].type == "file" and ">" or "+>"
- if i + level == cSelected then
- uWords(pre .. tFiles[i + level].name, 1, i + 5, colors.black, colors.lime)
- else
- uWords(pre .. tFiles[i + level].name, 1, i + 5, colors.lime)
- end
- if i == h - 7 then
- break
- end
- end
- if currentDir == "" then
- if cSelected == #tFiles + 1 then
- uWords("=>" .. "new", 1, h, colors.black, colors.lime)
- else
- uWords("=>" .. "new", 1, h, colors.lime)
- end
- else
- if cSelected == #tFiles + 1 then
- uWords("/>" .. "back", 1, h, colors.black, colors.lime)
- else
- uWords("/>" .. "back", 1, h, colors.lime)
- end
- end
- end
- function loadFileOptions(file, ...)
- clearTable(tFiles)
- for i = 1, select("#", ...) do
- tFiles[i] = {}
- tFiles[i].name = select(i, ...)
- tFiles[i].type = select(i, ...)
- end
- currentDir = currentDir .. "/" .. file
- end
- function activateFile(f)
- oLevel = 0
- cSelected = 1
- if f.type == "directory" then
- currentDir = currentDir .. "/" .. f.name
- oLevel = 0
- cSelected = 1
- inDir = true
- elseif f.type == "file" then
- loadFileOptions(f.name, "Edit", "Run", "Delete")
- inDir = false
- elseif f.type == "Edit" then
- shell.run("edit " .. currentDir)
- elseif f.type == "Run" then
- term.clear()
- uWords("Input args:", 1, 1, colors.lime)
- term.setCursorPos(1, 2)
- local args = read()
- shell.run(currentDir .. " " .. args)
- os.pullEvent()
- elseif f.type == "Delete" then
- shell.run("delete " .. currentDir)
- currentDir = currentDir:gsub("/[%w%.]+$", "")
- inDir = true
- end
- end
- function eventHandler(e)
- if e[1] == "key" then
- if e[2] == keys.enter then
- if cSelected > #tFiles then
- if currentDir == "" then
- term.setBackgroundColor(colors.black)
- term.clear()
- uWords("Input Program Name:", 1, 1, colors.lime)
- term.setCursorPos(1, 2)
- local program = read()
- shell.run("edit " .. program)
- oLevel = 0
- cSelected = 1
- inDir = true
- else
- currentDir = currentDir:gsub("/[%w%.]+$", "")
- inDir = true
- oLevel = 0
- cSelected = 1
- end
- else
- activateFile(tFiles[cSelected])
- end
- elseif e[2] == keys.down then
- if cSelected - oLevel == h - 7 and cSelected < #tFiles then
- oLevel = oLevel + 1
- end
- cSelected = cSelected <= #tFiles and cSelected + 1 or #tFiles + 1
- elseif e[2] == keys.up then
- if cSelected - oLevel == h - 18 and cSelected > 1 then
- oLevel = oLevel - 1
- end
- cSelected = cSelected > 1 and cSelected - 1 or 1
- end
- elseif e[1] == "mouse_click" then
- if e[2] == 1 and e[3] > w - 2 and e[4] > h - 2 then
- os.shutdown()
- end
- end
- end
- while true do
- displayScreen(oLevel, inDir)
- local events = {os.pullEventRaw()}
- eventHandler(events)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement