Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local pVersion = 2.0
- local pEdition = "Home"
- local pAuthServer = 25
- local sendersID = os.getComputerID()
- function drawGUI()
- term.clear()
- term.setCursorPos(1,1)
- print("---------------------------------------------------")
- print("- -")
- print("- -")
- print("- -")
- print("- -")
- print("- -")
- print("- -")
- print("- -")
- print("- -")
- print("- -")
- print("- -")
- print("- -")
- print("- -")
- print("- -")
- print("- -")
- print("---------------------------------------------------")
- print("->> <<-")
- print("---------------------------------------------------")
- term.setCursorPos(4,17)
- write("PriestleyOS ")
- write(pEdition)
- write(" ")
- write(pVersion)
- end
- function PP2Receive(packetwait)
- mastID, PP2Packet = rednet.receive("PP2", packetwait)
- sep = "%s"
- t = {}
- i = 1
- for str in string.gmatch(PP2Packet, "([^"..sep.."]+)") do
- t[i] = str
- i = i + 1
- end
- pp2S = #t
- t[1] = tonumber(t[1])
- t[2] = tonumber(t[2])
- if pp2S == 3 then
- return t[1], t[2], t[3]
- end
- outputMessage = ""
- counter = 3
- while counter <= pp2S do
- outputMessage = outputMessage .. t[counter] .. " "
- counter = counter + 1
- end
- return t[1], t[2], outputMessage
- end
- function PP2SendDirect(computerID, destinationID, message)
- createdPacket = computerID .. " " .. destinationID .. " " .. message
- rednet.send(destinationID, createdPacket, "PP2")
- end
- function PP2Send(computerID, destinationID, message)
- createdPacket = computerID .. " " .. destinationID .. " " .. message
- rednet.broadcast(createdPacket, "PP2m")
- end
- function posLogin()
- local serverStatus = false
- local serverResponse = "fail"
- drawGUI()
- while serverStatus == false do
- term.setCursorPos(4,4)
- write("[=======================]")
- term.setCursorPos(4,5)
- write("[ PriestleyOS Login ]")
- term.setCursorPos(4,6)
- write("[=======================]")
- term.setCursorPos(4,7)
- write("[Username: ]")
- term.setCursorPos(4,8)
- write("[Password: ]")
- term.setCursorPos(4,9)
- write("[=======================]")
- term.setCursorPos(4,10)
- write("[Server Status: ]")
- while serverStatus == "fail" do
- PP2SendDirect(sendersID, pAuthServer, "ping")
- sleep(0.2)
- ignore, ignore, serverResponse = PP2Receive(3)
- if serverResponse == "success" then
- term.setCursorPos(4,17)
- write("ONLINE ")
- break
- end
- term.setCursorPos(4,17)
- write("OFFLINE")
- term.setCursorPos(4,12)
- write("Retrying...")
- end
- end
- end
- posLogin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement