Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Configuration
- -- Strings
- local sBypasspw = "lastmyth"
- local sDoorpw = "derp"
- local sRedstoneSideClose = "back"
- local sRedstoneSideOpen = "bottom"
- local sName = "The Sorting Facility"
- local wp = "print"
- -- Do not edit from here
- -- [[ Menu, clear print, and welcome functions ]] --
- local function menu(...)
- local sel = 1
- local list = {...}
- local offX,offY = term.getCursorPos()
- local curX,curY = term.getCursorPos()
- while true do
- if sel > #list then sel = 1 end
- if sel < 1 then sel = #list end
- for i = 1,#list do
- term.setCursorPos(offX,offY+i-1)
- if sel == i then
- print("["..list[i].."]") -- very customisible example print(">"..list[i])
- else
- print(" "..list[i].." ") -- very customisible
- end
- end
- while true do
- local e,e1,e2,e3,e4,e5 = os.pullEvent()
- if e == "key" then
- if e1 == 200 then -- up key
- sel = sel-1
- break
- end
- if e1 == 208 then -- down key
- sel = sel+1
- break
- end
- if e1 == 28 then
- term.setCursorPos(curX,curY)
- return list[sel],sel
- end
- end
- end
- end
- end
- function clearPrint(string, x, y)
- if not x or x < 0 then x = 1 end
- if not y or y < 0 then y = 1 end
- term.clear()
- term.setCursorPos(x,y)
- print(string)
- end
- function Welcome(string)
- clearPrint("+-----------------------------------------------+")
- print("+-- Welcome to "..sName.." --+")
- print("+-----------------------------------------------+\n")
- print(string)
- end
- -- [[ Open and Close functions ]] --
- function Open()
- Welcome("Opening doors...")
- for i = 1,5 do
- rs.setOutput(sRedstoneSideOpen,true)
- sleep(.425)
- rs.setOutput(sRedstoneSideOpen,false)
- sleep(.425)
- end
- Welcome("Doors have been opened!")
- sleep(1)
- begin()
- end
- function Close()
- update = true
- Welcome("Closing garage doors...")
- sleep(1.5)
- Welcome("Closing doors...")
- for i = 1,5 do
- rs.setOutput(sRedstoneSideClose,true)
- sleep(.425)
- rs.setOutput(sRedstoneSideClose,false)
- sleep(.425)
- end
- Welcome("Doors have been closed!")
- sleep(1)
- begin()
- end
- function Exit()
- Welcome("Exiting...")
- sleep(1.5)
- end
- -- [[Check Password]] --
- function checkPW(PW)
- if PW == sDoorpw then
- Welcome("Password correct!")
- sleep(1.5)
- Welcome("Choose an option:")
- local selection = menu(
- " Open ",
- " Close ",
- " Exit ")
- if selection == " Open " then
- Open()
- elseif selection == " Close " then
- Close()
- elseif selection == " Exit " then
- Exit()
- end
- elseif PW == sBypasspw then
- Open()
- else
- Welcome("Password invalid.")
- sleep(1.5)
- end
- end
- function begin()
- Welcome("Enter password:")
- write(" > ")
- checkPW(read("*"))
- end
- begin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement