Guest User

Untitled

a guest
Sep 25th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.00 KB | None | 0 0
  1. function testLogIn()
  2. shell.run("clear")
  3. print(msg1)
  4. term.setCursorBlink(false)
  5. read()
  6. if msg == "YOU HAVE BEEN LOGGED IN" then
  7. loadRandomCrap()
  8. else
  9. loadRandomCrap()
  10. end
  11. end
  12.  
  13. function requestFriends()
  14. rednet.send(37, crntname)
  15. end
  16.  
  17. function testLogInTwo()
  18. shell.run("clear")
  19. print(msg2)
  20. term.setCursorBlink(false)
  21. read()
  22. loadRandomCrap()
  23. end
  24.  
  25. function OpenAll()
  26. for _,side in ipairs(rs.getSides()) do
  27. rednet.open(side)
  28. end
  29. end
  30.  
  31. function mineBook()
  32. cursor = "=> "
  33.  
  34. w1 = "Search"
  35. w2 = "Change Status"
  36. w3 = "Friends"
  37. w4 = "Exit"
  38.  
  39. min = 1
  40. max = 4
  41. cur = min
  42.  
  43. function doThings2()
  44. if cur == 4 then
  45. runApp()
  46. elseif cur == 3 then
  47. OpenAll()
  48. loadRandomCrap2()
  49. elseif cur == 1 then
  50. logIn()
  51. elseif cur == 2 then
  52. makeUser()
  53. loadRandomCrap2()
  54. end
  55. end
  56.  
  57.  
  58. function loadRandomCrap2()
  59. OpenAll()
  60. term.clear()
  61. term.setCursorPos(1,1)
  62. print("|----------------------|")
  63. print("| MineBook 1.0 |")
  64. print("| in the beginning |")
  65. print("|----------------------|")
  66. if cur == 1 then
  67. term.setCursorPos(1,7)
  68. print(""..cursor..""..w1.."")
  69. else
  70. term.setCursorPos(1,7)
  71. print(w1)
  72. end
  73. if cur == 2 then
  74. term.setCursorPos(1,8)
  75. print(""..cursor..""..w2.."")
  76. else
  77. term.setCursorPos(1,8)
  78. print(w2)
  79. end
  80. if cur == 3 then
  81. term.setCursorPos(1,9)
  82. print(""..cursor..""..w3.."")
  83. else
  84. term.setCursorPos(1,9)
  85. print(w3)
  86. end
  87. if cur == 4 then
  88. term.setCursorPos(1,10)
  89. print(""..cursor..""..w4.."")
  90. else
  91. term.setCursorPos(1,10)
  92. print(w4)
  93. end
  94. end
  95.  
  96. function runMineBook()
  97. loadRandomCrap2()
  98. while true do
  99. event, param1 = os.pullEvent()
  100. if event == "key" and param1 == 200 then
  101. if cur == min then
  102. cur = max
  103. loadRandomCrap2()
  104. else
  105. cur = cur-1
  106. loadRandomCrap2()
  107. end
  108. elseif event == "key" and param1 == 208 then
  109. if cur == max then
  110. cur = min
  111. loadRandomCrap2()
  112. else
  113. cur = cur+1
  114. loadRandomCrap2()
  115. end
  116. elseif event == "key" and param1 == 28 then
  117. doThings2()
  118. end
  119. end
  120. end
  121.  
  122. runMineBook()
  123. end
  124.  
  125. function split(str, pat)
  126. local t = { }
  127. local fpat = "(.-)"..pat
  128. local last_end = 1
  129. local s, e, cap = str:find(fpat, 1)
  130. while s do
  131. if s ~= 1 or cap ~= "" then
  132. table.insert(t,cap)
  133. end
  134. last_end = e+1
  135. s, e, cap = str:find(fpat, last_end)
  136. end
  137. if last_end <= #str then
  138. cap = str:sub(last_end)
  139. table.insert(t, cap)
  140. end
  141. return t
  142. end
  143.  
  144. min = 1
  145. max = 4
  146. cur = min
  147.  
  148. function makeUser()
  149. shell.run("clear")
  150. term.write("ENTER DESIRED USERNAME: ")
  151. term.setCursorPos(1,3)
  152. term.write("ENTER DESIRED PASSWORD: ")
  153. term.setCursorPos(1,5)
  154. term.write("RE-ENTER DESIRED PASSWORD: ")
  155. term.setCursorPos(26,1)
  156. dusrnm = read()
  157. term.setCursorPos(26,3)
  158. dpw = read("*")
  159. term.setCursorPos(29,5)
  160. rdpw = read("*")
  161. if dpw == rdpw then
  162. y = dusrnm.."!SP!"..dpw
  163. rednet.send(35, y)
  164. id2, msg2, d2 = rednet.receive()
  165. testLogInTwo()
  166. else
  167. shell.run("clear")
  168. print("PASSWORDS DO NOT MATCH")
  169. end
  170. end
  171.  
  172. function logIn()
  173. shell.run("clear")
  174. term.write("ENTER USERNAME: ")
  175. term.setCursorPos(1,3)
  176. term.write("ENTER PASSWORD: ")
  177. term.setCursorPos(17,1)
  178. usrnm = read()
  179. term.setCursorPos(17,3)
  180. pswrd = read("*")
  181. x = usrnm.."!SP!"..pswrd
  182. rednet.send(34, x)
  183. id1, msg1, d1 = rednet.receive()
  184. if msg1 == "YOU HAVE BEEN LOGGED IN" then
  185. crntname = usrnm
  186. testLogIn()
  187. end
  188. testLogIn()
  189. end
  190.  
  191. term.setCursorBlink(false)
  192.  
  193. cursor = "=> "
  194.  
  195. s1 = "Log In"
  196. s2 = "Make Account"
  197. s3 = "Open Rednet Ports"
  198. s4 = "Exit"
  199.  
  200. function doThings()
  201. if cur == 4 then
  202. os.reboot()
  203. elseif cur == 3 then
  204. OpenAll()
  205. loadRandomCrap()
  206. elseif cur == 1 then
  207. logIn()
  208. elseif cur == 2 then
  209. makeUser()
  210. loadRandomCrap()
  211. end
  212. end
  213.  
  214.  
  215. function loadRandomCrap()
  216. OpenAll()
  217. term.clear()
  218. term.setCursorPos(1,1)
  219. print("|----------------------|")
  220. print("| MineBook 1.0 |")
  221. print("| in the beginning |")
  222. print("|----------------------|")
  223. if cur == 1 then
  224. term.setCursorPos(1,7)
  225. print(""..cursor..""..s1.."")
  226. else
  227. term.setCursorPos(1,7)
  228. print(s1)
  229. end
  230. if cur == 2 then
  231. term.setCursorPos(1,8)
  232. print(""..cursor..""..s2.."")
  233. else
  234. term.setCursorPos(1,8)
  235. print(s2)
  236. end
  237. if cur == 3 then
  238. term.setCursorPos(1,9)
  239. print(""..cursor..""..s3.."")
  240. else
  241. term.setCursorPos(1,9)
  242. print(s3)
  243. end
  244. if cur == 4 then
  245. term.setCursorPos(1,10)
  246. print(""..cursor..""..s4.."")
  247. else
  248. term.setCursorPos(1,10)
  249. print(s4)
  250. end
  251. end
  252.  
  253. function runProgram()
  254. min = 1
  255. max = 4
  256. cur = min
  257. loadRandomCrap()
  258. while true do
  259. event, param1 = os.pullEvent()
  260. if event == "key" and param1 == 200 then
  261. if cur == min then
  262. cur = max
  263. loadRandomCrap()
  264. else
  265. cur = cur-1
  266. loadRandomCrap()
  267. end
  268. elseif event == "key" and param1 == 208 then
  269. if cur == max then
  270. cur = min
  271. loadRandomCrap()
  272. else
  273. cur = cur+1
  274. loadRandomCrap()
  275. end
  276. elseif event == "key" and param1 == 28 then
  277. if cur == 4 then
  278. break()
  279. else
  280. doThings()
  281. end
  282. end
  283. end
  284. end
  285.  
  286. runProgram()
Add Comment
Please, Sign In to add comment