Guest User

Untitled

a guest
Jan 21st, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.98 KB | None | 0 0
  1. --CONFIGURATION
  2.  
  3. server = 2 -- put the server's computer id here
  4. cursor = "<> " -- this is the cursor for the welcome screen
  5. cursor2 = "<> " -- this is the cursor for the actual Minebook
  6. maxUserNameLength = 10 --The max ammount of charecters allowed in a username
  7. banners = {"| Only One |", "| Multiple Features |", "| Admin Added |", "| Super Addicting |", "| Updates Coming Soon |"} --This is the banners (what it says under RedBook 1.2) to learn how to add custum banners read the Banner ReadMe
  8.  
  9. -- |----------------------|
  10. -- | RedBook 1.2 |
  11. -- | Updates Coming Soon |
  12. -- |----------------------|
  13.  
  14. -- Banner Template ^
  15.  
  16. --Do not touch anything below this unless you know what you are doing
  17.  
  18. function uploadScript()
  19. shell.run("clear")
  20. print("Pick a file to upload")
  21. sApp = read()
  22. if fs.exists(sApp) then
  23. fProgram = fs.open(sApp, "r")
  24. program = fProgram.readAll()
  25. fProgram.close()
  26. s = crntname.."!SP!uploadScript!SP!"..sApp.."!SP!"..program
  27. rednet.send(server, s)
  28. id, msg, d = rednet.receive(2)
  29. if msg ~= nil then
  30. print(msg)
  31. os.sleep(2)
  32. end
  33. loadRandomCrap2()
  34. else
  35. shell.run("clear")
  36. print("NOT A PROGRAM")
  37. loadRandomCrap2()
  38. end
  39. end
  40.  
  41. function browseScripts()
  42. hj = crntname.."!SP!downloadScript!SP!"..browseScripts
  43. rednet.send(server, hj)
  44. id, msg, d = rednet.receive(2)
  45. if msg == nil then
  46. shell.run("Clear")
  47. print("SERVER ERROR")
  48. os.sleep(2)
  49. else
  50. t = textutils.unserialize(msg)
  51. shell.run("clear")
  52. textutils.tabulate(t)
  53. print("")
  54. print("Pick a software to download. If you dont want to download anything then type none")
  55. print("")
  56. term.write("Enter software: ")
  57. app = read()
  58. if app ~= "none" then
  59. p = crntname.."!SP!downloadScript!SP!"..app
  60. rednet.send(server, p)
  61. end
  62. end
  63. loadRandomCrap2()
  64. end
  65.  
  66. function testLogIn()
  67. shell.run("clear")
  68. if msg1 == "YOU HAVE BEEN LOGGED IN" then
  69. print(msg1..": "..crntname)
  70. term.setCursorBlink(false)
  71. read()
  72. else
  73. print(msg1)
  74. term.setCursorBlink(false)
  75. read()
  76. end
  77. if msg1 == "YOU HAVE BEEN LOGGED IN" then
  78. pickNewBanner()
  79. mineBook()
  80. else
  81. pickNewBanner()
  82. loadRandomCrap()
  83. end
  84. end
  85.  
  86. function errorQuit()
  87. a = jkfdls+fjdsjfal
  88. print(a)
  89. end
  90.  
  91. function searchUser()
  92. shell.run("clear")
  93. term.write("ENTER USER: ")
  94. user2 = read()
  95. if user2 ~= crntname then
  96. sndsrch = crntname.."!SP!search!SP!"..user2
  97. rednet.send(server, sndsrch)
  98. id3, msg3, d3 = rednet.receive(5)
  99. if msg3 ~= nil then
  100. srch = split(msg3, "!SP!")
  101. nuser = srch[1]
  102. nstatus = srch[2]
  103. nfriends = srch[3]
  104. if nstatus == nil then
  105. nstatus = ""
  106. end
  107. shell.run("clear")
  108. print("|||||||||||||||||||||||||||")
  109. print("|| ||")
  110. print("|| USER SEARCH RESULTS ||")
  111. print("|| ||")
  112. print("|||||||||||||||||||||||||||")
  113. print("")
  114. print("")
  115. print("User Name: "..nuser)
  116. print("")
  117. print("Status: "..nstatus)
  118. print("")
  119. print("")
  120. print("PRESS S TO SEND FRIEND REQUEST OR E TO EXIT")
  121. while true do
  122. event9, param9 = os.pullEvent()
  123. if event9 == "key" and param9 == 31 and nuser then
  124. sndmsg = crntname.."!SP!sndfrq!SP!"..nuser
  125. shell.run("clear")
  126. rednet.send(server, sndmsg)
  127. id8, msg8, d8 = rednet.receive(1)
  128. if msg8 == nil then
  129. print("REQUEST SENT")
  130. read()
  131. pickNewBanner()
  132. loadRandomCrap2()
  133. break
  134. else
  135. print("YOU ARE ALREADY FRIENDS WITH THIS PERSON")
  136. read()
  137. pickNewBanner()
  138. loadRandomCrap2()
  139. break
  140. end
  141. elseif event9 == "key" and param9 == 18 then
  142. pickNewBanner()
  143. loadRandomCrap2()
  144. break
  145. end
  146. end
  147. else
  148. shell.run("clear")
  149. print("SERVER ERROR")
  150. read()
  151. pickNewBanner()
  152. loadRandomCrap2()
  153. end
  154. else
  155. shell.run("clear")
  156. print("YOU CAN NOT SEARCH YOURSELF")
  157. sleep(1)
  158. pickNewBanner()
  159. loadRandomCrap2()
  160. end
  161. end
  162.  
  163. function prntFrq()
  164. shell.run("clear")
  165. print("FRIEND REQUESTS")
  166. print("")
  167. print(frq[gcur])
  168. print("")
  169. print("PRESS A TO ACCEPT OR D TO DECLINE")
  170. end
  171.  
  172. function printFrndReq()
  173. gcur = 1
  174. prntFrq()
  175. while true do
  176. event2, param2 = os.pullEvent()
  177. if event2 == "key" and param2 == 30 then
  178. shell.run("clear")
  179. print("USER ADDED")
  180. ju = crntname.."!SP!add friend!SP!"..frq[gcur]
  181. rednet.send(server, ju)
  182. gcur = gcur+1
  183. read()
  184. if gcur > gmax then
  185. loadRandomCrap2()
  186. break
  187. else
  188. prntFrq()
  189. end
  190. elseif event2 == "key" and param2 == 32 then
  191. shell.run("clear")
  192. print("USER DECLINED")
  193. gcur = gcur+1
  194. read()
  195. if gcur > gmax then
  196. pickNewBanner()
  197. loadRandomCrap2()
  198. break
  199. else
  200. prntFrq()
  201. end
  202. end
  203. end
  204. end
  205.  
  206. function checkFrndReq()
  207. jk = crntname.."!SP!chck frnd req"
  208. rednet.send(server, jk)
  209. id, msg, d = rednet.receive(5)
  210. if msg ~= nil then
  211. frq = split(msg, "!SP!")
  212. gmax = #frq
  213. gmin = 1
  214. if gmax >= gmin then
  215. shell.run("clear")
  216. printFrndReq()
  217. else
  218. shell.run("clear")
  219. print("NO NEW REQUESTS")
  220. read()
  221. end
  222. loadRandomCrap2()
  223. end
  224. end
  225.  
  226. function updateStatus()
  227. shell.run("clear")
  228. stat = read()
  229. h = crntname.."!SP!status update!SP!"..stat
  230. rednet.send(server, h)
  231. g = fs.open("MINEBOOK/STATUS", "w")
  232. g.write(stat)
  233. g.close()
  234. end
  235.  
  236. function listFriends()
  237. y = "list"
  238. x = crntname.."!SP!"..y
  239. rednet.send(server, x)
  240. id, msg, d = rednet.receive(4)
  241. if msg == nil then
  242. shell.run("clear")
  243. print("ERROR")
  244. read()
  245. loadRandomCrap2()
  246. else
  247. shell.run("clear")
  248. r = split(msg, "!SP!")
  249. print("FRIEND LIST")
  250. textutils.tabulate(r)
  251. read()
  252. loadRandomCrap2()
  253. end
  254. end
  255.  
  256. function testLogInTwo()
  257. shell.run("clear")
  258. print(msg2)
  259. term.setCursorBlink(false)
  260. read()
  261. end
  262.  
  263. function OpenAll()
  264. for _,side in ipairs(rs.getSides()) do
  265. rednet.open(side)
  266. end
  267. end
  268.  
  269. function mineBook()
  270.  
  271. w1 = "Search"
  272. w2 = "Change Status"
  273. w3 = "Friends"
  274. w4 = "Check Friend Request"
  275. w5 = "Upload a Script"
  276. w6 = "Browse Scripts"
  277. w7 = "Exit"
  278.  
  279. min = 1
  280. max = 7
  281. cur = min
  282.  
  283. function doThings2()
  284. if cur == 3 then
  285. listFriends()
  286. elseif cur == 4 then
  287. checkFrndReq()
  288. elseif cur == 1 then
  289. searchUser()
  290. elseif cur == 2 then
  291. updateStatus()
  292. pickNewBanner()
  293. loadRandomCrap2()
  294. elseif cur == 5 then
  295. uploadScript()
  296. elseif cur == 6 then
  297. browseScripts()
  298. end
  299. end
  300.  
  301.  
  302. function loadRandomCrap2()
  303. OpenAll()
  304. term.clear()
  305. term.setCursorPos(1,1)
  306. print("|----------------------| WELLCOME: "..crntname)
  307. print("| RedBook 1.2 |")
  308. print(banners[curBanner])
  309. print("|----------------------|")
  310. print("")
  311. print("")
  312. if cur == 1 then
  313. term.setCursorPos(1,11)
  314. print(""..cursor2..""..w1.."")
  315. else
  316. term.setCursorPos(1,11)
  317. print(w1)
  318. end
  319. if cur == 2 then
  320. term.setCursorPos(1,12)
  321. print(""..cursor2..""..w2.."")
  322. else
  323. term.setCursorPos(1,12)
  324. print(w2)
  325. end
  326. if cur == 3 then
  327. term.setCursorPos(1,13)
  328. print(""..cursor2..""..w3.."")
  329. else
  330. term.setCursorPos(1,13)
  331. print(w3)
  332. end
  333. if cur == 4 then
  334. term.setCursorPos(1,14)
  335. print(""..cursor2..""..w4.."")
  336. else
  337. term.setCursorPos(1,14)
  338. print(w4)
  339. end
  340. if cur == 5 then
  341. term.setCursorPos(1,15)
  342. print(""..cursor2..""..w5.."")
  343. else
  344. term.setCursorPos(1,15)
  345. print(w5)
  346. end
  347. if cur == 6 then
  348. term.setCursorPos(1,16)
  349. print(""..cursor2..""..w6.."")
  350. else
  351. term.setCursorPos(1,16)
  352. print(w6)
  353. end
  354. if cur == 7 then
  355. term.setCursorPos(1,17)
  356. print(""..cursor2..""..w7.."")
  357. else
  358. term.setCursorPos(1,17)
  359. print(w7)
  360. end
  361. end
  362.  
  363. function runMineBook()
  364. loadRandomCrap2()
  365. while true do
  366. event, param1 = os.pullEvent()
  367. if event == "key" and param1 == 200 then
  368. if cur == min then
  369. cur = max
  370. loadRandomCrap2()
  371. else
  372. cur = cur-1
  373. loadRandomCrap2()
  374. end
  375. elseif event == "key" and param1 == 208 then
  376. if cur == max then
  377. cur = min
  378. loadRandomCrap2()
  379. else
  380. cur = cur+1
  381. loadRandomCrap2()
  382. end
  383. elseif event == "key" and param1 == 28 then
  384. if cur == 7 then
  385. shell.run("clear")
  386. min = 1
  387. max = 4
  388. cur = min
  389. pickNewBanner()
  390. loadRandomCrap()
  391. break
  392. end
  393. doThings2()
  394. end
  395. end
  396. end
  397. runMineBook()
  398. end
  399.  
  400. function split(str, pat)
  401. local t = { }
  402. local fpat = "(.-)"..pat
  403. local last_end = 1
  404. local s, e, cap = str:find(fpat, 1)
  405. while s do
  406. if s ~= 1 or cap ~= "" then
  407. table.insert(t,cap)
  408. end
  409. last_end = e+1
  410. s, e, cap = str:find(fpat, last_end)
  411. end
  412. if last_end <= #str then
  413. cap = str:sub(last_end)
  414. table.insert(t, cap)
  415. end
  416. return t
  417. end
  418.  
  419. min = 1
  420. max = 4
  421. cur = min
  422.  
  423. function makeUser()
  424. shell.run("clear")
  425. term.write("ENTER DESIRED USERNAME: ")
  426. term.setCursorPos(1,3)
  427. term.write("ENTER DESIRED PASSWORD: ")
  428. term.setCursorPos(1,5)
  429. term.write("RE-ENTER DESIRED PASSWORD: ")
  430. term.setCursorPos(26,1)
  431. dusrnm = read()
  432. term.setCursorPos(26,3)
  433. dpw = read("*")
  434. term.setCursorPos(29,5)
  435. rdpw = read("*")
  436. if dpw == rdpw then
  437. if #dusrnm <= maxUserNameLength then
  438. y = dusrnm.."!SP!makeUser!SP!"..dpw
  439. rednet.send(server, y)
  440. id2, msg2, d2 = rednet.receive(1)
  441. if msg2 == nil then
  442. shell.run("clear")
  443. print("SERVER ERROR")
  444. read()
  445. loadRandomCrap()
  446. else
  447. username = dusrnm
  448. rednet.send(server, username.."!SP!status update!SP!DEFAULT STATUS")
  449. testLogInTwo()
  450. end
  451. else
  452. shell.run("clear")
  453. print("USERNAME IS TOO LONG")
  454. read()
  455. end
  456. else
  457. shell.run("clear")
  458. print("PASSWORDS DO NOT MATCH")
  459. read()
  460. end
  461. end
  462.  
  463. function logIn()
  464. shell.run("clear")
  465. term.write("ENTER USERNAME: ")
  466. term.setCursorPos(1,3)
  467. term.write("ENTER PASSWORD: ")
  468. term.setCursorPos(17,1)
  469. usrnm = read()
  470. term.setCursorPos(17,3)
  471. pswrd = read("*")
  472. x = usrnm.."!SP!logIn!SP!"..pswrd
  473. rednet.send(server, x)
  474. id1, msg1, d1 = rednet.receive(1)
  475. if msg1 == nil then
  476. shell.run("clear")
  477. print("SERVER ERROR")
  478. read()
  479. loadRandomCrap()
  480. else
  481. if msg1 == "YOU HAVE BEEN LOGGED IN" then
  482. crntname = usrnm
  483. testLogIn()
  484. else
  485. testLogIn()
  486. end
  487. end
  488. end
  489.  
  490. term.setCursorBlink(false)
  491. cursor = "=> "
  492.  
  493. s1 = "Log In"
  494. s2 = "Make Account"
  495. s3 = "Change Banner"
  496. s4 = "Exit"
  497.  
  498. function doThings()
  499. if cur == 3 then
  500. pickNewBanner()
  501. loadRandomCrap()
  502. elseif cur == 1 then
  503. logIn()
  504. elseif cur == 2 then
  505. makeUser()
  506. pickNewBanner()
  507. loadRandomCrap()
  508. end
  509. end
  510.  
  511. function pickNewBanner()
  512. maxBannerNumber = #banners
  513. curBanner = math.random(maxBannerNumber)
  514. end
  515.  
  516. function loadRandomCrap()
  517. OpenAll()
  518. term.clear()
  519. term.setCursorPos(1,1)
  520. print("|----------------------|")
  521. print("| RedBook 1.2 |")
  522. print(banners[curBanner])
  523. print("|----------------------|")
  524. if cur == 1 then
  525. term.setCursorPos(1,7)
  526. print(""..cursor..""..s1.."")
  527. else
  528. term.setCursorPos(1,7)
  529. print(s1)
  530. end
  531. if cur == 2 then
  532. term.setCursorPos(1,8)
  533. print(""..cursor..""..s2.."")
  534. else
  535. term.setCursorPos(1,8)
  536. print(s2)
  537. end
  538. if cur == 3 then
  539. term.setCursorPos(1,9)
  540. print(""..cursor..""..s3.."")
  541. else
  542. term.setCursorPos(1,9)
  543. print(s3)
  544. end
  545. if cur == 4 then
  546. term.setCursorPos(1,10)
  547. print(""..cursor..""..s4.."")
  548. else
  549. term.setCursorPos(1,10)
  550. print(s4)
  551. end
  552. end
  553.  
  554. function runProgram()
  555. fs.makeDir("MINEBOOK")
  556.  
  557. min = 1
  558. max = 4
  559. cur = min
  560.  
  561. loadRandomCrap()
  562. while true do
  563. event, param1 = os.pullEvent()
  564. if event == "key" and param1 == 200 then
  565. if cur == min then
  566. cur = max
  567. loadRandomCrap()
  568. else
  569. cur = cur-1
  570. loadRandomCrap()
  571. end
  572. elseif event == "key" and param1 == 208 then
  573. if cur == max then
  574. cur = min
  575. loadRandomCrap()
  576. else
  577. cur = cur+1
  578. loadRandomCrap()
  579. end
  580. elseif event == "key" and param1 == 28 then
  581. if cur == 4 then
  582. break
  583. end
  584. doThings()
  585. end
  586. end
  587. end
  588.  
  589. pickNewBanner()
  590. runProgram()
Add Comment
Please, Sign In to add comment