Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bexit = false
- id = os.getComputerID()
- x,y = term.getSize()
- i=3
- local function openRednet()
- for _,side in pairs(rs.getSides()) do
- if peripheral.isPresent(side) and peripheral.getType(side) == 'modem' then
- rednet.open(side)
- return(side)
- end
- end
- print("No modem present!")
- end
- function slow(text,h)
- w = math.floor((x-string.len(text))/2)
- term.setCursorPos(w,h)
- textutils.slowPrint(text)
- end
- function intro()
- term.setTextColor(colors.red)
- term.setBackgroundColor(colors.yellow)
- slow("# # # # # #### # #",3)
- slow("# # # # # # ## ##",4)
- slow(" ## ## # ## # # #",5)
- slow("# # ## # # # #",6)
- slow("# # ## #### #### # #",7)
- term.setTextColor(colors.green)
- slow("Crypochat",9)
- term.setBackgroundColor(colors.black)
- end
- function drawTab()
- term.setTextColor(colors.yellow)
- --clear()
- term.setCursorPos(1,1)
- term.clearLine()
- print("Computer ID "..id)
- term.setCursorPos(x-string.len("type 'help' for help"),1)
- print("type 'help' for help")
- term.setCursorPos(1,2)
- term.clearLine()
- print("__________________________________________________")
- term.setCursorPos(1,y-3)
- term.clearLine()
- print("__________________________________________________")
- term.setTextColor(colors.white)
- end
- function clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function help()
- end
- function idfunc()
- end
- function clear2()
- end
- function input()
- term.setTextColor(colors.white)
- term.setCursorPos(1,y-1)
- local message2 = read()
- term.setCursorPos(1,y-1)
- term.clearLine()
- if message2 == "help" then
- help()
- elseif message2 == "exit" then
- bexit = true
- else
- --term.setTextColor(colors.green)
- win("Me: "..message2)
- rednet.broadcast(tostring(id),message2)
- --term.setTextColor(colors.white)
- end
- end
- function win(text)
- if i > y-5 or i==y-5 then
- term.setCursorPos(1,y-3)
- term.clearLine()
- term.setCursorPos(1,4)
- term.clearLine()
- term.scroll(1)
- drawTab()
- term.setCursorPos(1,y-5)
- print(text)
- else
- term.setCursorPos(1,1+i)
- print(text)
- i = i+1
- end
- end
- modemSide = openRednet()
- if modemSide == nil then
- print("No modem connected")
- else
- print("Opened modem on "..modemSide.."!")
- end
- --Introduction
- term.clear()
- term.setCursorPos(1,1)
- if modemSide ~= nil then
- --intro()
- term.setCursorPos(1,11)
- print(βWhat is the id of you partner?β)
- id2=io.read()
- print("Press any key to continue")
- key = os.pullEvent("key")
- while key == nil do
- sleep(0.1)
- end
- clear()
- while bexit == false do
- local timer = os.startTimer(.25) --.25s
- local event, senderid, message, distance
- repeat
- event, senderid, message, distance = os.pullEvent()
- until event ~= "timer" or timer == senderid
- if event == "timer" then
- drawTab()
- input()
- elseif event == "rednet_message" then
- win(id2..β: "..message)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement