Advertisement
Freack100

Freakplace cPanel example

Aug 21st, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.63 KB | None | 0 0
  1. term.setBackgroundColor(colors.gray)
  2. term.setTextColor(colors.white)
  3. term.clear()
  4.  
  5. local selectedMenuPoint = "Home"
  6. local isServerOnline = false
  7.  
  8. local function square(sX,sY,eX,eY,col)
  9.     term.setBackgroundColor(col)
  10.     for i = sY,eY do
  11.         term.setCursorPos(sX,i)
  12.         for i = sX,eX do
  13.             term.write(" ")
  14.         end
  15.     end
  16. end
  17.  
  18. local function drawTopMenu()
  19.     if selectedMenuPoint == "Home" then
  20.         term.setCursorPos(1,1)
  21.         term.setTextColor(colors.black)
  22.         term.setBackgroundColor(colors.lightGray)
  23.         for i = 1, 17 do
  24.             term.write(" ")
  25.         end
  26.         term.setCursorPos(2,1)
  27.         term.write("Home")
  28.         term.setCursorPos(18,1)
  29.         term.setBackgroundColor(colors.gray)
  30.         term.setTextColor(colors.white)
  31.         for i = 1, 17 do
  32.             term.write(" ")
  33.         end
  34.         term.setCursorPos(19,1)
  35.         term.write("Server")
  36.         term.setCursorPos(35,1)
  37.         for i = 1, 17 do
  38.             term.write(" ")
  39.         end
  40.         term.setCursorPos(37,1)
  41.         term.write("File")
  42.     elseif selectedMenuPoint == "Server" then
  43.         term.setCursorPos(1,1)
  44.         term.setTextColor(colors.white)
  45.         term.setBackgroundColor(colors.gray)
  46.         for i = 1, 17 do
  47.             term.write(" ")
  48.         end
  49.         term.setCursorPos(2,1)
  50.         term.write("Home")
  51.         term.setCursorPos(18,1)
  52.         term.setBackgroundColor(colors.lightGray)
  53.         term.setTextColor(colors.black)
  54.         for i = 1, 17 do
  55.             term.write(" ")
  56.         end
  57.         term.setCursorPos(19,1)
  58.         term.write("Server")
  59.         term.setCursorPos(35,1)
  60.                 term.setTextColor(colors.white)
  61.         term.setBackgroundColor(colors.gray)
  62.         for i = 1, 17 do
  63.             term.write(" ")
  64.         end
  65.  
  66.         term.setCursorPos(37,1)
  67.         term.write("File")
  68.     elseif selectedMenuPoint == "File" then
  69.         term.setCursorPos(1,1)
  70.         term.setTextColor(colors.white)
  71.         term.setBackgroundColor(colors.gray)
  72.         for i = 1, 17 do
  73.             term.write(" ")
  74.         end
  75.         term.setCursorPos(2,1)
  76.         term.write("Home")
  77.         term.setCursorPos(18,1)
  78.         for i = 1, 17 do
  79.             term.write(" ")
  80.         end
  81.         term.setCursorPos(19,1)
  82.         term.write("Server")
  83.         term.setTextColor(colors.black)
  84.         term.setBackgroundColor(colors.lightGray)
  85.         term.setCursorPos(35,1)
  86.         for i = 1, 17 do
  87.             term.write(" ")
  88.         end
  89.         term.setCursorPos(37,1)
  90.         term.write("File")
  91.     end
  92. end
  93.  
  94. local function drawContent()
  95.     if selectedMenuPoint == "Home" then
  96.         term.setTextColor(colors.gray)
  97.         term.setBackgroundColor(colors.white)
  98.         for i = 2, 19 do
  99.             term.setCursorPos(1,i)
  100.             for j = 1, 51 do
  101.                 term.write(" ")
  102.             end
  103.         end
  104.         square(5,4,51-5,8,colors.lightGray)
  105.         term.setCursorPos(6,5)
  106.         term.write("The server is "..(isServerOnline and "online" or "offline"))
  107.         term.setCursorPos(6,7)
  108.         term.write("Version: fPanel Spaghetti (1.1)")
  109.     elseif selectedMenuPoint == "Server" then
  110.         term.setTextColor(colors.gray)
  111.         term.setBackgroundColor(colors.white)
  112.         for i = 2, 19 do
  113.             term.setCursorPos(1,i)
  114.             for j = 1, 51 do
  115.                 term.write(" ")
  116.             end
  117.         end
  118.         term.setCursorPos(2,4)
  119.         term.write("The server is "..(isServerOnline and "online" or "offline").. " press c to change it")
  120.         term.setCursorPos(3,5)
  121.         term.write("It's only an example,so you can't change it")
  122.        
  123.     elseif selectedMenuPoint == "File" then
  124.         term.setTextColor(colors.gray)
  125.         term.setBackgroundColor(colors.white)
  126.         for i = 2, 19 do
  127.             term.setCursorPos(1,i)
  128.             for j = 1, 51 do
  129.                 term.write(" ")
  130.             end
  131.         end
  132.         term.setCursorPos(3,4)
  133.         term.setBackgroundColor(colors.lightGray)
  134.         term.write(" You can't use this cause It's just an example")
  135.         term.setCursorPos(3,6)
  136.         term.write("upload")
  137.     end
  138. end
  139.  
  140. drawTopMenu()
  141.  
  142. local function topMenuClickHandle()
  143.     while true do
  144.         local evt,btn,x,y = os.pullEvent("mouse_click")
  145.         if x >= 1 and x <= 17 and y == 1 and selectedMenuPoint ~= "Home" then
  146.             selectedMenuPoint = "Home"
  147.             drawTopMenu()
  148.             drawContent()
  149.         elseif x >= 17+1 and x <= 17*2 and y == 1 and selectedMenuPoint ~= "Server" then
  150.             selectedMenuPoint = "Server"
  151.             drawTopMenu()
  152.             drawContent()
  153.             --[[while selectedMenuPoint == "Server" do
  154.                 local evt,btn,x,y = os.pullEvent("mouse_click")
  155.                 if x >= 5+string.len("The server is "..(isServerOnline and "online" or "offline").. "click -) ") and x <= 5+string.len("The server is "..(isServerOnline and "online" or "offline").. "click -) ")+4 and y == 4 then
  156.                     isServerOnline = not isServerOnline
  157.                 end
  158.                 sleep(0)
  159.             end]]--
  160.             while selectedMenuPoint == "Server" do
  161.                 local evt, char = os.pullEvent("char")
  162.                 if char == "c" then
  163.                     isServerOnline = not isServerOnline
  164.                     selectedMenuPoint = "Home"
  165.                     drawTopMenu()
  166.                     drawContent()
  167.                 end
  168.                 sleep(0)
  169.             end
  170.         elseif x >= (17*2)+1 and x <= 51 and y == 1 and selectedMenuPoint ~= "File" then
  171.             selectedMenuPoint = "File"
  172.             drawTopMenu()
  173.             drawContent()
  174.         end
  175.         sleep(0)
  176.     end
  177. end
  178.  
  179. topMenuClickHandle()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement