PaymentOption

BasicWebsite

Apr 29th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.65 KB | None | 0 0
  1. -- Basic website code to be run by user; by PaymentOption --
  2. VERSION = "ALPHA"
  3. ------------------------------------------------------------
  4.  
  5. -- VARS --
  6. tArgs = { ... }
  7. server = tArgs[1]
  8. selection = 1
  9. ----------
  10.  
  11. -- Helper Functions --
  12. function cPrint(height, string)
  13.     local w, h = term.getSize()
  14.     local xPosition = w/2 - string.len(string)/2
  15.    
  16.     term.setCursorPos(xPosition, height)
  17.     term.write(string)
  18. end
  19.  
  20. function rPrint(height, string)
  21.     local w,h = term.getSize()
  22.     local xPos = w - string.len(string)
  23.    
  24.     term.setCursorPos(xPos, height)
  25.     term.write(string)
  26. end
  27.  
  28. function clear()
  29.     term.clear()
  30.     term.setCursorPos(1,1)
  31. end
  32. ----------------------
  33.  
  34. -- Networking related functions --
  35. function disconnect(server)
  36.     rednet.send(tonumber(server), "disconnect")
  37.     fs.delete("NeXuS/Website/"..tostring(server).."/code")
  38.     clear()
  39.     clear()
  40.     shell.run("browser")
  41. end
  42. ----------------------------------
  43.  
  44. -- Menues and other screens --
  45. function printMenu()
  46.     cPrint(1, "NeXuS Test Website")
  47.     rPrint(16, "Version: "..VERSION)
  48.    
  49.     if selection == 1 then cPrint(6, "[Other Function]")
  50.     else                   cPrint(6, " Other Function ") end
  51.    
  52.     if selection == 2 then cPrint(7, "  [Disconnect]  ")
  53.     else                   cPrint(7, "   Disconnect   ") end
  54. end
  55. ------------------------------
  56.  
  57. while true do
  58.     clear()
  59.     printMenu()
  60.    
  61.     event, key = os.pullEvent("key")
  62.    
  63.     if key == 200 and selection > 1 then selection = selection-1
  64.     elseif key == 208 and selection < 2 then selection = selection+1
  65.     end
  66.    
  67.     if key == 28 and selection == 1 then clear(); cPrint(6, "DAFUQ DID I JUST SAY?!"); sleep(1.3)
  68.     elseif key == 28 and selection == 2 then disconnect(server)
  69.     end
  70. end
Advertisement
Add Comment
Please, Sign In to add comment