Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --CONFIGURATION
- server = 2 -- put the server's computer id here
- cursor = "<> " -- this is the cursor for the welcome screen
- cursor2 = "<> " -- this is the cursor for the actual Minebook
- maxUserNameLength = 10 --The max ammount of charecters allowed in a username
- 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
- -- |----------------------|
- -- | RedBook 1.2 |
- -- | Updates Coming Soon |
- -- |----------------------|
- -- Banner Template ^
- --Do not touch anything below this unless you know what you are doing
- function uploadScript()
- shell.run("clear")
- print("Pick a file to upload")
- sApp = read()
- if fs.exists(sApp) then
- fProgram = fs.open(sApp, "r")
- program = fProgram.readAll()
- fProgram.close()
- s = crntname.."!SP!uploadScript!SP!"..sApp.."!SP!"..program
- rednet.send(server, s)
- id, msg, d = rednet.receive(2)
- if msg ~= nil then
- print(msg)
- os.sleep(2)
- end
- loadRandomCrap2()
- else
- shell.run("clear")
- print("NOT A PROGRAM")
- loadRandomCrap2()
- end
- end
- function browseScripts()
- hj = crntname.."!SP!downloadScript!SP!"..browseScripts
- rednet.send(server, hj)
- id, msg, d = rednet.receive(2)
- if msg == nil then
- shell.run("Clear")
- print("SERVER ERROR")
- os.sleep(2)
- else
- t = textutils.unserialize(msg)
- shell.run("clear")
- textutils.tabulate(t)
- print("")
- print("Pick a software to download. If you dont want to download anything then type none")
- print("")
- term.write("Enter software: ")
- app = read()
- if app ~= "none" then
- p = crntname.."!SP!downloadScript!SP!"..app
- rednet.send(server, p)
- end
- end
- loadRandomCrap2()
- end
- 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
- pickNewBanner()
- mineBook()
- else
- pickNewBanner()
- loadRandomCrap()
- end
- end
- function errorQuit()
- a = jkfdls+fjdsjfal
- print(a)
- end
- function searchUser()
- shell.run("clear")
- term.write("ENTER USER: ")
- user2 = read()
- if user2 ~= crntname then
- sndsrch = crntname.."!SP!search!SP!"..user2
- rednet.send(server, sndsrch)
- id3, msg3, d3 = rednet.receive(5)
- if msg3 ~= nil then
- srch = split(msg3, "!SP!")
- nuser = srch[1]
- nstatus = srch[2]
- nfriends = srch[3]
- if nstatus == nil then
- nstatus = ""
- end
- shell.run("clear")
- print("|||||||||||||||||||||||||||")
- print("|| ||")
- print("|| USER SEARCH RESULTS ||")
- print("|| ||")
- print("|||||||||||||||||||||||||||")
- print("")
- print("")
- print("User Name: "..nuser)
- print("")
- print("Status: "..nstatus)
- print("")
- print("")
- print("PRESS S TO SEND FRIEND REQUEST OR E TO EXIT")
- while true do
- event9, param9 = os.pullEvent()
- if event9 == "key" and param9 == 31 and nuser then
- sndmsg = crntname.."!SP!sndfrq!SP!"..nuser
- shell.run("clear")
- rednet.send(server, sndmsg)
- id8, msg8, d8 = rednet.receive(1)
- if msg8 == nil then
- print("REQUEST SENT")
- read()
- pickNewBanner()
- loadRandomCrap2()
- break
- else
- print("YOU ARE ALREADY FRIENDS WITH THIS PERSON")
- read()
- pickNewBanner()
- loadRandomCrap2()
- break
- end
- elseif event9 == "key" and param9 == 18 then
- pickNewBanner()
- loadRandomCrap2()
- break
- end
- end
- else
- shell.run("clear")
- print("SERVER ERROR")
- read()
- pickNewBanner()
- loadRandomCrap2()
- end
- else
- shell.run("clear")
- print("YOU CAN NOT SEARCH YOURSELF")
- sleep(1)
- pickNewBanner()
- loadRandomCrap2()
- end
- end
- function prntFrq()
- shell.run("clear")
- print("FRIEND REQUESTS")
- print("")
- print(frq[gcur])
- print("")
- print("PRESS A TO ACCEPT OR D TO DECLINE")
- end
- function printFrndReq()
- gcur = 1
- prntFrq()
- while true do
- event2, param2 = os.pullEvent()
- if event2 == "key" and param2 == 30 then
- shell.run("clear")
- print("USER ADDED")
- ju = crntname.."!SP!add friend!SP!"..frq[gcur]
- rednet.send(server, ju)
- gcur = gcur+1
- read()
- if gcur > gmax then
- loadRandomCrap2()
- break
- else
- prntFrq()
- end
- elseif event2 == "key" and param2 == 32 then
- shell.run("clear")
- print("USER DECLINED")
- gcur = gcur+1
- read()
- if gcur > gmax then
- pickNewBanner()
- loadRandomCrap2()
- break
- else
- prntFrq()
- end
- end
- end
- end
- function checkFrndReq()
- jk = crntname.."!SP!chck frnd req"
- rednet.send(server, jk)
- id, msg, d = rednet.receive(5)
- if msg ~= nil then
- frq = split(msg, "!SP!")
- gmax = #frq
- gmin = 1
- if gmax >= gmin then
- shell.run("clear")
- printFrndReq()
- else
- shell.run("clear")
- print("NO NEW REQUESTS")
- read()
- end
- loadRandomCrap2()
- end
- end
- function updateStatus()
- shell.run("clear")
- stat = read()
- h = crntname.."!SP!status update!SP!"..stat
- rednet.send(server, h)
- g = fs.open("MINEBOOK/STATUS", "w")
- g.write(stat)
- g.close()
- end
- function listFriends()
- y = "list"
- x = crntname.."!SP!"..y
- rednet.send(server, 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()
- w1 = "Search"
- w2 = "Change Status"
- w3 = "Friends"
- w4 = "Check Friend Request"
- w5 = "Upload a Script"
- w6 = "Browse Scripts"
- w7 = "Exit"
- min = 1
- max = 7
- cur = min
- function doThings2()
- if cur == 3 then
- listFriends()
- elseif cur == 4 then
- checkFrndReq()
- elseif cur == 1 then
- searchUser()
- elseif cur == 2 then
- updateStatus()
- pickNewBanner()
- loadRandomCrap2()
- elseif cur == 5 then
- uploadScript()
- elseif cur == 6 then
- browseScripts()
- 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("| RedBook 1.2 |")
- print(banners[curBanner])
- print("|----------------------|")
- print("")
- print("")
- print("STATUS: "..ju)
- if cur == 1 then
- term.setCursorPos(1,11)
- print(""..cursor2..""..w1.."")
- else
- term.setCursorPos(1,11)
- print(w1)
- end
- if cur == 2 then
- term.setCursorPos(1,12)
- print(""..cursor2..""..w2.."")
- else
- term.setCursorPos(1,12)
- print(w2)
- end
- if cur == 3 then
- term.setCursorPos(1,13)
- print(""..cursor2..""..w3.."")
- else
- term.setCursorPos(1,13)
- print(w3)
- end
- if cur == 4 then
- term.setCursorPos(1,14)
- print(""..cursor2..""..w4.."")
- else
- term.setCursorPos(1,14)
- print(w4)
- end
- if cur == 5 then
- term.setCursorPos(1,15)
- print(""..cursor2..""..w5.."")
- else
- term.setCursorPos(1,15)
- print(w5)
- end
- if cur == 6 then
- term.setCursorPos(1,16)
- print(""..cursor2..""..w6.."")
- else
- term.setCursorPos(1,16)
- print(w6)
- end
- if cur == 7 then
- term.setCursorPos(1,17)
- print(""..cursor2..""..w7.."")
- else
- term.setCursorPos(1,17)
- print(w7)
- 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 == 7 then
- shell.run("clear")
- min = 1
- max = 4
- cur = min
- pickNewBanner()
- 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
- if #dusrnm <= maxUserNameLength then
- y = dusrnm.."!SP!makeUser!SP!"..dpw
- rednet.send(server, y)
- id2, msg2, d2 = rednet.receive(1)
- if msg2 == nil then
- shell.run("clear")
- print("SERVER ERROR")
- read()
- loadRandomCrap()
- else
- username = dusrnm
- rednet.send(server, username.."!SP!status update!SP!DEFAULT STATUS")
- testLogInTwo()
- end
- else
- shell.run("clear")
- print("USERNAME IS TOO LONG")
- read()
- 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!logIn!SP!"..pswrd
- rednet.send(server, x)
- id1, msg1, d1 = rednet.receive(1)
- if msg1 == nil then
- shell.run("clear")
- print("SERVER ERROR")
- read()
- loadRandomCrap()
- 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 = "Change Banner"
- s4 = "Exit"
- function doThings()
- if cur == 3 then
- pickNewBanner()
- loadRandomCrap()
- elseif cur == 1 then
- logIn()
- elseif cur == 2 then
- makeUser()
- pickNewBanner()
- loadRandomCrap()
- end
- end
- function pickNewBanner()
- maxBannerNumber = #banners
- curBanner = math.random(maxBannerNumber)
- end
- function loadRandomCrap()
- OpenAll()
- term.clear()
- term.setCursorPos(1,1)
- print("|----------------------|")
- print("| RedBook 1.2 |")
- print(banners[curBanner])
- 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
- pickNewBanner()
- runProgram()
Add Comment
Please, Sign In to add comment