Advertisement
metarmask

Chat Program for ComputerCraft

Mar 3rd, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 KB | None | 0 0
  1. -- Programet är skrivet av metarmask
  2.  
  3.  
  4. termX, termY = term.getSize()
  5. term.setBackgroundColor(colors.white)
  6. term.setTextColor(colors.red)
  7. term.clear()
  8. function writeOwner()
  9. term.setCursorPos(termX/2-#"Skrivet av metarmask", termY)
  10. write("Skrivet av ")
  11. term.setTextColor(colors.green)
  12. write("metarmask")
  13. term.setTextColor(colors.red)
  14. end
  15. writeOwner()
  16. term.setCursorPos(termX/2-14,termY/2)
  17. write("Startar: ")
  18. term.setBackgroundColor(colors.red)
  19. textutils.slowWrite(string.rep(" ", 10), 4)
  20. term.setBackgroundColor(colors.white)
  21. write("  Klar! ")
  22. sleep(0.5)
  23. term.clear()
  24. writeOwner()
  25.  
  26. a1dot = "å"
  27. a2dots = "ä"
  28. o2dots = "ö"
  29.  
  30. mon1 = peripheral.wrap("left")
  31. mon2 = peripheral.wrap("bottom")
  32. sModemSide = nil
  33.     for n,sSide in ipairs( rs.getSides() ) do
  34.         if peripheral.getType( sSide ) == "modem" then 
  35.             sModemSide = sSide
  36.             break
  37.         end
  38.     end
  39. if sModemSide == nil then
  40. else
  41. rednet.open(sModemSide)
  42. end
  43. mon1.setTextColor(colors.black)
  44. mon1.setBackgroundColor(colors.yellow)
  45. mon1.clear()
  46. mon2.clear()
  47. mon1.setCursorPos(1,1)
  48. mon2.setCursorPos(2,2)
  49. mon1.setTextScale(2)
  50. mon2.setTextScale(1.5)
  51. mon1.write("Weekly news!")
  52. meddelanden = {}
  53. ids = {}
  54.  
  55. while true do
  56.  
  57. id, meddelande = rednet.receive()
  58. term.clear()
  59. messageLenght = #meddelande
  60. idLenght = #tostring(id)
  61. totalLenght1 = messageLenght + 5
  62. totalLenght2 = idLenght + 22
  63. term.setCursorPos(1,termY/2)
  64. print("Tog emot \""..meddelande.."\" fr"..a1dot.."n dator "..id..".")
  65. print("Antal meddelanden "..a2dots.."r nu "..#meddelanden + 1)
  66. table.insert(ids, id)
  67. table.insert(meddelanden, meddelande)
  68. count = #meddelanden
  69.  
  70. for i=1,#meddelanden do
  71. posY, posX = mon2.getCursorPos()
  72. mon2.clearLine()
  73. mon2.write(ids[count].." "..meddelanden[count])
  74. mon2.setCursorPos(2,posX+2)
  75. count = count - 1
  76. end
  77.  
  78. mon2.setCursorPos(2,2)
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement