Advertisement
AquaJD

[A'sP] AquaClient

Sep 13th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. -- GUI Colors
  2.  
  3. side = "back"
  4. doorSide = "right"
  5. tBarCol = colors.blue
  6. tBarTextCol = colors.white
  7. backColor = colors.white
  8. textColor = colors.blue
  9.  
  10. serverID = 4
  11.  
  12. rednet.open(side)
  13. os.pullEvent = os.pullEventRaw
  14.  
  15. function titleBar()
  16.   term.setTextColor(tBarTextCol)
  17.   term.setBackgroundColor(tBarCol)
  18.   term.setCursorPos(1,1)
  19.   term.clearLine()
  20.   term.setCursorPos(1,1)
  21.   print("[AquaClient] - The Roaming Client")
  22. end
  23.  
  24. function drawBox(x,y,w,h,color)
  25.   mY = y
  26.   term.setCursorPos(x,y)
  27.   term.setBackgroundColor(color)
  28.   for i=1,h do
  29.     term.setCursorPos(x,mY)
  30.     print(string.rep(" ",w))
  31.     mY = mY + 1
  32.   end
  33. end
  34.  
  35. function drawMS()
  36.   term.setBackgroundColor(backColor)
  37.   term.clear()
  38.   drawBox(5,5,42,12,colors.lightBlue)
  39.   term.setCursorPos(6,6)
  40.   print("Password:")
  41.   term.setBackgroundColor(colors.gray)
  42.   term.setCursorPos(6,7)
  43.   print("                  ")
  44.   term.setBackgroundColor(colors.lightBlue)
  45.   term.setCursorPos(6,9)
  46.   print("1. Click on the gray space.")
  47.   term.setCursorPos(6,10)
  48.   print("2. Enter the password.")
  49.   term.setCursorPos(6,11)
  50.   print("3. Wait for a reply.")
  51.  
  52.   titleBar()
  53. end
  54.  
  55. drawMS()
  56. while true do
  57.     local event,button,X,Y = os.pullEvent()
  58.     if event == "mouse_click" then
  59.         if X >=6 and X <=24 and Y==7 and button ==1 then
  60.             term.setBackgroundColor(colors.gray)
  61.             term.setTextColor(colors.white)
  62.             term.setCursorPos(7,7)
  63.             passInput = read("*")
  64.             rednet.send(serverID,passInput)
  65.             local senderID,message,distance = rednet.receive(5)
  66.             if senderID == serverID then
  67.                 if message == "CODE_ACCEPT" then
  68.                     term.setTextColor(colors.green)
  69.                     term.setBackgroundColor(colors.lightBlue)
  70.                     term.setCursorPos(6,13)
  71.                     print("Server responded!")
  72.                     term.setCursorPos(6,14)
  73.                     print("Password accepted!")
  74.                     sleep(1)
  75.                     rs.setOutput(doorSide,true)
  76.                     sleep(3)
  77.                     os.shutdown()
  78.                 elseif message == "CODE_DECLINE" then
  79.                     term.setTextColor(colors.red)
  80.                     term.setBackgroundColor(colors.lightBlue)
  81.                     term.setCursorPos(6,13)
  82.                     print("Server responded!")
  83.                     term.setCursorPos(6,14)
  84.                     print("Password declined!")
  85.                     sleep(3)
  86.                     os.shutdown()
  87.                 end
  88.             else
  89.                 term.setCursorPos(6,13)
  90.                 term.setTextColor(colors.orange)
  91.                 term.setBackgroundColor(colors.lightBlue)
  92.                 print("Server did not respond.")
  93.                 term.setCursorPos(6,14)
  94.                 print("Please notify your Server Admin.")
  95.                 sleep(3)
  96.                 os.shutdown()
  97.             end
  98.         end
  99.         drawMS()
  100.     end
  101.     drawMS()
  102. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement