Guest User

Untitled

a guest
Jul 19th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.21 KB | None | 0 0
  1. if fs.exists("mine/pass") then
  2. file = fs.open("mine/pass", "r")
  3. term.clear()
  4. term.setCursorPos(1,1)
  5. print("[System bezpieczenstwa]")
  6. print("Podaj haslo by kontynuowac.")
  7. pass = read("*")
  8. if pass == file.readAll() then
  9. local tChoices = {}
  10. tChoices[0] = '[|>|] Programy'
  11. tChoices[1] = '[|>|] Preferencje'
  12. tChoices[2] = '[|>|] Uruchom'
  13. tChoices[3] = '[|>|] Wlasny Program'
  14. tChoices[4] = '[|>|] Api'
  15. tChoices[5] = '[|>|] Poradniki'
  16. tChoices[6] = '[!>!] Multimedia'
  17.  
  18. 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 #.
  19. local nTermX, nTermY = term.getSize()
  20. local sSeperator = ("-"):rep(nTermX) -- Create a seperator string with the size of the terminal
  21.  
  22. local tActions = {} -- Twin table of tChouices, we'll put functions in here to do stuff.
  23.  
  24.  
  25.  
  26. tActions[0] = function() -- Stuff a function in here!
  27.     term.clear()
  28.     term.setCursorPos(1, 1) -- Reset the cursor's position to be safe
  29.     print(sSeperator)
  30.     print("|                           Programy                                 |")
  31.     print(sSeperator)
  32. shell.run("programs")
  33.     term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  34.     write("    [By wrocic wcisnij Enter]")
  35.     read(" ")
  36. end
  37.  
  38. tActions[1] = function()
  39.     term.clear()
  40.     term.setCursorPos(1, 1)
  41.     print(sSeperator)
  42.     print "|                  Preferencje                       |"
  43.     print(sSeperator)
  44.  id = os.getComputerID()
  45.  print("System: TNTSoft Mine XVS")
  46.  print("")
  47.  print("ID Komputera: ", id)
  48.  
  49.     term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  50.     write("    [By wrocic wcisnij Enter]")
  51.     read(" ")
  52. end
  53.  
  54. tActions[2] = function() -- I've just copypasted these, with the space-saving modification :p
  55.     term.clear()
  56.     term.setCursorPos(1, 1)
  57.     print(sSeperator)
  58.     print "|        Uruchom                |"
  59.     print(sSeperator)
  60.    
  61.  print("Nazwa programu: ")
  62.  a = read()
  63.  if a == "startup" then
  64.  return
  65.  else
  66.  print("")
  67.  shell.run(a)
  68.  end
  69.  
  70.     term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  71.     write("    [By wrocic wcisnij Enter]")
  72.     read(" ")
  73. end
  74.  
  75. tActions[3] = function()
  76.     term.clear()
  77.     term.setCursorPos(1, 1)
  78.     print(sSeperator)
  79.     print "|               Wlasny Program      |"
  80.     print(sSeperator)
  81.    
  82.  print("Nazwa: ")
  83.  e = read()
  84.  print("")
  85.  if e == "startup" then
  86.  print("Odmowa Dostepu!")
  87.  return
  88.  else
  89.  shell.run("edit", e)
  90.  end
  91.  
  92.     term.setCursorPos(1, nTermY) -- Move the cursor to the bottom
  93.     write("    [By wrocic wcisnij Enter]")
  94.     read(" ")
  95. end
  96.  
  97. tActions[4] = function()
  98. term.clear()
  99. term.setCursorPos(1,1)
  100. print(sSeperator)
  101. print("|        Api               |")
  102. print(sSeperator)
  103. shell.run("apis")
  104.  
  105. term.setCursorPos(1, nTermY)
  106. write("        [By wrocic wcisnij Enter]")
  107. read(" ")
  108. end
  109.  
  110. tActions[5] = function()
  111. shell.run("tuts")
  112. end
  113. tActions[6] = function()
  114. term.clear()
  115. term.setCursorPos(1,1)
  116. print(sSeperator)
  117. print("|                                Multimedia         |")
  118. print(sSeperator)
  119. print("Lista multimedi: ")
  120. print("niebo.png")
  121.  
  122. print("Nazwa multimedi: ")
  123. png = read()
  124.  
  125. shell.run(png)
  126.  
  127. term.setCursorPos(1, nTermY)
  128. write("        [By wrocic wcisnij Enter]")
  129. read(" ")
  130. end
  131.  
  132. table.insert(tActions, os.shutdown) -- Insert the shutdown function at the end to compliment the "Shutdown" menu item :)
  133.  
  134. -- Do the above for the remaining
  135.  
  136. if nKey == 29 and 20 then
  137. shell.run("clear")
  138. print("Mine Root Terminal")
  139. end
  140.  
  141. local nSelection = 0 -- The current selection defaults at 0
  142. repeat
  143.     term.setCursorPos(1, 1)
  144.     term.clear()
  145.     print(sSeperator)
  146.     print("|                   TNTSoft Mine XVS               |")
  147.     print(sSeperator)
  148.  
  149.     for nLine = 0, #tChoices do -- Iterate through the possible potions, and print them, marking the chosen one
  150.         local sLine = " "
  151.         if nSelection == nLine then
  152.             sLine = ">"
  153.         end
  154.         local sLineNum = tostring(nLine)
  155.         if #sLineNum < 2 then
  156.             sLineNum = "0" .. sLineNum -- Prepend a 0 if it's too short
  157.         end
  158.         sLine = sLine .. "[" .. sLineNum .. "]" .. " " .. tChoices[nLine] -- Construct the string we're printing
  159.         print(sLine) -- Print it
  160.     end
  161.     -- os.pullEvent keys: up - 200, down - 208, enter - 28
  162.     local sEvent, nKey = os.pullEvent("key") -- Using the 1.3 filtering; this will mean only "key" events will pass
  163.  
  164.     if nKey == 200 or nKey == 17 then -- Up/w key: move up the menu
  165.         if tChoices[nSelection - 1] then -- Check if we can move up
  166.             nSelection = nSelection - 1
  167.         end
  168.         -- Ignore it otherwise
  169.     elseif nKey == 208 or nKey == 31  then -- Down/s key: move down the menu
  170.         if tChoices[nSelection + 1] then -- Check if we can move down
  171.             nSelection = nSelection + 1
  172.         end
  173.     elseif nKey == 28 then -- Enter key: Selecting a choice
  174.         if tActions[nSelection] then
  175.             tActions[nSelection]() -- Run the function associated with the action.
  176.         else
  177.             print("Blad z  ", nSelection)
  178.             read() -- This error is recoverable.
  179.         end
  180.     end
  181. until false -- Run this loop forever :)
  182. else
  183. print("Zle haslo!")
  184. sleep(2)
  185. os.reboot()
  186. end
  187. else
  188. term.clear()
  189. term.setCursorPos(1,1)
  190. print("[System bezpieczenstwa]")
  191. print("Utworz haslo.")
  192. p = read()
  193. plik = fs.open("mine/pass", "w")
  194. plik.write(p)
  195. plik.close()
  196. print("")
  197. print("Utworzono haslo. Resetowanie komputera...")
  198. sleep(3)
  199. os.reboot()
  200. end
Add Comment
Please, Sign In to add comment