FishtoastleProgramer

DankOs programList

Apr 10th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.48 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. local fle = fs.open("DankOs/.version","r")
  3. local Ver = fle.readLine()
  4. fle.close()
  5.  
  6. local w,h = term.getSize()
  7.  
  8. function printCentered( y,s )
  9.    local x = math.floor((w - string.len(s)) / 2)
  10.    term.setCursorPos(x,y)
  11.    term.clearLine()
  12.    term.write( s )
  13. end
  14.  
  15. local nOption = 1
  16.  
  17. local function drawMenu()
  18.    term.clear()
  19.    term.setCursorPos(1,1)
  20.    term.write("Dank Os alpha "..Ver.."// ")
  21. term.setCursorPos(1,2)
  22. shell.run("id")
  23.  
  24.    term.setCursorPos(w-11,1)
  25.    if nOption == 1 then
  26.    term.write("messegeBoard")
  27. elseif nOption == 2 then
  28.    term.write("SendFile")
  29. elseif nOption == 3 then
  30.    term.write("GetFile")
  31. elseif nOption == 4 then
  32.     term.write("install a program")
  33. elseif nOption == 5 then  
  34.     term.write("uninstall a program")
  35. elseif nOption == 6 then
  36.    term.write("Back")
  37. else
  38. end
  39.  
  40. end
  41.  
  42. --GUI
  43. term.clear()
  44. local function drawFrontend()
  45.    printCentered( math.floor(h/2) - 3, "")
  46.    printCentered( math.floor(h/2) - 2, "Programs" )
  47.    printCentered( math.floor(h/2) - 1, "")
  48.    printCentered( math.floor(h/2) + 0, ((nOption == 1) and "[ MessegeBoard ]") or "MessegeBoard" )
  49.    printCentered( math.floor(h/2) + 1, ((nOption == 2) and "[ SendFile ]") or "SendFile" )
  50.    printCentered( math.floor(h/2) + 2, ((nOption == 3) and "[ GetFile ]") or "GetFile" )
  51.    printCentered( math.floor(h/2) + 3, ((nOption == 4) and "[ install a program ]")or "install a program" )
  52.    printCentered( math.floor(h/2) + 4, ((nOption == 5) and "[ uninstall a program ]")or"uninstall a program")
  53.    printCentered( math.floor(h/2) + 5, ((nOption == 6) and "[ Back ]") or "Back" )
  54.    printCentered( math.floor(h/2) + 6, "")
  55. end
  56.  
  57. --Display
  58. drawMenu()
  59. drawFrontend()
  60.  
  61. while true do
  62.  local e,p = os.pullEvent()
  63.  if e == "key" then
  64.   local key = p
  65.   if key == 17 or key == 200 then
  66.  
  67.    if nOption > 1 then
  68.     nOption = nOption - 1
  69.     drawMenu()
  70.     drawFrontend()
  71.    end
  72.   elseif key == 31 or key == 208 then
  73.   if nOption < 6 then
  74.   nOption = nOption + 1
  75.   drawMenu()
  76.   drawFrontend()
  77. end
  78. elseif key == 28 then
  79.     --End should not be here!!
  80. break
  81. end --End should be here!!
  82. end
  83. end
  84. term.clear()
  85.  
  86. --Conditions
  87. if nOption  == 1 then
  88. shell.run("DankOs/.Message")
  89. elseif nOption == 2 then
  90. shell.run("DankOs/.sendFile")
  91. elseif nOption == 3 then
  92. shell.run("DankOs/.getFile")
  93. elseif nOption == 4 then
  94. shell.run("DankOs/.installProgram")
  95. elseif nOption == 5 then
  96. shell.run("DankOs/.uninstallProgram")
  97. else
  98. shell.run(".menu")
  99. end
Add Comment
Please, Sign In to add comment