Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- pastebin get YugF1mqx startup
- local pullEvent = os.pullEvent
- os.pullEvent = os.pullEventRaw
- local skip = false
- term.setTextColor(colors.lightBlue)
- term.setBackgroundColor(colors.black)
- term.clear()
- local beep = function()
- rs.setOutput("bottom",true)
- sleep(0)
- rs.setOutput("bottom",false)
- end
- local funcread = function(repchar,rHistory,doFunc,noNewLine)
- local scr_x,scr_y = term.getSize()
- local sx,sy = term.getCursorPos()
- local cursor = 1
- local rCursor = #rHistory+1
- local output = ""
- term.setCursorBlink(true)
- while true do
- local evt,key = os.pullEvent()
- local cx,cy = term.getCursorPos()
- if evt == "key" then
- if key == keys.enter then
- if not noNewLine then
- write("\n")
- end
- term.setCursorBlink(false)
- return output
- elseif key == keys.left then
- if cursor-1 >= 1 then
- cursor = cursor - 1
- end
- elseif key == keys.right then
- if cursor <= #output then
- cursor = cursor + 1
- end
- elseif key == keys.up then
- if rCursor > 1 then
- rCursor = rCursor - 1
- term.setCursorPos(sx,sy)
- term.write((" "):rep(#output))
- output = rHistory[rCursor] or ""
- cursor = #output+1
- pleaseDoFunc = true
- end
- elseif key == keys.down then
- term.setCursorPos(sx,sy)
- term.write((" "):rep(#output))
- if rCursor < #rHistory then
- rCursor = rCursor + 1
- output = rHistory[rCursor] or ""
- cursor = #output+1
- pleaseDoFunc = true
- else
- rCursor = #rHistory+1
- output = ""
- cursor = 1
- end
- elseif key == keys.backspace then
- if cursor > 1 and #output > 0 then
- output = output:sub(1,cursor-2)..output:sub(cursor)
- cursor = cursor - 1
- pleaseDoFunc = true
- end
- elseif key == keys.delete then
- if #output:sub(cursor,cursor) == 1 then
- output = output:sub(1,cursor-1)..output:sub(cursor+1)
- pleaseDoFunc = true
- end
- end
- elseif evt == "char" or evt == "paste" then
- output = output:sub(1,cursor-1)..key..output:sub(cursor+(#key-1))
- cursor = cursor + #key
- pleaseDoFunc = true
- end
- if pleaseDoFunc then
- pleaseDoFunc = false
- if type(doFunc) == "function" then
- doFunc(output)
- end
- term.setCursorPos(sx,sy)
- local pOut = output
- if #output >= scr_x-(sx-2) then
- pOut = output:sub((#output+(sx))-scr_x)
- end
- if repchar then
- term.write(repchar:sub(1,1):rep(#pOut).." ")
- else
- term.write(pOut.." ")
- end
- local cx,cy = term.getCursorPos()
- end
- term.setCursorPos(sx+cursor-1,cy)
- end
- end
- local loginPrompt = function()
- local tries = 0
- while true do
- write(" login: ")
- local name = funcread(nil,{},beep)
- beep()
- if name ~= "Dr.CAIN" then
- tries = tries + 1
- print("No such user registered\n")
- else
- write(" code : ")
- local code = funcread("*",{},beep)
- beep()
- if code ~= "wanker" then
- sleep(2)
- tries = tries + 1
- print("Pass code rejected\n")
- else
- sleep(1)
- return true
- end
- end
- if tries >= 5 then
- print("System locked")
- while true do
- beep()
- sleep(0)
- end
- end
- end
- end
- local slowWrite = function(txt,delay,doBeep)
- if delay == 0 then
- return write(txt)
- else
- for a = 1, #txt do
- write(txt:sub(a,a))
- if doBeep then
- beep()
- end
- sleep(delay)
- end
- end
- end
- local function explode(div,str)
- if (div=='') then return false end
- local pos,arr = 0,{}
- for st,sp in function() return string.find(str,div,pos,true) end do
- table.insert(arr,string.sub(str,pos,st-1))
- pos = sp + 1
- end
- table.insert(arr,string.sub(str,pos))
- return arr
- end
- if not skip then
- local script = [[
- NOM ENGINEERING WORK SYSTEM
- Model CPS-9204
- Copywright (c) 2105, 2109, 2114
- NOM Corporation
- All Rights Reserved]]
- local script = explode("\n",script)
- for a = 1, #script do
- sleep(0.4)
- term.setCursorPos(2,a)
- slowWrite(script[a],0,true)
- end
- sleep(0.3)
- for a = 1024, 8192, 1024 do
- term.setCursorPos(2,#script+2)
- term.write("real mem = "..a)
- term.setCursorPos(19,#script+2)
- term.write("TB")
- sleep(0.5)
- end
- sleep(0.5)
- for a = 4096, 32768, 4096 do
- term.setCursorPos(2,#script+3)
- term.write("avail mem = "..a)
- term.setCursorPos(20,#script+3)
- term.write("TB")
- sleep(0.5)
- end
- term.setCursorPos(1,#script+5)
- print(" primary data cache : 512KB")
- sleep(0.3)
- print(" primary inst.cache : 768KB")
- sleep(0.3)
- print(" secondary cache : 32768KB")
- sleep(0.4)
- loginPrompt()
- end
- read = function(repchar,tHistory)
- return funcread(repchar,tHistory,beep)
- end
- _G.read = read
- os.pullEvent = pullEvent
Add Comment
Please, Sign In to add comment