Advertisement
Guest User

skype

a guest
Aug 28th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.69 KB | None | 0 0
  1. --Variables
  2.  
  3. thisUser = tostring(accN)
  4. thisPass = tostring(accP)  --Set up pass on other program
  5.  
  6. name = "Skype"
  7. ver = "Alpha 1.6"
  8. local muT = "Username: " --menu username text
  9. local mpT = "Password: " --menu password text
  10. w,h = term.getSize()
  11. id = os.getComputerID()
  12. yPos = 4
  13. rXpos = 1 -- When receiving messages
  14. sXpos = w -- When sending them
  15.  
  16.  
  17.  
  18. --Tables
  19. local nathan = {62; "12/9/15";} --id, setupdate
  20. local sean = {63; "12/9/15";} --id, setupdate
  21.  
  22. --Functions
  23.  
  24. local function drawTb()
  25.   term.setCursorPos(1,1)
  26.   term.setTextColor(1)
  27.   term.setBackgroundColor(colors.blue)
  28.   term.clearLine()
  29.   print(name)
  30.   term.setCursorPos(math.floor(w)-#ver,1)
  31.   print(ver)
  32. end
  33.  
  34. local function bground()
  35.   term.setCursorPos(1,1)
  36.   term.setBackgroundColor(1)
  37.   term.clear()
  38.   term.setCursorPos(22,2)
  39.   term.setTextColor(colors.red)
  40.   print("MESSAGES")
  41. end
  42.  
  43. local function listen()
  44.   term.setBackgroundColor(1)
  45.   term.setTextColor(colors.red)
  46.   term.setCursorPos(1,yPos)
  47.    while true do
  48.      id, message = rednet.receive()
  49.       if id == 63 then
  50.         sender = "Sean"
  51.         term.setTextColor(colors.cyan)
  52.         term.setCursorPos(rXpos,yPos)
  53.         yPos = yPos + 1
  54.         print("<"..sender.."> "..message)
  55.      elseif id == 62 then
  56.         sender = "Nathan"
  57.         term.setTextColor(colors.orange)
  58.         term.setCursorPos(rXpos,yPos)
  59.         yPos = yPos + 1
  60.         print("<"..sender.."> "..message)
  61.       end
  62.     end  -- could insert userMessage() here?  
  63. end
  64.  
  65. local function textBar()
  66.   term.setCursorPos(1,18)
  67.   term.setBackgroundColor(colors.lightBlue)
  68.   term.clearLine()
  69.   term.setTextColor(colors.green)
  70. end
  71.  
  72. local function userMessage()
  73. while true do
  74.   textBar()-- change this to term.setCursorPos(1,18)
  75.   term.setCursorPos(1,18)
  76.   term.clearLine()
  77.   term.write(">")
  78.   term.setCursorPos(2,18)
  79.   uMessage = read()
  80.   rednet.send(63,uMessage)
  81.   rednet.send(62,uMessage)
  82.     term.setCursorPos(math.floor(w)-#uMessage,yPos)
  83.     yPos = yPos + 1
  84.     term.setTextColor(colors.purple)
  85.     term.setBackgroundColor(colors.white)
  86.     print(uMessage)
  87. end
  88. end
  89.  
  90. local function login()
  91.   term.setTextColor(1)
  92.   term.setBackgroundColor(colors.cyan)
  93.   term.setCursorPos(w/2-#muT,(h/2)-3)
  94.   term.clear()
  95.    term.write("Username: ")
  96.    local input1 = read()
  97.    term.setCursorPos(w/2-#mpT,(h/2)+1)
  98.    term.write("Password: ")
  99.    local input2 = read("*")
  100.      if input1 == thisUser and input2 == thisPass then
  101.         bground()
  102.         drawTb()
  103.      else
  104.        login()
  105.     end
  106. end
  107.  
  108. --Main code
  109.  
  110. login()
  111. rednet.open("top")
  112. --bground()         --These lines are in use
  113. --drawTb()          --These lines are in use
  114. textBar()
  115. --listen()
  116. userMessage()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement