Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if fs.exists("button") then
- print("API Installed, Continuing...")
- sleep(1)
- else
- print("API Isn't Installed, Downloading...")
- shell.run("pastebin", "get", "XBbMUYNn", "button")
- sleep(1)
- print("API Installed, Rebooting...")
- sleep(3)
- os.reboot()
- end
- os.loadAPI("button")
- m = peripheral.wrap("top")
- m.clear()
- local oreProcessEnabled = false
- local powerEnabled = false
- local quarryEnabled = false
- local reactorEnabled = false
- --Save data
- function saveData()
- fs.makeDir("saves")
- local file = fs.open("saves/control","w")
- file.writeLine(oreProcessEnabled)
- file.writeLine(powerEnabled)
- file.writeLine(quarryEnabled)
- file.writeLine(reactorEnabled)
- file.close()
- end
- --Load data
- function loadData()
- local file = fs.open("saves/control","r")
- local fileData = {}
- local line
- repeat
- line = file.readLine()
- table.insert(fileData, line)
- until line == nil
- file.close()
- oreProcessEnabled = fileData[1]
- powerEnabled = fileData[2]
- quarryEnabled = fileData[3]
- reactorEnabled = fileData[4]
- end
- --Sets the state of redstone for a specific side and color.
- function changeEnabled(col,enabled,side)
- if enabled == true then
- redstone.setBundledOutput(side,colors.combine(redstone.getBundledOutput(side),col))
- else
- redstone.setBundledOutput(side,colors.subtract(redstone.getBundledOutput(side),col))
- end
- end
- --This is the "main" menu
- function mainMenu()
- m.clear()
- button.clearTable()
- button.setTable("Basement", Basement,false,9,19,3,5)
- button.setTable("Reactor", Reactor,reactorEnabled,21,31,3,5)
- button.screen()
- button.heading("Main Menu")
- end
- --This is the "basement" menu.
- function basementMenu()
- m.clear()
- button.clearTable()
- button.setTable("Ore_Processing", Ore_Processing,oreProcessEnabled,3,19,3,5)
- button.setTable("Power", Power,powerEnabled,21,37,3,5)
- button.setTable("Quarry", Quarry,quarryEnabled,12,28,7,9)
- button.setTable("Back", Back,false,9,31,16,18)
- button.heading("Basement Control")
- button.screen()
- button.setButton("Ore_Processing", oreProcessEnabled)
- button.setButton("Power", powerEnabled)
- button.setButton("Quarry", quarryEnabled)
- setWires()
- end
- --If the "Basement" button is pressed.
- function Basement()
- print("Basement Menu Opened")
- loadData()
- basementMenu()
- end
- --If the "Ore_Processing" button is pressed.
- function Ore_Processing()
- oreProcessEnabled = not oreProcessEnabled
- sleep(0.1)
- button.setButton("Ore_Processing", oreProcessEnabled)
- saveData()
- setWires()
- end
- --If the "Power" button is pressed.
- function Power()
- powerEnabled = not powerEnabled
- sleep(0.1)
- button.setButton("Power", powerEnabled)
- saveData()
- setWires()
- end
- --If the "Quarry" button is pressed.
- function Quarry()
- quarryEnabled = not quarryEnabled
- sleep(0.1)
- button.setButton("Quarry", quarryEnabled)
- saveData()
- setWires()
- end
- --If the "Back" button is pressed
- function Back()
- mainMenu()
- end
- --If the "Reactor" button is clicked.
- function Reactor()
- reactorEnabled = not reactorEnabled
- sleep(0.1)
- button.setButton("Reactor", reactorEnabled)
- print("Reactor has no function")
- saveData()
- setWires()
- end
- function setWires()
- changeEnabled(colors.red,oreProcessEnabled,"back")
- changeEnabled(colors.blue,powerEnabled,"back")
- changeEnabled(colors.white,quarryEnabled,"back")
- end
- --Does stuff with input
- function getClick()
- event ,side,x,y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- --Start of Program
- --Make it fancy
- term.clear()
- term.setCursorPos(1,1)
- print("Base Control By: djgaven588")
- --Load Data
- loadData()
- setWires()
- --Go to main menu
- mainMenu()
- --Detect input
- while true do
- getClick()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement