Dragon53535

Quarry Management

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