DraRex368

ROBCO Termlink PROGRAMS

Jul 17th, 2022 (edited)
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2.  
  3. local w,h = term.getSize()
  4.     local x = math.floor((w - string.len(s)) /2)
  5.     term.setCursorPos(x,y)
  6.     term.clearLine()
  7.     term.write( s )
  8. end
  9.  
  10. local nOption = 1
  11.  
  12. local function drawMenu()
  13.     term.clear()
  14.     term.setCursorPos(1,1).
  15.     term.write("Program List")
  16.  
  17.     term.setCursorPos(w-11,1)
  18.     if nOption == 1 then
  19.         term.write("Email")
  20.     elseif nOption == 2 then
  21.         term.write("Send File")
  22.     elseif nOption == 3 then
  23.         term.write("Get File")
  24.     elseif nOption == 4 then
  25.         term.write("Back")
  26.     else
  27. end
  28.  
  29. end
  30.  
  31. --GUI
  32.  
  33. term.clear()
  34. local function drawFrontend()
  35.    printCentered( math.floor(h/2) - 3, "")
  36.    printCentered( math.floor(h/2) - 2, "")
  37.    printCentered( math.floor(h/2) - 1, "")
  38.    printCentered( math.floor(h/2) + 0, ((nOption == 1) and "[ > *EMAIL*]") or "[ >  EMAIL ]" )
  39.     term.setTextColor (colors.green)
  40.    printCentered( math.floor(h/2) + 1, ((nOption == 2) and "[ > *SEND FILE*]") or "[ >  SEND FILE ]" )
  41.     term.setTextColor (colors.green)
  42.    printCentered( math.floor(h/2) + 2, ((nOption == 3) and "[ > *GET FILE*]") or "[ >  GET FILE ]" )
  43.     term.setTextColor (colors.green)
  44.    printCentered( math.floor(h/2) + 3, ((nOption == 4) and "[ > *BACK*]") or "[ >  BACK ]" )
  45.     term.setTextColor (colors.green)
  46.    printCentered( math.floor(h/2) + 4, "")
  47. end
  48.  
  49. --Display
  50. drawMenu()
  51. drawFrontend()
  52.  
  53. while true do
  54.  local e,p = os.pullEvent()
  55.  if e == "key" then
  56.   local key = p
  57.   if key == 17 or key == 200 then
  58.  
  59.    if nOption > 1 then
  60.     nOption = nOption - 1
  61.     drawMenu()
  62.     drawFrontend()
  63.    end
  64.   elseif key == 31 or key == 208 then
  65.   if nOption < 4 then
  66.   nOption = nOption + 1
  67.   drawMenu()
  68.   drawFrontend()
  69. end
  70. elseif key == 28 then
  71.     --End should not be here!!
  72. break
  73. end --End should be here!!
  74. end
  75. end
  76. term.clear()
  77.  
  78. --Conditions
  79. if nOption  == 1 then
  80. shell.run("os/.email")
  81. elseif nOption == 2 then
  82. shell.run("os/.sendfile")
  83. elseif nOption == 3 then
  84. shell.run("os/.getfile")
  85. else
  86. shell.run("os/.menu)
  87. end
Add Comment
Please, Sign In to add comment