Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function testLogIn()
- shell.run("clear")
- if msg1 == "YOU HAVE BEEN LOGGED IN" then
- print(msg1..": "..crntname)
- term.setCursorBlink(false)
- read()
- else
- print(msg1)
- term.setCursorBlink(false)
- read()
- end
- if msg1 == "YOU HAVE BEEN LOGGED IN" then
- mineBook()
- else
- loadRandomCrap()
- end
- end
- function errorQuit()
- a = jkfdls+fjdsjfal
- print(a)
- end
- function printFrndReq()
- print("FRIEND REQUESTS (If blank then there are no friend requests)")
- print("")
- print(rq[tsel])
- print("")
- print("PRESS A TO ACCEPT OR D TO DECLINE")
- function checkFrndReq()
- gu = crntname.."!SP!chck frnd req"
- rednet.send(37, gu)
- id, msg, d = rednet.receive(5) --27
- if msg ~= nil then
- rq = split(msg, "!SP!")
- shell.run("clear")
- ordr = #rq
- if ordr > 0 then
- tsel = 1
- while true do
- evnt, parm = os.pullEvent()
- if evnt == "key" and parm == 30 then
- sndcnfrm = crntname.."!SP!add friend"!SP!"..rg[tsel]
- rednet.send(37, sndcnfrm)
- tsel = tsel+1
- if tsel > ordr then
- loadRandomCrap2()
- break
- else
- printFrndReq()
- end
- elseif evnt == "key" and parm == 32 then
- tsel = tsel+1
- if tsel > ordr then
- loadRandomCrap2()
- break
- else
- printFrndReq()
- end
- end
- end
- else
- loadRandomCrap2()
- end
- end
- end
- function updateStatus()
- shell.run("clear")
- stat = read()
- h = crntname.."!SP!status update!SP!"..stat
- rednet.send(37, h)
- g = fs.open("MINEBOOK/STATUS", "w")
- g.write(stat)
- g.close()
- end
- function listFriends()
- y = "list"
- x = crntname.."!SP!"..y
- rednet.send(37, x)
- id, msg, d = rednet.receive(4)
- if msg == nil then
- shell.run("clear")
- print("ERROR")
- read()
- loadRandomCrap2()
- else
- shell.run("clear")
- r = split(msg, "!SP!")
- print("FRIEND LIST")
- textutils.tabulate(r)
- read()
- loadRandomCrap2()
- end
- end
- function testLogInTwo()
- shell.run("clear")
- print(msg2)
- term.setCursorBlink(false)
- read()
- end
- function OpenAll()
- for _,side in ipairs(rs.getSides()) do
- rednet.open(side)
- end
- end
- function mineBook()
- cursor = ">> "
- w1 = "Search"
- w2 = "Change Status"
- w3 = "Friends"
- w4 = "Check Friend Request"
- w5 = "Exit"
- min = 1
- max = 5
- cur = min
- function doThings2()
- if cur == 3 then
- listFriends()
- elseif cur == 4 then
- checkFrndReq()
- elseif cur == 1 then
- logIn()
- elseif cur == 2 then
- updateStatus()
- loadRandomCrap2()
- end
- end
- function loadRandomCrap2()
- OpenAll()
- term.clear()
- term.setCursorPos(1,1)
- y = fs.open("MINEBOOK/STATUS", "a")
- y.close()
- l = fs.open("MINEBOOK/STATUS", "r")
- ju = l.readAll()
- crntstatus = ju
- print("|----------------------| WELLCOME: "..crntname)
- print("| MineBook 1.0 |")
- print("| in the beginning |")
- print("|----------------------|")
- print("")
- print("STATUS: "..ju)
- if cur == 1 then
- term.setCursorPos(1,9)
- print(""..cursor..""..w1.."")
- else
- term.setCursorPos(1,9)
- print(w1)
- end
- if cur == 2 then
- term.setCursorPos(1,10)
- print(""..cursor..""..w2.."")
- else
- term.setCursorPos(1,10)
- print(w2)
- end
- if cur == 3 then
- term.setCursorPos(1,11)
- print(""..cursor..""..w3.."")
- else
- term.setCursorPos(1,11)
- print(w3)
- end
- if cur == 4 then
- term.setCursorPos(1,12)
- print(""..cursor..""..w4.."")
- else
- term.setCursorPos(1,12)
- print(w4)
- end
- if cur == 5 then
- term.setCursorPos(1,13)
- print(""..cursor..""..w5.."")
- else
- term.setCursorPos(1,13)
- print(w5)
- end
- end
- function runMineBook()
- loadRandomCrap2()
- while true do
- event, param1 = os.pullEvent()
- if event == "key" and param1 == 200 then
- if cur == min then
- cur = max
- loadRandomCrap2()
- else
- cur = cur-1
- loadRandomCrap2()
- end
- elseif event == "key" and param1 == 208 then
- if cur == max then
- cur = min
- loadRandomCrap2()
- else
- cur = cur+1
- loadRandomCrap2()
- end
- elseif event == "key" and param1 == 28 then
- if cur == 5 then
- shell.run("clear")
- min = 1
- max = 4
- cur = min
- loadRandomCrap()
- break
- end
- doThings2()
- end
- end
- end
- runMineBook()
- end
- function split(str, pat)
- local t = { }
- local fpat = "(.-)"..pat
- local last_end = 1
- local s, e, cap = str:find(fpat, 1)
- while s do
- if s ~= 1 or cap ~= "" then
- table.insert(t,cap)
- end
- last_end = e+1
- s, e, cap = str:find(fpat, last_end)
- end
- if last_end <= #str then
- cap = str:sub(last_end)
- table.insert(t, cap)
- end
- return t
- end
- min = 1
- max = 4
- cur = min
- function makeUser()
- shell.run("clear")
- term.write("ENTER DESIRED USERNAME: ")
- term.setCursorPos(1,3)
- term.write("ENTER DESIRED PASSWORD: ")
- term.setCursorPos(1,5)
- term.write("RE-ENTER DESIRED PASSWORD: ")
- term.setCursorPos(26,1)
- dusrnm = read()
- term.setCursorPos(26,3)
- dpw = read("*")
- term.setCursorPos(29,5)
- rdpw = read("*")
- if dpw == rdpw then
- y = dusrnm.."!SP!"..dpw
- rednet.send(35, y)
- id2, msg2, d2 = rednet.receive(1)
- if msg2 == nil then
- shell.run("clear")
- print("SERVER ERROR")
- read()
- runProgram()
- else
- testLogInTwo()
- end
- else
- shell.run("clear")
- print("PASSWORDS DO NOT MATCH")
- read()
- end
- end
- function logIn()
- shell.run("clear")
- term.write("ENTER USERNAME: ")
- term.setCursorPos(1,3)
- term.write("ENTER PASSWORD: ")
- term.setCursorPos(17,1)
- usrnm = read()
- term.setCursorPos(17,3)
- pswrd = read("*")
- x = usrnm.."!SP!"..pswrd
- rednet.send(34, x)
- id1, msg1, d1 = rednet.receive(1)
- if msg1 == nil then
- shell.run("clear")
- print("SERVER ERROR")
- read()
- runProgram()
- else
- if msg1 == "YOU HAVE BEEN LOGGED IN" then
- crntname = usrnm
- testLogIn()
- else
- testLogIn()
- end
- end
- end
- term.setCursorBlink(false)
- cursor = "=> "
- s1 = "Log In"
- s2 = "Make Account"
- s3 = "Open Rednet Ports"
- s4 = "Exit"
- function doThings()
- if cur == 3 then
- OpenAll()
- loadRandomCrap()
- elseif cur == 1 then
- logIn()
- elseif cur == 2 then
- makeUser()
- loadRandomCrap()
- end
- end
- function loadRandomCrap()
- cursor = "=> "
- OpenAll()
- term.clear()
- term.setCursorPos(1,1)
- print("|----------------------|")
- print("| MineBook 1.0 |")
- print("| in the beginning |")
- print("|----------------------|")
- if cur == 1 then
- term.setCursorPos(1,7)
- print(""..cursor..""..s1.."")
- else
- term.setCursorPos(1,7)
- print(s1)
- end
- if cur == 2 then
- term.setCursorPos(1,8)
- print(""..cursor..""..s2.."")
- else
- term.setCursorPos(1,8)
- print(s2)
- end
- if cur == 3 then
- term.setCursorPos(1,9)
- print(""..cursor..""..s3.."")
- else
- term.setCursorPos(1,9)
- print(s3)
- end
- if cur == 4 then
- term.setCursorPos(1,10)
- print(""..cursor..""..s4.."")
- else
- term.setCursorPos(1,10)
- print(s4)
- end
- end
- function runProgram()
- fs.makeDir("MINEBOOK")
- min = 1
- max = 4
- cur = min
- loadRandomCrap()
- while true do
- event, param1 = os.pullEvent()
- if event == "key" and param1 == 200 then
- if cur == min then
- cur = max
- loadRandomCrap()
- else
- cur = cur-1
- loadRandomCrap()
- end
- elseif event == "key" and param1 == 208 then
- if cur == max then
- cur = min
- loadRandomCrap()
- else
- cur = cur+1
- loadRandomCrap()
- end
- elseif event == "key" and param1 == 28 then
- if cur == 4 then
- break
- end
- doThings()
- end
- end
- end
- fs.makeDir("MINEBOOK")
- runProgram()
Add Comment
Please, Sign In to add comment