Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local serverid = 559
- local sessionName = ""
- local sessionData = {}
- function verify()
- rednet.open("bottom")
- rednet.send(serverid, ":verify")
- local id, msg = rednet.receive(2)
- if id~=nil then
- return true
- end
- return false
- end
- function isUser(name)
- rednet.open("bottom")
- rednet.send(serverid, ":user")
- rednet.receive(2)
- rednet.send(serverid, name)
- local id, msg = rednet.receive(2)
- if id~=nil then
- return msg
- end
- return nil
- end
- function getUserData(name)
- rednet.open("bottom")
- rednet.send(serverid, ":data")
- rednet.receive(2)
- rednet.send(serverid, name)
- local id, msg = rednet.receive(2)
- sessionData = textutils.unserialize(msg)
- end
- function session()
- print("Please enter your name:")
- sessionName = read()
- print("Please wait...")
- local data = isUser(sessionName)
- if data ~= nil then
- if data == ":newUser" then
- print("Welcome to the shooting range!")
- else
- print("Welcome back "..sessionName.."!")
- end
- else
- return
- end
- getUserData(sessionName)
- print("Your highscore is: "..sessionData.highscore)
- end
- function main()
- print("Welcome!")
- print("Please wait...")
- if not verify() then
- print("Make sure the computer on the back is on.")
- end
- while not verify() do
- sleep(1)
- end
- session()
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement