Advertisement
Xylem_Gaming

Test1

Sep 10th, 2015
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1. bexit = false
  2. id = os.getComputerID()
  3. x,y = term.getSize()
  4. i=3
  5.  
  6. local function openRednet()
  7. for _,side in pairs(rs.getSides()) do
  8. if peripheral.isPresent(side) and peripheral.getType(side) == 'modem' then
  9. rednet.open(side)
  10. return(side)
  11. end
  12. end
  13. print("No modem present!")
  14. end
  15.  
  16. function slow(text,h)
  17. w = math.floor((x-string.len(text))/2)
  18. term.setCursorPos(w,h)
  19. textutils.slowPrint(text)
  20. end
  21.  
  22. function intro()
  23. term.setTextColor(colors.red)
  24. term.setBackgroundColor(colors.yellow)
  25. slow("# # # # # #### # #",3)
  26. slow("# # # # # # ## ##",4)
  27. slow(" ## ## # ## # # #",5)
  28. slow("# # ## # # # #",6)
  29. slow("# # ## #### #### # #",7)
  30. term.setTextColor(colors.green)
  31. slow("Crypochat",9)
  32. term.setBackgroundColor(colors.black)
  33. end
  34.  
  35. function drawTab()
  36. term.setTextColor(colors.yellow)
  37. --clear()
  38. term.setCursorPos(1,1)
  39. term.clearLine()
  40. print("Computer ID "..id)
  41. term.setCursorPos(x-string.len("type 'help' for help"),1)
  42. print("type 'help' for help")
  43. term.setCursorPos(1,2)
  44. term.clearLine()
  45. print("__________________________________________________")
  46. term.setCursorPos(1,y-3)
  47. term.clearLine()
  48. print("__________________________________________________")
  49. term.setTextColor(colors.white)
  50. end
  51.  
  52. function clear()
  53. term.clear()
  54. term.setCursorPos(1,1)
  55. end
  56.  
  57. function help()
  58. end
  59. function idfunc()
  60. end
  61. function clear2()
  62. end
  63. function input()
  64. term.setTextColor(colors.white)
  65. term.setCursorPos(1,y-1)
  66. local message2 = read()
  67. term.setCursorPos(1,y-1)
  68. term.clearLine()
  69. if message2 == "help" then
  70. help()
  71. elseif message2 == "exit" then
  72. bexit = true
  73. else
  74. --term.setTextColor(colors.green)
  75. win("Me: "..message2)
  76. rednet.broadcast(tostring(id),message2)
  77. --term.setTextColor(colors.white)
  78. end
  79. end
  80.  
  81. function win(text)
  82. if i > y-5 or i==y-5 then
  83. term.setCursorPos(1,y-3)
  84. term.clearLine()
  85. term.setCursorPos(1,4)
  86. term.clearLine()
  87. term.scroll(1)
  88. drawTab()
  89. term.setCursorPos(1,y-5)
  90. print(text)
  91. else
  92. term.setCursorPos(1,1+i)
  93. print(text)
  94. i = i+1
  95. end
  96.  
  97. end
  98.  
  99. modemSide = openRednet()
  100. if modemSide == nil then
  101. print("No modem connected")
  102. else
  103. print("Opened modem on "..modemSide.."!")
  104. end
  105.  
  106. --Introduction
  107. term.clear()
  108. term.setCursorPos(1,1)
  109.  
  110. if modemSide ~= nil then
  111.  
  112. --intro()
  113. term.setCursorPos(1,11)
  114. print(β€œWhat is the id of you partner?”)
  115. id2=io.read()
  116. print("Press any key to continue")
  117. key = os.pullEvent("key")
  118.  
  119. while key == nil do
  120. sleep(0.1)
  121. end
  122. clear()
  123. while bexit == false do
  124.  
  125. local timer = os.startTimer(.25) --.25s
  126. local event, senderid, message, distance
  127.  
  128. repeat
  129. event, senderid, message, distance = os.pullEvent()
  130. until event ~= "timer" or timer == senderid
  131. if event == "timer" then
  132. drawTab()
  133. input()
  134. elseif event == "rednet_message" then
  135. win(id2..”: "..message)
  136. end
  137. end
  138. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement