Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function drawBoard(b)
- clear()
- write(b[1])
- write("|")
- write(b[2])
- write("|")
- print(b[3])
- print("-----")
- write(b[4])
- write("|")
- write(b[5])
- write("|")
- print(b[6])
- print("-----")
- write(b[7])
- write("|")
- write(b[8])
- write("|")
- print(b[9])
- end
- function fromID(id)
- while true do
- local tid, msg=rednet.receive()
- if tid == id then
- return msg
- end
- end
- end
- clear()
- print("ID:"..os.getComputerID())
- write("Server ID:")
- local server=read()+0
- write("Rednet side:")
- rednet.open(read())
- board={}
- for i=1,9 do
- board[i]=" "
- end
- stat=""
- while true do
- clear()
- drawBoard(board)
- act=fromID(server)
- if act=="start" then
- print("Start!")
- else if act=="win" then
- print("You win!")
- sleep(5)
- break
- else if act=="lose" then
- print("You lose!")
- sleep(5)
- break
- else if act=="Play" then
- print("Whats your play?")
- rednet.send(server,read())
- else if act=="Place" then
- board[(fromID(server)+0)]=fromID(server)
- else
- print("Error")
- sleep(5)
- os.reboot()
- end
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment