AquaJD

[A'sP] AquaServer

Sep 13th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.48 KB | None | 0 0
  1. -- GUI Colors
  2.  
  3. side = "top"
  4. tBarCol = colors.blue
  5. tBarTextCol = colors.white
  6. backColor = colors.white
  7. textColor = colors.blue
  8.  
  9. nRequests = 0
  10. aRequests = 0
  11. dRequests = 0
  12. tPass = "password"
  13.  
  14. rednet.open(side)
  15.  
  16.  
  17. function titleBar()
  18.   term.setTextColor(tBarTextCol)
  19.   term.setBackgroundColor(tBarCol)
  20.   term.setCursorPos(1,1)
  21.   term.clearLine()
  22.   term.setCursorPos(1,1)
  23.   print("[AquaServer] - The Roaming Server")
  24. end
  25.  
  26. function drawBox(x,y,w,h,color)
  27.   mY = y
  28.   term.setCursorPos(x,y)
  29.   term.setBackgroundColor(color)
  30.   for i=1,h do
  31.     term.setCursorPos(x,mY)
  32.     print(string.rep(" ",w))
  33.     mY = mY + 1
  34.   end
  35. end
  36.  
  37. function drawMS()
  38.   term.setBackgroundColor(backColor)
  39.   term.clear()
  40.   drawBox(5,5,42,12,colors.lightBlue)
  41.   term.setCursorPos(6,6)
  42.   print("Server booted.")
  43.   term.setCursorPos(6,7)
  44.   print("Server ID: "..os.getComputerID())
  45.   term.setCursorPos(6,9)
  46.   print(nRequests.." total requests this session.")
  47.   term.setCursorPos(6,10)
  48.   print(aRequests.." requests accepted this session.")
  49.   term.setCursorPos(6,11)
  50.   print(dRequests.." requests denied this session.")
  51.   term.setCursorPos(6,13)
  52.   print("Listening for requests...")
  53.   titleBar()
  54. end
  55.  
  56. drawMS()
  57. while true do
  58.   senderID,message,distance = rednet.receive()
  59.   nRequests = nRequests + 1
  60.   if message == tPass then
  61.     rednet.send(senderID,"CODE_ACCEPT")
  62.     aRequests = aRequests + 1
  63.   else
  64.     rednet.send(senderID,"CODE_DECLINE")
  65.     dRequests = dRequests + 1
  66.   end
  67.   drawMS()
  68. end
Advertisement
Add Comment
Please, Sign In to add comment