Henness

advancedgui

Jan 19th, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.32 KB | None | 0 0
  1. -- Advanced GUI by Henness
  2. -- Version 1.2 2/5/2013
  3.  
  4. -- Config
  5. local program = "Advanced Program's"
  6. local version = "v1.2"
  7. local author = "Henness"
  8.  
  9. screenw,screenh = term.getSize()
  10.  
  11. local shell = {}
  12. local tEnv = {
  13.     ["shell"] = shell,
  14. }
  15.  
  16. local select, bError, sError
  17. local enderChestMode = true
  18. local safeMode = true
  19. local questionInput = {
  20. new = {
  21.     {input = {{text = "", sx = 15, sy = 5}, {text = "", sx = 15, sy = 6}, {text = "", sx = 15, sy = 7}}}
  22.     },
  23. preset = {
  24.     {input = {{text = "", sx = 15, sy = 4}, {text = "", sx = 15, sy = 6}, {text = "", sx = 15, sy = 7}, {text = "", sx = 15, sy = 8}}},
  25.     {input = {{text = "", sx = 15, sy = 4}, {text = "", sx = 15, sy = 6}, {text = "", sx = 15, sy = 7}, {text = "", sx = 15, sy = 8}}},
  26.     {input = {{text = "", sx = 15, sy = 4}, {text = "", sx = 15, sy = 6}, {text = "", sx = 15, sy = 7}, {text = "", sx = 15, sy = 8}}}
  27.     }
  28. }
  29.  
  30. -- Functions
  31. function saveTable(table,name)
  32.     local file = fs.open(name,"w")
  33.     file.write(textutils.serialize(table))
  34.     file.close()
  35. end
  36.  
  37. function loadTable(name)
  38.     local file = fs.open(name,"r")
  39.     local data = file.readAll()
  40.     file.close()
  41.     return textutils.unserialize(data)
  42. end
  43.  
  44. function printReverse(str, xpos, ypos)
  45.     term.setCursorPos(xpos - (#str-1), ypos)
  46.     term.write (str)
  47. end
  48.  
  49. function printForward(str, xpos, ypos)
  50.     term.setCursorPos(xpos, ypos)
  51.     term.write (str)
  52. end
  53.  
  54. function printCentered(str, ypos)
  55.     term.setCursorPos((screenw/2 - #str/2) + 1, ypos)
  56.     term.write(str)
  57. end
  58.  
  59. function printRight(str, ypos)
  60.     term.setCursorPos(screenw - #str, ypos)
  61.     term.write(str)
  62. end
  63.  
  64. function printLeft(str, ypos)
  65.     term.setCursorPos(1, ypos)
  66.     term.write(str)
  67. end
  68.  
  69. function readLines( sLines, _sReplaceChar )
  70.     term.setCursorBlink( true )
  71.     local w, h = term.getSize()
  72.     local nPos = 0
  73.     local nSelect = 1
  74.     local vSelect = 1
  75.     local function redraw( _sCustomReplaceChar )
  76.         local nScroll = 0
  77.         if sLines[nSelect].sx + nPos >= w then
  78.             nScroll = (sLines[nSelect].sx + nPos) - w
  79.         end
  80.         term.setCursorPos( sLines[nSelect].sx, sLines[nSelect].sy )
  81.         local sReplace = _sCustomReplaceChar or _sReplaceChar
  82.         if sReplace then
  83.             term.write( string.rep(sReplace, string.len(sLines[nSelect].text) - nScroll) )
  84.         else
  85.             term.write( string.sub( sLines[nSelect].text, nScroll + 1 ) )
  86.         end
  87.         term.setCursorPos( sLines[nSelect].sx + nPos - nScroll, sLines[nSelect].sy )
  88.     end
  89.     for nVar, tVar in ipairs(sLines) do
  90.         nSelect = nVar
  91.         redraw()
  92.         if tVar.text ~= "" then
  93.             vSelect = nVar
  94.         end
  95.     end
  96.     nSelect = vSelect
  97.     nPos = #sLines[nSelect].text
  98.     redraw()
  99.     while true do
  100.         local sEvent, param = os.pullEvent()
  101.         if sEvent == "char" then
  102.             sLines[nSelect].text = string.sub( sLines[nSelect].text, 1, nPos ) .. param .. string.sub( sLines[nSelect].text, nPos + 1 )
  103.             nPos = nPos + 1
  104.             redraw()
  105.         elseif sEvent == "key" then
  106.             if param == keys.enter then
  107.                 -- Enter
  108.                 if nSelect < #sLines then
  109.                     nSelect = nSelect + 1
  110.                     if sLines[nSelect].text == "" then
  111.                         nPos = 0
  112.                     else
  113.                         nPos = #sLines[nSelect].text
  114.                     end
  115.                     redraw()
  116.                 else
  117.                     break
  118.                 end
  119.             elseif param == keys.left then
  120.                 -- Left
  121.                 if nPos > 0 then
  122.                     nPos = nPos - 1
  123.                     redraw()
  124.                 end
  125.             elseif param == keys.right then
  126.                 -- Right               
  127.                 if nPos < string.len(sLines[nSelect].text) then
  128.                     nPos = nPos + 1
  129.                     redraw()
  130.                 end
  131.             elseif param == keys.up or param == keys.down then
  132.                 -- Up or down
  133.                 if param == keys.up then
  134.                     -- Up
  135.                     if nSelect > 1 then
  136.                         nSelect = nSelect - 1
  137.                         if sLines[nSelect].text == "" then
  138.                             nPos = 0
  139.                         else
  140.                             nPos = #sLines[nSelect].text
  141.                         end
  142.                         redraw()
  143.                     end
  144.                 else
  145.                     -- Down
  146.                     if nSelect < #sLines then
  147.                         nSelect = nSelect + 1
  148.                         if sLines[nSelect].text == "" then
  149.                             nPos = 0
  150.                         else
  151.                             nPos = #sLines[nSelect].text
  152.                         end
  153.                         redraw()
  154.                     else
  155.                         break
  156.                     end
  157.                 end
  158.                 redraw()
  159.             elseif param == keys.backspace then
  160.                 -- Backspace
  161.                 if nPos > 0 then
  162.                     redraw(" ");
  163.                     sLines[nSelect].text = string.sub( sLines[nSelect].text, 1, nPos - 1 ) .. string.sub( sLines[nSelect].text, nPos + 1 )
  164.                     nPos = nPos - 1                
  165.                     redraw()
  166.                 end
  167.             elseif param == keys.home then
  168.                 -- Home
  169.                 nPos = 0
  170.                 redraw()       
  171.             elseif param == keys.delete then
  172.                 if nPos < string.len(sLines[nSelect].text) then
  173.                     redraw(" ");
  174.                     sLines[nSelect].text = string.sub( sLines[nSelect].text, 1, nPos ) .. string.sub( sLines[nSelect].text, nPos + 2 )             
  175.                     redraw()
  176.                 end
  177.             elseif param == keys["end"] then
  178.                 -- End
  179.                 nPos = string.len(sLines[nSelect].text)
  180.                 redraw()
  181.             end
  182.         end
  183.     end
  184.     term.setCursorBlink( false )
  185.     return sLines
  186. end
  187.  
  188. local function drawHeader()
  189.     printCentered(program, 1)
  190.     printLeft(string.rep("-", screenw), 2)
  191.     printLeft("["..version.."]"..string.rep("-", screenw-#author-#version-7).."[by "..author.."]", screenh)
  192. end
  193.  
  194. function drawMain()
  195.     term.clear()
  196.     drawHeader()
  197.     printLeft("  OreFinder", 4)
  198.     printLeft("  Tunnel", 5)
  199.     printLeft("  Exit", screenh-2)
  200.  
  201.     local ypos = 4
  202.     if select == 2 then ypos = 5
  203.     elseif select == 3 then ypos = screenh-2 end
  204.     printLeft(">", ypos)
  205. end
  206.  
  207. function drawOreFinder()
  208.     term.clear()
  209.     drawHeader()
  210.     if fs.exists("ofpreset") then
  211.         preset = loadTable("ofpreset")
  212.     else
  213.         preset = {
  214.             [1] = {
  215.                 values = {"000", "000", "00", "00", "PRESET #1", "0", true, true}
  216.             },
  217.             [2] = {
  218.                 values = {"000", "000", "00", "00", "PRESET #2", "0", true, true}
  219.             },
  220.             [3] = {
  221.                 values = {"000", "000", "00", "00", "PRESET #3", "0", true, true}
  222.             }
  223.         }
  224.         saveTable(preset, "ofpreset")
  225.     end
  226.  
  227.     local namea = preset[1].values[5]
  228.     local nameb = preset[2].values[5]
  229.     local namec = preset[3].values[5]
  230.     printLeft("  Continue", 4)
  231.     printLeft("  New", 5)
  232.     printLeft("  "..namea, 7)
  233.     printLeft("  "..nameb, 8)
  234.     printLeft("  "..namec, 9)
  235.     printLeft("  Back", screenh-2)
  236.     for i=1,screenh-3 do
  237.         printRight("|"..string.rep(" ", 21), i+2)
  238.     end
  239.     if select == 1 then
  240.         printLeft(">", 4)
  241.     elseif select == 2 then
  242.         printLeft(">", 5)
  243.     elseif select == 3 or select == 4 or select == 5 then
  244.         local vPreset = select - 2
  245.         local width = preset[vPreset].values[1]
  246.         local length = preset[vPreset].values[2]
  247.         local hours = preset[vPreset].values[3]
  248.         local minutes = preset[vPreset].values[4]
  249.         local ignore = preset[vPreset].values[6]
  250.         local safemode = preset[vPreset].values[7]
  251.         local enderchest = preset[vPreset].values[8]
  252.         if select == 3 then
  253.             printRight("|  "..namea..string.rep(" ", 19-#namea), 4)
  254.             printLeft(">", 7)
  255.         elseif select == 4 then
  256.             printRight("|  "..nameb..string.rep(" ", 19-#nameb), 4)
  257.             printLeft(">", 8)
  258.         elseif select == 5 then
  259.             printRight("|  "..namec..string.rep(" ", 19-#namec), 4)
  260.             printLeft(">", 9)
  261.         end
  262.         printRight("|     Size: "..string.rep("0", 3-#width)..width.."x"..string.rep("0", 3-#length)..length..string.rep(" ", 3), 6)
  263.         printRight("|     Time:  "..string.rep("0", 2-#hours)..hours..":"..string.rep("0", 2-#minutes)..minutes..string.rep(" ", 4), 7)
  264.         printRight("|   Ignore:   "..string.rep(" ", 2-#ignore)..ignore..string.rep(" ", 6), 9)
  265.         if safemode then
  266.             printRight("|   SafeMode  Yes     ", 10)
  267.         else
  268.             printRight("|   SafeMode  No      ", 10)
  269.         end
  270.         if enderchest then
  271.             printRight("| EnderChest  Yes     ", 11)
  272.         else
  273.             printRight("| EnderChest  No      ", 11)
  274.         end
  275.     elseif select == 6 then
  276.         printLeft(">", screenh-2)
  277.     end
  278. end
  279.  
  280. function drawOreFinderContinue()
  281.     local continueList = {
  282.         "+-------------------------------+",
  283.         "|                               |",
  284.         "|  Would you like to continue   |",
  285.         "|   your previous excavation?   |",
  286.         "|                               |",
  287.         "|        YES          NO        |",
  288.         "+-------------------------------+"
  289.     }
  290.     for i=1,#continueList do
  291.         if i == #continueList-1 then
  292.             if select == 1 then
  293.                 printCentered("|       [YES]         NO        |", 3 + i)
  294.             elseif select == 2 then
  295.                 printCentered("|        YES         [NO]       |", 3 + i)
  296.             end
  297.         else
  298.             printCentered(continueList[i], 3 + i)
  299.         end
  300.     end
  301. end
  302.  
  303. function drawOreFinderStart()
  304.     local startList = {
  305.         "+-------------------------------+",
  306.         "|                               |",
  307.         "|  Are you sure you would like  |",
  308.         "|   to start a new excavation?  |",
  309.         "|                               |",
  310.         "|        YES          NO        |",
  311.         "+-------------------------------+"
  312.     }
  313.     for i=1,#startList do
  314.         if i == #startList-1 then
  315.             if select == 1 then
  316.                 printCentered("|       [YES]         NO        |", 3 + i)
  317.             elseif select == 2 then
  318.                 printCentered("|        YES         [NO]       |", 3 + i)
  319.             end
  320.         else
  321.             printCentered(startList[i], 3 + i)
  322.         end
  323.     end
  324. end
  325.  
  326. function drawOreFinderNoFile()
  327.     local nofileList = {
  328.         "+-------------------------------+",
  329.         "|                               |",
  330.         "|            ERROR!             |",
  331.         "|    No save file was found.    |",
  332.         "|                               |",
  333.         "|             [OK]              |",
  334.         "+-------------------------------+"
  335.     }
  336.     for i=1,#nofileList do
  337.         printCentered(nofileList[i], 3 + i)
  338.     end
  339. end
  340.  
  341. function drawOreFinderInputError()
  342.     local inputerrorList = {
  343.         "+-------------------------------+",
  344.         "|                               |",
  345.         "|            ERROR!             |",
  346.         "| Please input valid variables! |",
  347.         "|                               |",
  348.         "|             [OK]              |",
  349.         "+-------------------------------+"
  350.     }
  351.     for i=1,#inputerrorList do
  352.         printCentered(inputerrorList[i], 3 + i)
  353.     end
  354. end
  355.  
  356.  
  357. function drawOreFinderPreset()
  358.     local presetList = {
  359.         "+-------------------------------+",
  360.         "|                               |",
  361.         "|                               |",
  362.         "|                               |",
  363.         "|                               |",
  364.         "|    START    CANCEL    EDIT    |",
  365.         "+-------------------------------+"
  366.     }
  367.     Name = preset[presetstate].values[5]
  368.     Width = preset[presetstate].values[1]
  369.     Length = preset[presetstate].values[2]
  370.     Hours = preset[presetstate].values[3]
  371.     Minutes = preset[presetstate].values[4]
  372.     Ignore = preset[presetstate].values[6]
  373.     for i=1,#presetList do
  374.         if i == 2 or i == 5 then
  375.             printCentered("|                               |", 3 + i)
  376.             if i == 2 then
  377.                 printCentered(Name, 3 + i)
  378.             end
  379.         elseif i == 3 then
  380.             printCentered("|      Size: " .. string.rep("0", 3-#Width) .. Width .. "x" .. string.rep("0", 3-#Length) .. Length .. string.rep(" ", 12) .. "|", 3 + i)
  381.         elseif i == 4 then
  382.             printCentered("|      Time:  " .. string.rep("0", 2-#Hours) .. Hours .. ":" .. string.rep("0", 2-#Minutes) .. Minutes .. string.rep(" ", 13) .. "|", 3 + i)
  383.         elseif i == #presetList-1 then
  384.             if select == 1 then
  385.                 printCentered("|   [START]   CANCEL    EDIT    |", 3 + i)
  386.             elseif select == 2 then
  387.                 printCentered("|    START   [CANCEL]   EDIT    |", 3 + i)
  388.             elseif select == 3 then
  389.                 printCentered("|    START    CANCEL   [EDIT]   |", 3 + i)
  390.             end
  391.         else
  392.             printCentered(presetList[i], 3 + i)
  393.         end
  394.     end
  395. end
  396.  
  397. function drawOreFinderNew()
  398.     local sLine8 = " Ender Chest "
  399.     local sLine9 = "   Safe Mode "
  400.  
  401.     term.clear()
  402.     drawHeader()
  403.     printCentered("Input variables for the excavation.", 3)
  404.     printLeft("       Width: " .. questionInput.new[1].input[1].text, 5)
  405.     printLeft("      Length: " .. questionInput.new[1].input[2].text, 6)
  406.     printLeft("      Ignore: " .. questionInput.new[1].input[3].text, 7)
  407.     if enderChestMode then
  408.         printLeft(sLine8 .. " Yes ", 8)
  409.     else
  410.         printLeft(sLine8 .. " No  ", 8)
  411.     end
  412.     if safeMode then
  413.         printLeft(sLine9 .. " Yes ", 9)
  414.     else
  415.         printLeft(sLine9 .. " No  ", 9)
  416.     end
  417.     printLeft(string.rep("-", screenw), screenh-2)
  418.     printCentered(" DONE ", screenh-1)
  419.     if select == 1 then
  420.         readLines(questionInput.new[1].input)
  421.         Width,Length,Ignore = tonumber(questionInput.new[1].input[1].text),tonumber(questionInput.new[1].input[2].text),tonumber(questionInput.new[1].input[3].text)
  422.         if Width ~= nil and Length ~= nil and Ignore ~= nil and Width > 0 and Length > 0 and Ignore >= 0 and Ignore < 15 then
  423.             select = 2
  424.             mopt[menustate].draw()
  425.         else
  426.             menustate = mopt[menustate].options[select]
  427.             mopt[menustate].draw()
  428.         end
  429.     elseif select == 2 then
  430.         if enderChestMode then
  431.             printLeft(sLine8 .. "[Yes]", 8)
  432.         else
  433.             printLeft(sLine8 .. "[No] ", 8)
  434.         end
  435.     elseif select == 3 then
  436.         if safeMode then
  437.             printLeft(sLine9 .. "[Yes]", 9)
  438.         else
  439.             printLeft(sLine9 .. "[No] ", 9)
  440.         end
  441.     elseif select == 4 then
  442.         printCentered("[DONE]", screenh-1)
  443.     end
  444. end
  445.  
  446. function drawOreFinderEdit()
  447.     local sLine9 = " Ender Chest "
  448.     local sLine10 = "   Safe Mode "
  449.  
  450.     term.clear()
  451.     drawHeader()
  452.     printCentered("Input variables for preset " .. presetname .. ".", 3)
  453.     printLeft("        Name: " .. questionInput.preset[presetstate].input[1].text, 4)
  454.     printLeft("       Width: " .. questionInput.preset[presetstate].input[2].text, 6)
  455.     printLeft("      Length: " .. questionInput.preset[presetstate].input[3].text, 7)
  456.     printLeft("      Ignore: " .. questionInput.preset[presetstate].input[4].text, 8)
  457.     if enderChestMode then
  458.         printLeft(sLine9 .. " Yes ", 9)
  459.     else
  460.         printLeft(sLine9 .. " No  ", 9)
  461.     end
  462.     if safeMode then
  463.         printLeft(sLine10 .. " Yes ", 10)
  464.     else
  465.         printLeft(sLine10 .. " No  ", 10)
  466.     end
  467.     printLeft(string.rep("-", screenw), screenh-2)
  468.     printCentered(" DONE ", screenh-1)
  469.     if select == 1 then
  470.         readLines(questionInput.preset[presetstate].input)
  471.         Name,Width,Length,Ignore = tostring(questionInput.preset[presetstate].input[1].text),tonumber(questionInput.preset[presetstate].input[2].text),tonumber(questionInput.preset[presetstate].input[3].text),tonumber(questionInput.preset[presetstate].input[4].text)
  472.         if Name ~= nil and #Name < 15 and Width ~= nil and Length ~= nil and Ignore ~= nil and Width > 0 and Length > 0 and Ignore >= 0 and Ignore < 15 then
  473.             preset[presetstate].values[5] = Name
  474.             preset[presetstate].values[1] = tostring(Width)
  475.             preset[presetstate].values[2] = tostring(Length)
  476.             preset[presetstate].values[6] = tostring(Ignore)
  477.             preset[presetstate].values[7] = enderChestMode
  478.             preset[presetstate].values[8] = safeMode
  479.             saveTable(preset, "ofpreset")
  480.             select = 2
  481.             mopt[menustate].draw()
  482.         else
  483.             menustate = mopt[menustate].options[select]
  484.             mopt[menustate].draw()
  485.         end
  486.     elseif select == 2 then
  487.         if enderChestMode then
  488.             printLeft(sLine9 .. "[Yes]", 9)
  489.         else
  490.             printLeft(sLine9 .. "[No] ", 9)
  491.         end
  492.     elseif select == 3 then
  493.         if safeMode then
  494.             printLeft(sLine10 .. "[Yes]", 10)
  495.         else
  496.             printLeft(sLine10 .. "[No] ", 10)
  497.         end
  498.     elseif select == 4 then
  499.         printCentered("[DONE]", screenh-1)
  500.     end
  501. end
  502.  
  503. function drawErrorMenu()
  504.     term.clear()
  505.     drawHeader()
  506.     printLeft(string.rep("-", screenw), screenh-2)
  507.     printCentered("[OK]", screenh-1)
  508.     term.setCursorPos(1, 3)
  509.     print(sError)
  510. end
  511.  
  512. function gui()
  513.     term.clear()
  514.     select = 1
  515.     menustate = "main"
  516.     mopt = {
  517.         ["main"] = {
  518.             options = {"orefinder", "tunnel", "exit"},
  519.             draw = drawMain
  520.         },
  521.         ["orefinder"] = {
  522.             options = {"orefindercontinue", "orefindernew", "orefinderpreset", "orefinderpreset", "orefinderpreset", "main"},
  523.             draw = drawOreFinder
  524.         },
  525.         ["orefindercontinue"] = {
  526.             options = {"orefinderrun", "orefinder"},
  527.             draw = drawOreFinderContinue
  528.         },
  529.         ["orefindernofile"] = {
  530.             options = {"orefinder"},
  531.             draw = drawOreFinderNoFile
  532.         },
  533.         ["orefindernew"] = {
  534.             options = {"orefinderinputerror", "enderchest", "safemode", "orefinderstart"},
  535.             draw = drawOreFinderNew
  536.         },
  537.         ["orefinderpreset"] = {
  538.             options = {"orefinderstart", "orefinder", "orefinderedit"},
  539.             draw = drawOreFinderPreset
  540.         },
  541.         ["orefinderstart"] = {
  542.             options = {"orefinderrun", "orefinder"},
  543.             draw = drawOreFinderStart
  544.         },
  545.         ["orefinderedit"] = {
  546.             options = {"orefinderpreseterror", "enderchest", "safemode", "orefinder"},
  547.             draw = drawOreFinderEdit
  548.         },
  549.         ["orefinderinputerror"] = {
  550.             options = {"orefindernew"},
  551.             draw = drawOreFinderInputError
  552.         },
  553.         ["orefinderpreseterror"] = {
  554.             options = {"orefinderedit"},
  555.             draw = drawOreFinderInputError
  556.         },
  557.         ["errormenu"] = {
  558.             options = {"main"},
  559.             draw = drawErrorMenu
  560.         }
  561.     }
  562.     while true do
  563.         mopt[menustate].draw()
  564.         local id, key = os.pullEvent("key")
  565.         -- DOWN = 208 UP = 200 LEFT = 203 RIGHT = 205 ENTER = 28
  566.         if key == 200 and select > 1 then
  567.             select = select-1
  568.         elseif key == 208 and select < #mopt[menustate].options then
  569.             select = select+1
  570.         elseif key == 203 and select > 1 then
  571.             select = select-1
  572.         elseif key == 205 and select < #mopt[menustate].options then
  573.             select = select+1
  574.         elseif key == 28 then
  575.             if mopt[menustate].options[select] == "exit" then
  576.                 break
  577.             elseif mopt[menustate].options[select] == "orefindercontinue" then
  578.                 if fs.exists("orefinder.save") then
  579.                     menustate = "orefindercontinue"
  580.                 else
  581.                     menustate = "orefindernofile"
  582.                 end
  583.                 select = 1
  584.             elseif mopt[menustate].options[select] == "orefinderrun" then
  585.                 if menustate ~= "orefindercontinue" then
  586.                     local _tSave = {
  587.                         w = 1,
  588.                         l = 1,
  589.                         width = Width,
  590.                         length = Length,
  591.                         ignore = Ignore,
  592.                         safemode = safeMode,
  593.                         enderchestmode = enderChestMode
  594.                     }
  595.                     saveTable(_tSave, "orefinder.save")
  596.                 end
  597.                 bError, sError = pcall(loadfile("advancedorefinder", "orefinder.save"))
  598.                 if not bError then
  599.                     menustate = "errormenu"
  600.                 else
  601.                     menustate = "main"
  602.                 end
  603.                 select = 1
  604.             elseif mopt[menustate].options[select] == "tunnel" then
  605.                 -- Run Tunnel
  606.                 bError, sError = pcall(loadfile("advancedtunnel"))
  607.                 if not bError then
  608.                     menustate = "errormenu"
  609.                 else
  610.                     menustate = "main"
  611.                 end
  612.                 select = 1
  613.             elseif mopt[menustate].options[select] == "enderchest" then
  614.                 if enderChestMode then
  615.                     enderChestMode = false
  616.                 else
  617.                     enderChestMode = true
  618.                 end
  619.             elseif mopt[menustate].options[select] == "safemode" then
  620.                 if safeMode then
  621.                     safeMode = false
  622.                 else
  623.                     safeMode = true
  624.                 end
  625.             else
  626.                 if mopt[menustate].options[select] == "orefinderpreset" then
  627.                     drawOreFinder()
  628.                     if select == 3 then
  629.                         presetstate = 1
  630.                         presetname = "one"
  631.                     elseif select == 4 then
  632.                         presetstate = 2
  633.                         presetname = "two"
  634.                     elseif select == 5 then
  635.                         presetstate = 3
  636.                         presetname = "three"
  637.                     end
  638.                 end
  639.                 menustate = mopt[menustate].options[select]
  640.                 select = 1
  641.             end
  642.         end
  643.     end
  644.     term.clear()
  645.     term.setCursorPos(1,1)
  646. end
  647.  
  648. -- RUN
  649. gui()
Advertisement
Add Comment
Please, Sign In to add comment