resaloli

gui

Jul 17th, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. local tChoices = {}
  3. tChoices[0] = 'Locking Wizard'
  4. tChoices[1] = 'Reserved'
  5. tChoices[2] = 'Reserved'
  6. tChoices[3] = 'Reserved'
  7. table.insert(tChoices, 'Exit')
  8. local nTermX, nTermY = term.getSize()
  9. local sSeperator = ("-"):rep(nTermX)
  10. local tActions = {}
  11.  
  12. tActions[0] = function()
  13.     term.clear()
  14.     term.setCursorPos(1, 1)
  15.     write("Starting Locking Wizard")
  16.     write('\n')
  17.     write("Coded By resaloli")
  18.     term.setCursorPos(nTermX / 2, nTermY)
  19.     write("    [Press enter to start]")
  20.     read()
  21.     shell.run("/disk/wizard")
  22. end
  23. tActions[1] = function()
  24.     term.clear()
  25.     term.setCursorPos(1, 1)
  26.     print("Nothing yet!")
  27.     write("    [Press enter to return to main menu]")
  28.     read()
  29. end
  30. tActions[2] = function()
  31.     term.clear()
  32.     term.setCursorPos(1, 1)
  33.     print("Nothing yet!")
  34.     write("    [Press enter to return to main menu]")
  35.     read()
  36. end
  37. tActions[3] = function()
  38.     term.clear()
  39.     term.setCursorPos(1, 1)
  40.     print("Nothing yet!")
  41.     write("    [Press enter to return to main menu]")
  42.     read()
  43. end
  44.  
  45. table.insert(tActions, os.reboot)
  46.  
  47. local nSelection = 0
  48.  
  49. while true do
  50.     term.setCursorPos(1, 1)
  51.     term.clear()
  52.     print(sSeperator)
  53.     print("|                      Resaloli simple GUI                |")
  54.     print(sSeperator)
  55.  
  56.     for nLine = 0, #tChoices do
  57.         local sLine = " "
  58.         if nSelection == nLine then
  59.             sLine = ">"
  60.         end
  61.         local sLineNum = tostring(nLine)
  62.         if #sLineNum < 2 then
  63.             sLineNum = sLineNum
  64.         end
  65.         sLine = sLine .. "[" .. sLineNum .. "]" .. " " .. tChoices[nLine]
  66.         print(sLine)
  67.     end
  68.     local sEvent, nKey = os.pullEvent("key")
  69.  
  70.     if nKey == 200 or nKey == 17 then
  71.         if tChoices[nSelection - 1] then
  72.             nSelection = nSelection - 1
  73.         end
  74.     elseif nKey == 208 or nKey == 31  then
  75.         if tChoices[nSelection + 1] then
  76.             nSelection = nSelection + 1
  77.         end
  78.     elseif nKey == 28 then
  79.         if tActions[nSelection] then
  80.             tActions[nSelection]()
  81.         else
  82.             print("Error: Selection out of bounds: ", nSelection)
  83.             read()
  84.         end
  85.     end
  86. end
Add Comment
Please, Sign In to add comment