Guest User

Untitled

a guest
Oct 4th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.04 KB | None | 0 0
  1. function testLogIn()
  2. shell.run("clear")
  3. if msg1 == "YOU HAVE BEEN LOGGED IN" then
  4. print(msg1..": "..crntname)
  5. term.setCursorBlink(false)
  6. read()
  7. else
  8. print(msg1)
  9. term.setCursorBlink(false)
  10. read()
  11. end
  12. if msg1 == "YOU HAVE BEEN LOGGED IN" then
  13. mineBook()
  14. else
  15. loadRandomCrap()
  16. end
  17. end
  18.  
  19. function errorQuit()
  20. a = jkfdls+fjdsjfal
  21. print(a)
  22. end
  23.  
  24. function updateStatus()
  25. shell.run("clear")
  26. stat = read()
  27. h = crntname.."!SP!status update"..stat
  28. rednet.send(37, h)
  29. g = fs.open("MINEBOOK/STATUS", "w")
  30. g.write(stat)
  31. g.close()
  32. end
  33.  
  34. function listFriends()
  35. y = "list"
  36. x = crntname.."!SP!"..y
  37. rednet.send(37, x)
  38. id, msg, d = rednet.receive(4)
  39. if msg == nil then
  40. shell.run("clear")
  41. print("ERROR")
  42. read()
  43. loadRandomCrap2()
  44. else
  45. shell.run("clear")
  46. r = split(msg, "!SP!")
  47. print("FRIEND LIST")
  48. textutils.tabulate(r)
  49. read()
  50. loadRandomCrap2()
  51. end
  52. end
  53.  
  54. function testLogInTwo()
  55. shell.run("clear")
  56. print(msg2)
  57. term.setCursorBlink(false)
  58. read()
  59. end
  60.  
  61. function OpenAll()
  62. for _,side in ipairs(rs.getSides()) do
  63. rednet.open(side)
  64. end
  65. end
  66.  
  67. function mineBook()
  68. cursor = ">> "
  69.  
  70. w1 = "Search"
  71. w2 = "Change Status"
  72. w3 = "Friends"
  73. w4 = "Exit"
  74.  
  75. min = 1
  76. max = 4
  77. cur = min
  78.  
  79. function doThings2()
  80. if cur == 3 then
  81. listFriends()
  82. elseif cur == 4 then
  83. runProgram()
  84. elseif cur == 1 then
  85. logIn()
  86. elseif cur == 2 then
  87. updateStatus()
  88. loadRandomCrap2()
  89. end
  90. end
  91.  
  92.  
  93. function loadRandomCrap2()
  94. OpenAll()
  95. term.clear()
  96. term.setCursorPos(1,1)
  97. l = fs.open("MINEBOOK/STATUS")
  98. ju = l.readAll()
  99. crntstatus = ju
  100. print("|----------------------| WELLCOME: "..crntname)
  101. print("| MineBook 1.0 |")
  102. print("| in the beginning |")
  103. print("|----------------------|")
  104. print("")
  105. print("STATUS: "..ju)
  106. if cur == 1 then
  107. term.setCursorPos(1,9)
  108. print(""..cursor..""..w1.."")
  109. else
  110. term.setCursorPos(1,9)
  111. print(w1)
  112. end
  113. if cur == 2 then
  114. term.setCursorPos(1,10)
  115. print(""..cursor..""..w2.."")
  116. else
  117. term.setCursorPos(1,10)
  118. print(w2)
  119. end
  120. if cur == 3 then
  121. term.setCursorPos(1,11)
  122. print(""..cursor..""..w3.."")
  123. else
  124. term.setCursorPos(1,11)
  125. print(w3)
  126. end
  127. if cur == 4 then
  128. term.setCursorPos(1,12)
  129. print(""..cursor..""..w4.."")
  130. else
  131. term.setCursorPos(1,12)
  132. print(w4)
  133. end
  134. end
  135.  
  136. function runMineBook()
  137. loadRandomCrap2()
  138. while true do
  139. event, param1 = os.pullEvent()
  140. if event == "key" and param1 == 200 then
  141. if cur == min then
  142. cur = max
  143. loadRandomCrap2()
  144. else
  145. cur = cur-1
  146. loadRandomCrap2()
  147. end
  148. elseif event == "key" and param1 == 208 then
  149. if cur == max then
  150. cur = min
  151. loadRandomCrap2()
  152. else
  153. cur = cur+1
  154. loadRandomCrap2()
  155. end
  156. elseif event == "key" and param1 == 28 then
  157. if cur == 4 then
  158. shell.run("clear")
  159. loadRandomCrap()
  160. break
  161. end
  162. doThings2()
  163. end
  164. end
  165. end
  166.  
  167. runMineBook()
  168. end
  169.  
  170. function split(str, pat)
  171. local t = { }
  172. local fpat = "(.-)"..pat
  173. local last_end = 1
  174. local s, e, cap = str:find(fpat, 1)
  175. while s do
  176. if s ~= 1 or cap ~= "" then
  177. table.insert(t,cap)
  178. end
  179. last_end = e+1
  180. s, e, cap = str:find(fpat, last_end)
  181. end
  182. if last_end <= #str then
  183. cap = str:sub(last_end)
  184. table.insert(t, cap)
  185. end
  186. return t
  187. end
  188.  
  189. min = 1
  190. max = 4
  191. cur = min
  192.  
  193. function makeUser()
  194. shell.run("clear")
  195. term.write("ENTER DESIRED USERNAME: ")
  196. term.setCursorPos(1,3)
  197. term.write("ENTER DESIRED PASSWORD: ")
  198. term.setCursorPos(1,5)
  199. term.write("RE-ENTER DESIRED PASSWORD: ")
  200. term.setCursorPos(26,1)
  201. dusrnm = read()
  202. term.setCursorPos(26,3)
  203. dpw = read("*")
  204. term.setCursorPos(29,5)
  205. rdpw = read("*")
  206. if dpw == rdpw then
  207. y = dusrnm.."!SP!"..dpw
  208. rednet.send(35, y)
  209. id2, msg2, d2 = rednet.receive(1)
  210. if msg2 == nil then
  211. shell.run("clear")
  212. print("SERVER ERROR")
  213. read()
  214. runProgram()
  215. else
  216. testLogInTwo()
  217. end
  218. else
  219. shell.run("clear")
  220. print("PASSWORDS DO NOT MATCH")
  221. read()
  222. end
  223. end
  224.  
  225. function logIn()
  226. shell.run("clear")
  227. term.write("ENTER USERNAME: ")
  228. term.setCursorPos(1,3)
  229. term.write("ENTER PASSWORD: ")
  230. term.setCursorPos(17,1)
  231. usrnm = read()
  232. term.setCursorPos(17,3)
  233. pswrd = read("*")
  234. x = usrnm.."!SP!"..pswrd
  235. rednet.send(34, x)
  236. id1, msg1, d1 = rednet.receive(1)
  237. if msg1 == nil then
  238. shell.run("clear")
  239. print("SERVER ERROR")
  240. read()
  241. runProgram()
  242. else
  243. if msg1 == "YOU HAVE BEEN LOGGED IN" then
  244. crntname = usrnm
  245. testLogIn()
  246. else
  247. testLogIn()
  248. end
  249. end
  250. end
  251.  
  252. term.setCursorBlink(false)
  253. cursor = "=> "
  254.  
  255. s1 = "Log In"
  256. s2 = "Make Account"
  257. s3 = "Open Rednet Ports"
  258. s4 = "Exit"
  259.  
  260. function doThings()
  261. if cur == 3 then
  262. OpenAll()
  263. loadRandomCrap()
  264. elseif cur == 1 then
  265. logIn()
  266. elseif cur == 2 then
  267. makeUser()
  268. loadRandomCrap()
  269. end
  270. end
  271.  
  272.  
  273. function loadRandomCrap()
  274. cursor = "=> "
  275. OpenAll()
  276. term.clear()
  277. term.setCursorPos(1,1)
  278. print("|----------------------|")
  279. print("| MineBook 1.0 |")
  280. print("| in the beginning |")
  281. print("|----------------------|")
  282. if cur == 1 then
  283. term.setCursorPos(1,7)
  284. print(""..cursor..""..s1.."")
  285. else
  286. term.setCursorPos(1,7)
  287. print(s1)
  288. end
  289. if cur == 2 then
  290. term.setCursorPos(1,8)
  291. print(""..cursor..""..s2.."")
  292. else
  293. term.setCursorPos(1,8)
  294. print(s2)
  295. end
  296. if cur == 3 then
  297. term.setCursorPos(1,9)
  298. print(""..cursor..""..s3.."")
  299. else
  300. term.setCursorPos(1,9)
  301. print(s3)
  302. end
  303. if cur == 4 then
  304. term.setCursorPos(1,10)
  305. print(""..cursor..""..s4.."")
  306. else
  307. term.setCursorPos(1,10)
  308. print(s4)
  309. end
  310. end
  311.  
  312. function runProgram()
  313. fs.makeDir("MINEBOOK")
  314.  
  315. min = 1
  316. max = 4
  317. cur = min
  318. loadRandomCrap()
  319. while true do
  320. event, param1 = os.pullEvent()
  321. if event == "key" and param1 == 200 then
  322. if cur == min then
  323. cur = max
  324. loadRandomCrap()
  325. else
  326. cur = cur-1
  327. loadRandomCrap()
  328. end
  329. elseif event == "key" and param1 == 208 then
  330. if cur == max then
  331. cur = min
  332. loadRandomCrap()
  333. else
  334. cur = cur+1
  335. loadRandomCrap()
  336. end
  337. elseif event == "key" and param1 == 28 then
  338. if cur == 4 then
  339. break
  340. end
  341. doThings()
  342. end
  343. end
  344. end
  345.  
  346. fs.makeDir("MINEBOOK")
  347. runProgram()function testLogIn()
  348. shell.run("clear")
  349. if msg1 == "YOU HAVE BEEN LOGGED IN" then
  350. print(msg1..": "..crntname)
  351. term.setCursorBlink(false)
  352. read()
  353. else
  354. print(msg1)
  355. term.setCursorBlink(false)
  356. read()
  357. end
  358. if msg1 == "YOU HAVE BEEN LOGGED IN" then
  359. mineBook()
  360. else
  361. loadRandomCrap()
  362. end
  363. end
  364.  
  365. function errorQuit()
  366. a = jkfdls+fjdsjfal
  367. print(a)
  368. end
  369.  
  370. function updateStatus()
  371. shell.run("clear")
  372. stat = read()
  373. h = crntname.."!SP!status update"..stat
  374. rednet.send(37, h)
  375. g = fs.open("MINEBOOK/STATUS", "w")
  376. g.write(stat)
  377. g.close()
  378. end
  379.  
  380. function listFriends()
  381. y = "list"
  382. x = crntname.."!SP!"..y
  383. rednet.send(37, x)
  384. id, msg, d = rednet.receive(4)
  385. if msg == nil then
  386. shell.run("clear")
  387. print("ERROR")
  388. read()
  389. loadRandomCrap2()
  390. else
  391. shell.run("clear")
  392. r = split(msg, "!SP!")
  393. print("FRIEND LIST")
  394. textutils.tabulate(r)
  395. read()
  396. loadRandomCrap2()
  397. end
  398. end
  399.  
  400. function testLogInTwo()
  401. shell.run("clear")
  402. print(msg2)
  403. term.setCursorBlink(false)
  404. read()
  405. end
  406.  
  407. function OpenAll()
  408. for _,side in ipairs(rs.getSides()) do
  409. rednet.open(side)
  410. end
  411. end
  412.  
  413. function mineBook()
  414. cursor = ">> "
  415.  
  416. w1 = "Search"
  417. w2 = "Change Status"
  418. w3 = "Friends"
  419. w4 = "Exit"
  420.  
  421. min = 1
  422. max = 4
  423. cur = min
  424.  
  425. function doThings2()
  426. if cur == 3 then
  427. listFriends()
  428. elseif cur == 4 then
  429. runProgram()
  430. elseif cur == 1 then
  431. logIn()
  432. elseif cur == 2 then
  433. updateStatus()
  434. loadRandomCrap2()
  435. end
  436. end
  437.  
  438.  
  439. function loadRandomCrap2()
  440. OpenAll()
  441. term.clear()
  442. term.setCursorPos(1,1)
  443. l = fs.open("MINEBOOK/STATUS")
  444. ju = l.readAll()
  445. crntstatus = ju
  446. print("|----------------------| WELLCOME: "..crntname)
  447. print("| MineBook 1.0 |")
  448. print("| in the beginning |")
  449. print("|----------------------|")
  450. print("")
  451. print("STATUS: "..ju)
  452. if cur == 1 then
  453. term.setCursorPos(1,9)
  454. print(""..cursor..""..w1.."")
  455. else
  456. term.setCursorPos(1,9)
  457. print(w1)
  458. end
  459. if cur == 2 then
  460. term.setCursorPos(1,10)
  461. print(""..cursor..""..w2.."")
  462. else
  463. term.setCursorPos(1,10)
  464. print(w2)
  465. end
  466. if cur == 3 then
  467. term.setCursorPos(1,11)
  468. print(""..cursor..""..w3.."")
  469. else
  470. term.setCursorPos(1,11)
  471. print(w3)
  472. end
  473. if cur == 4 then
  474. term.setCursorPos(1,12)
  475. print(""..cursor..""..w4.."")
  476. else
  477. term.setCursorPos(1,12)
  478. print(w4)
  479. end
  480. end
  481.  
  482. function runMineBook()
  483. loadRandomCrap2()
  484. while true do
  485. event, param1 = os.pullEvent()
  486. if event == "key" and param1 == 200 then
  487. if cur == min then
  488. cur = max
  489. loadRandomCrap2()
  490. else
  491. cur = cur-1
  492. loadRandomCrap2()
  493. end
  494. elseif event == "key" and param1 == 208 then
  495. if cur == max then
  496. cur = min
  497. loadRandomCrap2()
  498. else
  499. cur = cur+1
  500. loadRandomCrap2()
  501. end
  502. elseif event == "key" and param1 == 28 then
  503. if cur == 4 then
  504. shell.run("clear")
  505. loadRandomCrap()
  506. break
  507. end
  508. doThings2()
  509. end
  510. end
  511. end
  512.  
  513. runMineBook()
  514. end
  515.  
  516. function split(str, pat)
  517. local t = { }
  518. local fpat = "(.-)"..pat
  519. local last_end = 1
  520. local s, e, cap = str:find(fpat, 1)
  521. while s do
  522. if s ~= 1 or cap ~= "" then
  523. table.insert(t,cap)
  524. end
  525. last_end = e+1
  526. s, e, cap = str:find(fpat, last_end)
  527. end
  528. if last_end <= #str then
  529. cap = str:sub(last_end)
  530. table.insert(t, cap)
  531. end
  532. return t
  533. end
  534.  
  535. min = 1
  536. max = 4
  537. cur = min
  538.  
  539. function makeUser()
  540. shell.run("clear")
  541. term.write("ENTER DESIRED USERNAME: ")
  542. term.setCursorPos(1,3)
  543. term.write("ENTER DESIRED PASSWORD: ")
  544. term.setCursorPos(1,5)
  545. term.write("RE-ENTER DESIRED PASSWORD: ")
  546. term.setCursorPos(26,1)
  547. dusrnm = read()
  548. term.setCursorPos(26,3)
  549. dpw = read("*")
  550. term.setCursorPos(29,5)
  551. rdpw = read("*")
  552. if dpw == rdpw then
  553. y = dusrnm.."!SP!"..dpw
  554. rednet.send(35, y)
  555. id2, msg2, d2 = rednet.receive(1)
  556. if msg2 == nil then
  557. shell.run("clear")
  558. print("SERVER ERROR")
  559. read()
  560. runProgram()
  561. else
  562. testLogInTwo()
  563. end
  564. else
  565. shell.run("clear")
  566. print("PASSWORDS DO NOT MATCH")
  567. read()
  568. end
  569. end
  570.  
  571. function logIn()
  572. shell.run("clear")
  573. term.write("ENTER USERNAME: ")
  574. term.setCursorPos(1,3)
  575. term.write("ENTER PASSWORD: ")
  576. term.setCursorPos(17,1)
  577. usrnm = read()
  578. term.setCursorPos(17,3)
  579. pswrd = read("*")
  580. x = usrnm.."!SP!"..pswrd
  581. rednet.send(34, x)
  582. id1, msg1, d1 = rednet.receive(1)
  583. if msg1 == nil then
  584. shell.run("clear")
  585. print("SERVER ERROR")
  586. read()
  587. runProgram()
  588. else
  589. if msg1 == "YOU HAVE BEEN LOGGED IN" then
  590. crntname = usrnm
  591. testLogIn()
  592. else
  593. testLogIn()
  594. end
  595. end
  596. end
  597.  
  598. term.setCursorBlink(false)
  599. cursor = "=> "
  600.  
  601. s1 = "Log In"
  602. s2 = "Make Account"
  603. s3 = "Open Rednet Ports"
  604. s4 = "Exit"
  605.  
  606. function doThings()
  607. if cur == 3 then
  608. OpenAll()
  609. loadRandomCrap()
  610. elseif cur == 1 then
  611. logIn()
  612. elseif cur == 2 then
  613. makeUser()
  614. loadRandomCrap()
  615. end
  616. end
  617.  
  618.  
  619. function loadRandomCrap()
  620. cursor = "=> "
  621. OpenAll()
  622. term.clear()
  623. term.setCursorPos(1,1)
  624. print("|----------------------|")
  625. print("| MineBook 1.0 |")
  626. print("| in the beginning |")
  627. print("|----------------------|")
  628. if cur == 1 then
  629. term.setCursorPos(1,7)
  630. print(""..cursor..""..s1.."")
  631. else
  632. term.setCursorPos(1,7)
  633. print(s1)
  634. end
  635. if cur == 2 then
  636. term.setCursorPos(1,8)
  637. print(""..cursor..""..s2.."")
  638. else
  639. term.setCursorPos(1,8)
  640. print(s2)
  641. end
  642. if cur == 3 then
  643. term.setCursorPos(1,9)
  644. print(""..cursor..""..s3.."")
  645. else
  646. term.setCursorPos(1,9)
  647. print(s3)
  648. end
  649. if cur == 4 then
  650. term.setCursorPos(1,10)
  651. print(""..cursor..""..s4.."")
  652. else
  653. term.setCursorPos(1,10)
  654. print(s4)
  655. end
  656. end
  657.  
  658. function runProgram()
  659. fs.makeDir("MINEBOOK")
  660.  
  661. min = 1
  662. max = 4
  663. cur = min
  664. loadRandomCrap()
  665. while true do
  666. event, param1 = os.pullEvent()
  667. if event == "key" and param1 == 200 then
  668. if cur == min then
  669. cur = max
  670. loadRandomCrap()
  671. else
  672. cur = cur-1
  673. loadRandomCrap()
  674. end
  675. elseif event == "key" and param1 == 208 then
  676. if cur == max then
  677. cur = min
  678. loadRandomCrap()
  679. else
  680. cur = cur+1
  681. loadRandomCrap()
  682. end
  683. elseif event == "key" and param1 == 28 then
  684. if cur == 4 then
  685. break
  686. end
  687. doThings()
  688. end
  689. end
  690. end
  691.  
  692. fs.makeDir("MINEBOOK")
  693. runProgram()
Add Comment
Please, Sign In to add comment