Guest User

Untitled

a guest
Dec 12th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.80 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2.  
  3. local off = 0
  4.  
  5. local tChoices = {}
  6. tChoices[0] = 'Change User'
  7. tChoices[1] = 'Change Pass'
  8. tChoices[2] = 'Use prompt'
  9. tChoices[3] = 'Log-off'
  10.  
  11. local sChoice = "DEBUG"
  12.  
  13.  
  14. local nTermX, nTermY = term.getSize()
  15. local sSeperator = ("-"):rep(nTermX) -- Create a seperator string with the size of the terminal
  16.  
  17. local tActions = {} -- Twin table of tChouices, we'll put functions in here to do stuff.
  18.  
  19. function printFrame2()
  20. sleep(0.1)
  21. print("+------------------------|----------------------+")
  22. print("| ___ __ __ / |")
  23. print("| /___ / | /__ / |")
  24. print("| /____ /___| ____| / |")
  25. print("|__________________/ |")
  26. print("| Welcome "..user.."")
  27. print("|-----------------| |")
  28. print("| | |")
  29. print("|________________/ |")
  30. print("| |")
  31. print("| |")
  32. print("| |")
  33. print("| |")
  34. print("| |")
  35. print("| |")
  36. print("| |")
  37. print("| ________|")
  38. print("| /VER: 5.0|")
  39. term.setCursorPos(18,5)
  40. write(" | ///// // // ///// |")
  41. sleep(0.1)
  42. print("+------------------------|----------------------+")
  43. print("| ___ __ __ / |")
  44. print("| /___ / | /__ / |")
  45. print("| /____ /___| ____| / ///// ///// ///// |")
  46. print("|__________________/ // // // // |")
  47. print("| Welcome "..user.."")
  48. print("|-----------------| // // // // |")
  49. print("| | ///// ///// ///// |")
  50. print("| | _________________ |")
  51. print("|________________/ /Ehwhat Operating/ |")
  52. print("| / System / |")
  53. print("| /________________/ |")
  54. print("| |")
  55. print("| |")
  56. print("| |")
  57. print("| |")
  58. print("| ________|")
  59. print("| /VER: 5.0|")
  60. term.setCursorPos(18,5)
  61. write(" | ///// // // ///// |")
  62. sleep(0.1)
  63. print("+------------------------|----------------------+")
  64. print("| ___ __ __ / |")
  65. print("| /___ / | /__ / |")
  66. print("| /____ /___| ____| / ///// ///// ///// |")
  67. print("|__________________/ // // // // |")
  68. print("| Welcome "..user.."")
  69. print("|-----------------| // // // // |")
  70. print("| | ///// ///// ///// |")
  71. print("| | _________________ |")
  72. print("| | /Ehwhat Operating/ |")
  73. print("|________________/ / System / |")
  74. print("| /________________/ |")
  75. print("| |")
  76. print("| |")
  77. print("| |")
  78. print("| |")
  79. print("| ________|")
  80. print("| /VER: 5.0|")
  81. term.setCursorPos(18,5)
  82. write(" | ///// // // ///// |")
  83. sleep(0.1)
  84. print("+------------------------|----------------------+")
  85. print("| ___ __ __ / |")
  86. print("| /___ / | /__ / |")
  87. print("| /____ /___| ____| / ///// ///// ///// |")
  88. print("|__________________/ // // // // |")
  89. print("| Welcome "..user.."")
  90. print("|-----------------| // // // // |")
  91. print("| | ///// ///// ///// |")
  92. print("| | _________________ |")
  93. print("| | /Ehwhat Operating/ |")
  94. print("| | / System / |")
  95. print("|________________/ /________________/ |")
  96. print("| |")
  97. print("| |")
  98. print("| |")
  99. print("| |")
  100. print("| ________|")
  101. print("| /VER: 5.0|")
  102. term.setCursorPos(18,5)
  103. write(" | ///// // // ///// |")
  104. sleep(0.1)
  105. print("+------------------------|----------------------+")
  106. print("| ___ __ __ / |")
  107. print("| /___ / | /__ / |")
  108. print("| /____ /___| ____| / ///// ///// ///// |")
  109. print("|__________________/ // // // // |")
  110. print("| Welcome "..user.."")
  111. print("|-----------------| // // // // |")
  112. print("| | ///// ///// ///// |")
  113. print("| | _________________ |")
  114. print("| | /Ehwhat Operating/ |")
  115. print("| | / System / |")
  116. print("| | /________________/ |")
  117. print("|________________/ |")
  118. print("| |")
  119. print("| |")
  120. print("| |")
  121. print("| ________|")
  122. print("| /VER: 5.0|")
  123. term.setCursorPos(18,5)
  124. write(" | ///// // // ///// |")
  125. sleep(0.1)
  126. print("+------------------------|----------------------+")
  127. print("| ___ __ __ / |")
  128. print("| /___ / | /__ / |")
  129. print("| /____ /___| ____| / ///// ///// ///// |")
  130. print("|__________________/ // // // // |")
  131. print("| Welcome "..user.."")
  132. print("|-----------------| // // // // |")
  133. print("| | ///// ///// ///// |")
  134. print("| | _________________ |")
  135. print("| | /Ehwhat Operating/ |")
  136. print("| | / System / |")
  137. print("| | /________________/ |")
  138. print("| | |")
  139. print("|________________/ |")
  140. print("| |")
  141. print("| |")
  142. print("| ________|")
  143. print("| /VER: 5.0|")
  144. term.setCursorPos(18,5)
  145. write(" | ///// // // ///// |")
  146. sleep(0.1)
  147. print("+------------------------|----------------------+")
  148. print("| ___ __ __ / |")
  149. print("| /___ / | /__ / |")
  150. print("| /____ /___| ____| / ///// ///// ///// |")
  151. print("|__________________/ // // // // |")
  152. print("| Welcome "..user.."")
  153. print("|-----------------| // // // // |")
  154. print("| | ///// ///// ///// |")
  155. print("| | _________________ |")
  156. print("| | /Ehwhat Operating/ |")
  157. print("| | / System / |")
  158. print("| | /________________/ |")
  159. print("| | |")
  160. print("| / |")
  161. print("|_______________/ |")
  162. print("| |")
  163. print("| ________|")
  164. print("| /VER: 5.0|")
  165. term.setCursorPos(18,5)
  166. write(" | ///// // // ///// |")
  167. sleep(0.1)
  168. print("+------------------------|----------------------+")
  169. print("| ___ __ __ / |")
  170. print("| /___ / | /__ / |")
  171. print("| /____ /___| ____| / ///// ///// ///// |")
  172. print("|__________________/ // // // // |")
  173. print("| Welcome "..user.."")
  174. print("|-----------------| // // // // |")
  175. print("| | ///// ///// ///// |")
  176. print("| | _________________ |")
  177. print("| | /Ehwhat Operating/ |")
  178. print("| | / System / |")
  179. print("| | /________________/ |")
  180. print("| | |")
  181. print("| / |")
  182. print("| / |")
  183. print("|______________/ |")
  184. print("| ________|")
  185. print("| /VER: 5.0|")
  186. term.setCursorPos(18,5)
  187. write(" | ///// // // ///// |")
  188. end
  189.  
  190. function printFrame()
  191. term.setCursorPos(1,1)
  192. shell.run("clear")
  193. print("+------------------------|----------------------+")
  194. print("| ___ __ __ / |")
  195. print("| /___ / | /__ / |")
  196. print("| /____ /___| ____| / ///// ///// ///// |")
  197. print("|__________________/ // // // // |")
  198. print("| Welcome "..user.."")
  199. print("|-----------------| // // // // |")
  200. print("| | ///// ///// ///// |")
  201. print("| | _________________ |")
  202. print("| | /Ehwhat Operating/ |")
  203. print("| | / System / |")
  204. print("| | /________________/ |")
  205. print("| | |")
  206. print("| / |")
  207. print("| / |")
  208. print("|______________/ |")
  209. print("| ________|")
  210. print("| /VER: 5.0|")
  211. term.setCursorPos(18,5)
  212. write(" | ///// // // ///// |")
  213. sleep(0.1)
  214. print("+------------------------|----------------------+")
  215. print("| ___ __ __ / |")
  216. print("| /___ / | /__ / |")
  217. print("| /____ /___| ____| / ///// ///// ///// |")
  218. print("|__________________/ // // // // |")
  219. print("| Welcome "..user.."")
  220. print("|-----------------| // // // // |")
  221. print("| | ///// ///// ///// |")
  222. print("| | _________________ |")
  223. print("| | /Ehwhat Operating/ |")
  224. print("| | / System / |")
  225. print("| | /________________/ |")
  226. print("| | |")
  227. print("| / |")
  228. print("|_______________/ |")
  229. print("| |")
  230. print("| ________|")
  231. print("| /VER: 5.0|")
  232. term.setCursorPos(18,5)
  233. write(" | ///// // // ///// |")
  234. sleep(0.1)
  235. print("+------------------------|----------------------+")
  236. print("| ___ __ __ / |")
  237. print("| /___ / | /__ / |")
  238. print("| /____ /___| ____| / ///// ///// ///// |")
  239. print("|__________________/ // // // // |")
  240. print("| Welcome "..user.."")
  241. print("|-----------------| // // // // |")
  242. print("| | ///// ///// ///// |")
  243. print("| | _________________ |")
  244. print("| | /Ehwhat Operating/ |")
  245. print("| | / System / |")
  246. print("| | /________________/ |")
  247. print("| | |")
  248. print("|________________/ |")
  249. print("| |")
  250. print("| |")
  251. print("| ________|")
  252. print("| /VER: 5.0|")
  253. term.setCursorPos(18,5)
  254. write(" | ///// // // ///// |")
  255. sleep(0.1)
  256. print("+------------------------|----------------------+")
  257. print("| ___ __ __ / |")
  258. print("| /___ / | /__ / |")
  259. print("| /____ /___| ____| / ///// ///// ///// |")
  260. print("|__________________/ // // // // |")
  261. print("| Welcome "..user.."")
  262. print("|-----------------| // // // // |")
  263. print("| | ///// ///// ///// |")
  264. print("| | _________________ |")
  265. print("| | /Ehwhat Operating/ |")
  266. print("| | / System / |")
  267. print("| | /________________/ |")
  268. print("|________________/ |")
  269. print("| |")
  270. print("| |")
  271. print("| |")
  272. print("| ________|")
  273. print("| /VER: 5.0|")
  274. term.setCursorPos(18,5)
  275. write(" | ///// // // ///// |")
  276. sleep(0.1)
  277. print("+------------------------|----------------------+")
  278. print("| ___ __ __ / |")
  279. print("| /___ / | /__ / |")
  280. print("| /____ /___| ____| / ///// ///// ///// |")
  281. print("|__________________/ // // // // |")
  282. print("| Welcome "..user.."")
  283. print("|-----------------| // // // // |")
  284. print("| | ///// ///// ///// |")
  285. print("| | _________________ |")
  286. print("| | /Ehwhat Operating/ |")
  287. print("| | / System / |")
  288. print("|________________/ /________________/ |")
  289. print("| |")
  290. print("| |")
  291. print("| |")
  292. print("| |")
  293. print("| ________|")
  294. print("| /VER: 5.0|")
  295. term.setCursorPos(18,5)
  296. write(" | ///// // // ///// |")
  297. sleep(0.1)
  298. print("+------------------------|----------------------+")
  299. print("| ___ __ __ / |")
  300. print("| /___ / | /__ / |")
  301. print("| /____ /___| ____| / ///// ///// ///// |")
  302. print("|__________________/ // // // // |")
  303. print("| Welcome "..user.."")
  304. print("|-----------------| // // // // |")
  305. print("| | ///// ///// ///// |")
  306. print("| | _________________ |")
  307. print("| | /Ehwhat Operating/ |")
  308. print("|________________/ / System / |")
  309. print("| /________________/ |")
  310. print("| |")
  311. print("| |")
  312. print("| |")
  313. print("| |")
  314. print("| ________|")
  315. print("| /VER: 5.0|")
  316. term.setCursorPos(18,5)
  317. write(" | ///// // // ///// |")
  318. sleep(0.1)
  319. print("+------------------------|----------------------+")
  320. print("| ___ __ __ / |")
  321. print("| /___ / | /__ / |")
  322. print("| /____ /___| ____| / ///// ///// ///// |")
  323. print("|__________________/ // // // // |")
  324. print("| Welcome "..user.."")
  325. print("|-----------------| // // // // |")
  326. print("| | ///// ///// ///// |")
  327. print("| | _________________ |")
  328. print("|________________/ /Ehwhat Operating/ |")
  329. print("| / System / |")
  330. print("| /________________/ |")
  331. print("| |")
  332. print("| |")
  333. print("| |")
  334. print("| |")
  335. print("| ________|")
  336. print("| /VER: 5.0|")
  337. term.setCursorPos(18,5)
  338. write(" | ///// // // ///// |")
  339. sleep(0.1)
  340. print("+------------------------|----------------------+")
  341. print("| ___ __ __ / |")
  342. print("| /___ / | /__ / |")
  343. print("| /____ /___| ____| / |")
  344. print("|__________________/ |")
  345. print("| Welcome "..user.."")
  346. print("|-----------------| |")
  347. print("| "..sChoice.." ")
  348. print("|________________/ |")
  349. print("| |")
  350. print("| |")
  351. print("| |")
  352. print("| |")
  353. print("| |")
  354. print("| |")
  355. print("| |")
  356. print("| ________|")
  357. print("| /VER: 5.0|")
  358. term.setCursorPos(18,5)
  359. write(" | |")
  360. term.setCursorPos(19,7)
  361. write("| |")
  362. end
  363.  
  364. os.pullEvent = os.pullEventRaw
  365. function printFrameLogin()
  366. term.setCursorPos(1,1)
  367. term.clear()
  368. print("+------------------------|----------------------+")
  369. print("| ___ __ __ / |")
  370. print("| /___ / | /__ / |")
  371. print("| /____ /___| ____| / |")
  372. print("|__________________/ |")
  373. print("| |")
  374. print("| |")
  375. print("| |")
  376. print("| |")
  377. print("| |")
  378. print("| |")
  379. print("| |")
  380. print("| |")
  381. print("| |")
  382. print("| |")
  383. print("| |")
  384. print("| |")
  385. print("| |")
  386. end
  387.  
  388.  
  389. tActions[0] = function() -- Stuff a function in here!
  390. sChoice = "Username Change"
  391. printFrame()
  392. term.setCursorPos(23,1)
  393. write("/ | Enter Username")
  394. term.setCursorPos(23,2)
  395. write(" |_______________________")
  396. term.setCursorPos(23,3)
  397. write(" | ")
  398. term.setCursorPos(23,4)
  399. write(" |-----------------------")
  400. term.setCursorPos(26,3)
  401. input = read()
  402. term.setCursorPos(49,3)
  403. write("|")
  404. if input == PVar.user then
  405. term.setCursorPos(23,5)
  406. write(" | Enter New Username: ")
  407. term.setCursorPos(23,6)
  408. write(" |_______________________")
  409. term.setCursorPos(23,7)
  410. write(" | ")
  411. term.setCursorPos(23,8)
  412. write(" |-----------------------")
  413. term.setCursorPos(26,7)
  414. input = read()
  415. term.setCursorPos(49,7)
  416. write("|")
  417. PVar.user = input
  418. term.setCursorPos(23,9)
  419. write(" | ")
  420. term.setCursorPos(23,9)
  421. write(" | Username changed! ")
  422. term.setCursorPos(23,10)
  423. write(" \\______________________")
  424. sleep(1.5)
  425. printFrame2()
  426. else
  427. term.setCursorPos(23,5)
  428. write(" | Incorrect ")
  429. term.setCursorPos(22,6)
  430. write(" \\______________________")
  431. term.setCursorPos(49,6)
  432. write("|")
  433. sleep(1.5)
  434. printFrame2()
  435. end
  436.  
  437. end
  438.  
  439. tActions[1] = function()
  440. sChoice = "Password Change"
  441. printFrame()
  442. term.setCursorPos(23,1)
  443. write("/ | Enter Password")
  444. term.setCursorPos(23,2)
  445. write(" |_______________________")
  446. term.setCursorPos(23,3)
  447. write(" | ")
  448. term.setCursorPos(23,4)
  449. write(" |-----------------------")
  450. term.setCursorPos(26,3)
  451. input = read("*")
  452. term.setCursorPos(49,3)
  453. write("|")
  454. if input == PVar.pass then
  455. term.setCursorPos(23,5)
  456. write(" | Enter New Password: ")
  457. term.setCursorPos(23,6)
  458. write(" |_______________________")
  459. term.setCursorPos(23,7)
  460. write(" | ")
  461. term.setCursorPos(23,8)
  462. write(" |-----------------------")
  463. term.setCursorPos(26,7)
  464. input = read("*")
  465. term.setCursorPos(49,7)
  466. write("|")
  467. PVar.pass = input
  468. term.setCursorPos(23,9)
  469. write(" | Password changed! ")
  470. term.setCursorPos(23,10)
  471. write(" \\______________________")
  472. sleep(1.5)
  473. printFrame2()
  474. else
  475. term.setCursorPos(23,5)
  476. write(" | Incorrect ")
  477. term.setCursorPos(22,6)
  478. write(" \\______________________")
  479. term.setCursorPos(49,6)
  480. write("|")
  481. sleep(1.5)
  482. printFrame2()
  483. end
  484. end
  485.  
  486. tActions[2] = function()
  487. off = 1
  488. term.clear()
  489. term.setCursorPos(1,1)
  490. print("_________________________________________")
  491. print("| | E.OS V5.0 | Welcome "..PVar.user.."")
  492. print("|______________________________________/ ")
  493. term.setCursorPos(41,2)
  494. write("/")
  495. term.setCursorPos(1,4)
  496. end
  497.  
  498. tActions[3] = function()
  499. sChoice = "Log off"
  500. printFrame()
  501. term.setCursorPos(22,2)
  502. write(" \\______________________")
  503. term.setCursorPos(23,1)
  504. write(" | Logging off ")
  505. sleep(0.3)
  506. term.setCursorPos(23,1)
  507. write(" | Logging off. ")
  508. sleep(0.3)
  509. term.setCursorPos(23,1)
  510. write(" | Logging off.. ")
  511. sleep(0.3)
  512. term.setCursorPos(23,1)
  513. write(" | Logging off... ")
  514. term.setCursorPos(49,2)
  515. write("|")
  516. sleep(1.5)
  517. os.reboot()
  518. end
  519.  
  520. -- Finsh above for functions
  521.  
  522. local nSelection = 0 -- The current selection defaults at 0
  523. printFrame2()
  524. repeat
  525. term.setCursorPos(1, 1)
  526. term.clear()
  527. print("+------------------------|----------------------+")
  528. print("| ___ __ __ / |")
  529. print("| /___ / | /__ / |")
  530. print("| /____ /___| ____| / ///// ///// ///// |")
  531. print("|__________________/ // // // // |")
  532. print("| Welcome "..user.."")
  533. print("|-----------------| // // // // |")
  534. print("| | ///// ///// ///// |")
  535. print("| | _________________ |")
  536. print("| | /Ehwhat Operating/ |")
  537. print("| | / System / |")
  538. print("| | /________________/ |")
  539. print("| | |")
  540. print("| / |")
  541. print("| / |")
  542. print("|______________/ |")
  543. print("| ________|")
  544. print("| /VER: 5.0|")
  545. term.setCursorPos(18,5)
  546. write(" | ///// // // ///// |")
  547. term.setCursorPos(2,7)
  548.  
  549. for nLine = 0, #tChoices do -- Iterate through the possible options, and print them, marking the chosen one
  550. local oldx, oldy = term.getCursorPos()
  551. local sLine = " "
  552. if nSelection == nLine then
  553. sLine = ">"
  554. end
  555. local sLineNum = tostring(nLine)
  556. if #sLineNum < 2 then
  557. sLineNum = "0" .. sLineNum -- Prepend a 0 if it's too short
  558. end
  559. sLine = sLine .. "-" .. " " .. tChoices[nLine] -- Construct the string we're printing
  560. print(sLine) -- Print it#]
  561. term.setCursorPos(2,oldy+1)
  562. end
  563. -- os.pullEvent keys: up - 200, down - 208, enter - 28
  564. local sEvent, nKey = os.pullEvent("key") -- Using the 1.3 filtering; this will mean only "key" events will pass
  565.  
  566. if nKey == 200 or nKey == 17 then -- Up/w key: move up the menu
  567. if tChoices[nSelection - 1] then -- Check if we can move up
  568. nSelection = nSelection - 1
  569. end
  570. -- Ignore it otherwise
  571. elseif nKey == 208 or nKey == 31 then -- Down/s key: move down the menu
  572. if tChoices[nSelection + 1] then -- Check if we can move down
  573. nSelection = nSelection + 1
  574. end
  575. elseif nKey == 28 then -- Enter key: Selecting a choice
  576. if tActions[nSelection] then
  577. tActions[nSelection]() -- Run the function associated with the action.
  578.  
  579. else
  580. print("Error: Selection out of bounds: ", nSelection)
  581. sleep(2)
  582. shell.run("startup") -- This error is recoverable.
  583. end
  584. end
  585. until off == 1
Add Comment
Please, Sign In to add comment