Advertisement
johnneijzen

Test Lua

May 9th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.98 KB | None | 0 0
  1. --[[
  2. Version
  3.   0.03 5/10/2017
  4. Changelog
  5.   0.01 - First Draft
  6.   0.02 - Added Support for Bridge Program
  7.   0.03 - Added Support for Bridge No Side Wall Programs
  8. --]]
  9.  
  10. local options = {
  11.     "Excavation Program 2017",
  12.     "Tunnel Program 2017",
  13.     "Strip Mining Program 2017",
  14.     "Bridge Program 2017",
  15.     "Bridge Program No Side Walls 2017",
  16.     "Next Page",
  17.     "Multi Build Program 2017",
  18.     "Back Page"
  19. }
  20.  
  21. local optionSize = 8
  22. local n = 1
  23. local currentPage = 1
  24.  
  25. local function runOptions()
  26.     if n == 1 then
  27.         shell.run("john-ComputerCraft-Program/Excavation2017")
  28.     elseif n == 2 then
  29.         shell.run("john-ComputerCraft-Program/Tunnel2017")
  30.     elseif n == 3 then
  31.         shell.run("john-ComputerCraft-Program/StripMining2017")
  32.     elseif n == 4 then
  33.         shell.run("john-ComputerCraft-Program/Bridge2017")
  34.     elseif n == 5 then
  35.         shell.run("john-ComputerCraft-Program/BridgeNoWalls2017")
  36.     elseif n == 7 then
  37.         shell.run("john-ComputerCraft-Program/")
  38.     end
  39. end
  40.  
  41. local function gui()
  42.     while true do
  43.         term.clear()
  44.         term.setCursorPos(1,1)
  45.         for i = 1 , 6 do
  46.             if (i + ((currentPage-1) * 6)) <= optionSize then
  47.                 if n == i + ((currentPage-1)*6) then
  48.                     print("---> ".. options[i + ((currentPage-1)*6)])
  49.                     print("")
  50.                 else
  51.                     print("     ".. options[i + ((currentPage-1)*6)])
  52.                     print("")
  53.                 end
  54.             end
  55.         end
  56.         local event, key = os.pullEvent("key")
  57.         if key == keys.up and n > 1 + ((currentPage-1)*6) then
  58.             n = n - 1
  59.         elseif key == keys.down and n < 6 + ((currentPage-1)*6) then
  60.             if(n < optionSize) then
  61.                 n = n + 1
  62.             end    
  63.         elseif key == keys.enter then
  64.             if n == 6 then
  65.                 currentPage = 2
  66.                 n = 7
  67.             elseif n == 8 then
  68.                 currentPage = 1
  69.                 n = 6
  70.             else
  71.                 break
  72.             end
  73.         end
  74.     end
  75.     runOptions()
  76. end
  77.  
  78. gui()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement