Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if fs.exists("mine/pass") then
- file = fs.open("mine/pass", "r")
- term.clear()
- term.setCursorPos(1,1)
- print("[System bezpieczenstwa]")
- print("Podaj haslo by kontynuowac.")
- pass = read("*")
- if pass == file.readAll() then
- local tChoices = {}
- tChoices[0] = '[|>|] Programy'
- tChoices[1] = '[|>|] Preferencje'
- tChoices[2] = '[|>|] Uruchom'
- tChoices[3] = '[|>|] Wlasny Program'
- tChoices[4] = '[|>|] Api'
- tChoices[5] = '[|>|] Poradniki'
- tChoices[6] = '[!>!] Multimedia'
- table.insert(tChoices, '[|X|] Zamknij System') -- If you add more stuff, the shutdown will always come at the bottom, without you having to change its #.
- local nTermX, nTermY = term.getSize()
- local sSeperator = ("-"):rep(nTermX) -- Create a seperator string with the size of the terminal
- local tActions = {} -- Twin table of tChouices, we'll put functions in here to do stuff.
- tActions[0] = function() -- Stuff a function in here!
- term.clear()
- term.setCursorPos(1, 1) -- Reset the cursor's position to be safe
- print(sSeperator)
- print("| Programy |")
- print(sSeperator)
- shell.run("programs")
- term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
- write(" [By wrocic wcisnij Enter]")
- read(" ")
- end
- tActions[1] = function()
- term.clear()
- term.setCursorPos(1, 1)
- print(sSeperator)
- print "| Preferencje |"
- print(sSeperator)
- id = os.getComputerID()
- print("System: TNTSoft Mine XVS")
- print("")
- print("ID Komputera: ", id)
- term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
- write(" [By wrocic wcisnij Enter]")
- read(" ")
- end
- tActions[2] = function() -- I've just copypasted these, with the space-saving modification :p
- term.clear()
- term.setCursorPos(1, 1)
- print(sSeperator)
- print "| Uruchom |"
- print(sSeperator)
- print("Nazwa programu: ")
- a = read()
- if a == "startup" then
- return
- else
- print("")
- shell.run(a)
- end
- term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
- write(" [By wrocic wcisnij Enter]")
- read(" ")
- end
- tActions[3] = function()
- term.clear()
- term.setCursorPos(1, 1)
- print(sSeperator)
- print "| Wlasny Program |"
- print(sSeperator)
- print("Nazwa: ")
- e = read()
- print("")
- if e == "startup" then
- print("Odmowa Dostepu!")
- return
- else
- shell.run("edit", e)
- end
- term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
- write(" [By wrocic wcisnij Enter]")
- read(" ")
- end
- tActions[4] = function()
- term.clear()
- term.setCursorPos(1,1)
- print(sSeperator)
- print("| Api |")
- print(sSeperator)
- shell.run("apis")
- term.setCursorPos(1, nTermY)
- write(" [By wrocic wcisnij Enter]")
- read(" ")
- end
- tActions[5] = function()
- shell.run("tuts")
- end
- tActions[6] = function()
- term.clear()
- term.setCursorPos(1,1)
- print(sSeperator)
- print("| Multimedia |")
- print(sSeperator)
- print("Lista multimedi: ")
- print("niebo.png")
- print("Nazwa multimedi: ")
- png = read()
- shell.run(png)
- term.setCursorPos(1, nTermY)
- write(" [By wrocic wcisnij Enter]")
- read(" ")
- end
- table.insert(tActions, os.shutdown) -- Insert the shutdown function at the end to compliment the "Shutdown" menu item :)
- -- Do the above for the remaining
- if nKey == 29 and 20 then
- shell.run("clear")
- print("Mine Root Terminal")
- end
- local nSelection = 0 -- The current selection defaults at 0
- repeat
- term.setCursorPos(1, 1)
- term.clear()
- print(sSeperator)
- print("| TNTSoft Mine XVS |")
- print(sSeperator)
- for nLine = 0, #tChoices do -- Iterate through the possible potions, and print them, marking the chosen one
- local sLine = " "
- if nSelection == nLine then
- sLine = ">"
- end
- local sLineNum = tostring(nLine)
- if #sLineNum < 2 then
- sLineNum = "0" .. sLineNum -- Prepend a 0 if it's too short
- end
- sLine = sLine .. "[" .. sLineNum .. "]" .. " " .. tChoices[nLine] -- Construct the string we're printing
- print(sLine) -- Print it
- end
- -- os.pullEvent keys: up - 200, down - 208, enter - 28
- local sEvent, nKey = os.pullEvent("key") -- Using the 1.3 filtering; this will mean only "key" events will pass
- if nKey == 200 or nKey == 17 then -- Up/w key: move up the menu
- if tChoices[nSelection - 1] then -- Check if we can move up
- nSelection = nSelection - 1
- end
- -- Ignore it otherwise
- elseif nKey == 208 or nKey == 31 then -- Down/s key: move down the menu
- if tChoices[nSelection + 1] then -- Check if we can move down
- nSelection = nSelection + 1
- end
- elseif nKey == 28 then -- Enter key: Selecting a choice
- if tActions[nSelection] then
- tActions[nSelection]() -- Run the function associated with the action.
- else
- print("Blad z ", nSelection)
- read() -- This error is recoverable.
- end
- end
- until false -- Run this loop forever :)
- else
- print("Zle haslo!")
- sleep(2)
- os.reboot()
- end
- else
- term.clear()
- term.setCursorPos(1,1)
- print("[System bezpieczenstwa]")
- print("Utworz haslo.")
- p = read()
- plik = fs.open("mine/pass", "w")
- plik.write(p)
- plik.close()
- print("")
- print("Utworzono haslo. Resetowanie komputera...")
- sleep(3)
- os.reboot()
- end
Add Comment
Please, Sign In to add comment