Advertisement
Expenox

Quarry Management V0.1

Oct 21st, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.32 KB | None | 0 0
  1. --[[I would like to give credit and thanks to Dragon53535 for all this help!
  2. Thanks!]]--
  3. os.pullEvent = os.pullEventRaw
  4. local option = {[[|#################################################|
  5. |                 Quarry Management               |
  6. |                    Status: ]],[[                  |
  7. |                                                 |]],
  8. [[|                                                 |
  9. |#################################################|]],
  10. "|                        On                       |",
  11. "|                        Off                      |",
  12. "|                       >On                       |",
  13. "|                       >Off                      |"}
  14. local function clear(arg)
  15.     if arg == 1 then
  16.         term.setCursorPos(1,6)
  17.         term.clearLine()
  18.         term.setCursorPos(1,5)
  19.         term.clearLine()
  20.         print(option[6])
  21.         write(option[5])
  22.     elseif arg == 2 then
  23.         term.setCursorPos(1,6)
  24.         term.clearLine()
  25.         term.setCursorPos(1,5)
  26.         term.clearLine()
  27.         print(option[4])
  28.         write(option[7])
  29.     end
  30. end
  31. function backon()
  32.     if fs.exists("Settings") == true then
  33.         main1()
  34.     elseif fs.exists("Settings") == false then
  35.         firsttimesetup()
  36.     end
  37. end
  38.  
  39. function firsttimesetup()
  40.     fs.makeDir("Settings")
  41.     local check = fs.open("Settings/Status","w")
  42.     check.writeLine("Off")
  43.     check.close()
  44.     main1()
  45. end
  46.  
  47. function main2(new)
  48.     local x = 1
  49.     term.clear()
  50.     term.setCursorPos(1,1)
  51.     write(option[1]..new)
  52.     print(option[2])
  53.     print(option[6])
  54.     print(option[5])
  55.     print(option[3])
  56.     while true do
  57.         local event, param1 = os.pullEvent("key")
  58.         if param1 == 200 then
  59.             clear(1)
  60.             x = 1
  61.         elseif param1 == 208 then
  62.             clear(2)
  63.             x = 2
  64.         elseif param1 == 28 then
  65.             if x == 2 then
  66.                 local file = fs.open("Settings/Status","w")
  67.                 file.writeLine("Off")
  68.                 file.close()
  69.                 main1()
  70.             elseif x == 1 then
  71.                 local file = fs.open("Settings/Status","w")
  72.                 file.writeLine("On")
  73.                 file.close()
  74.                 main1()
  75.             end
  76.         end
  77.     end
  78. end
  79. function main1()
  80.     local file = fs.open("Settings/Status","r")
  81.     local fileData = {}
  82.     local line = file.readLine()
  83.     repeat
  84.         table.insert(fileData,line)
  85.         line = file.readLine()
  86.     until line == nil
  87.     file.close()
  88.     if fileData[1] == "On" then
  89.   rs.setOutput("back",false)
  90.         main2("On ")
  91.     elseif fileData[1] == "Off" then
  92.   rs.setOutput("back",true)
  93.         main2("Off")
  94.     end
  95. end
  96. backon()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement