Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("touchpoint")
- local modem = peripheral.wrap("back")
- local monSide = "right"
- local mon = peripheral.wrap(monSide)
- modem.open(1)
- cells = {}
- turbine = "BigReactors-Turbine_0"
- reactor = "BigReactors-Reactor_0"
- reactorActive = modem.callRemote(reactor, "getActive")
- turbineActive = modem.callRemote(turbine, "getActive")
- pages =
- {
- mainMenu = touchpoint.new(monSide),
- reactorControl = touchpoint.new(monSide),
- energyNetwork = touchpoint.new(monSide),
- machines = touchpoint.new(monSide)
- }
- t = pages[mainMenu]
- maxEnergy = 0
- energy = {}
- curTotalEnergy = -1
- curTotalEnergyPercent = 0
- energyLastTick = -1
- energyPerTick = -1
- -- Fetch the names of the cells from the modems net
- function getCells()
- names = modem.getNamesRemote()
- for i, v in ipairs(names) do
- if v:find("cofh_thermalexpansion_energycell_") ~= nil then
- table.insert(cells, v)
- end
- end
- end
- -- Get current amount of energy from each cell
- function getEnergy()
- if curTotalEnergy ~= -1 then
- energyLastTick = curTotalEnergy
- end
- curTotalEnergy = 0
- curTotalEnergyPercent = 0
- energy = {}
- for token in p4:gmatch("%d+") do
- table.insert(energy, tonumber(token))
- curTotalEnergy = curTotalEnergy + tonumber(token)
- end
- curTotalEnergyPercent = curTotalEnergy / maxEnergy * 100
- if energyLastTick ~= -1 then
- energyPerTick = (curTotalEnergy - energyLastTick) / #energy
- end
- end
- function toggleReactor()
- pages.reactorControl:toggleButton("reactor")
- reactorActive = not reactorActive
- modem.callRemote(reactor, "setActive", reactorActive)
- end
- function toggleTurbine()
- pages.reactorControl:toggleButton("turbine")
- turbineActive = not turbineActive
- modem.callRemote(turbine, "setActive", turbineActive)
- end
- function toggleQuarry()
- end
- function toggleDrill()
- end
- function drawGUI()
- end
- function changePage(page)
- t = pages.page
- end
- -- Initialize Buttons
- buttons =
- {
- mainMenu =
- {
- {
- " ",
- " Reactor Control ",
- " ",
- label = "reactorControl"
- },
- {
- " ",
- " Energy Network ",
- " ",
- label = "energyNetwork"
- },
- {
- " ",
- " Various Machines ",
- " ",
- label = "machines"
- }
- },
- reactorControl =
- {
- {
- " ",
- " Reactor ",
- " ",
- label = "reactor"
- },
- {
- " ",
- " Turbine ",
- " ",
- label = "turbine"
- },
- {
- " ",
- " Back ",
- " ",
- label = "backReactor"
- }
- },
- energyNetwork =
- {
- " ",
- " Back ",
- " ",
- label = "backEnergy"
- },
- machines =
- {
- {
- " ",
- " Quarry ",
- " ",
- label = "quarry"
- },
- {
- " ",
- " Laser Drill ",
- " ",
- label = "drill"
- },
- {
- " ",
- " Back ",
- " ",
- label = "backMachines"
- }
- }
- }
- print("New1")
- -- ERROR RIGHT HERE
- buttonFuncs =
- {
- mainMenu = {changePage(reactorControl), changePage(energyNetwork), changePage(machines)},
- reactorControl = {toggleReactor(), toggleTurbine(), changePage(mainMenu)},
- energyNetwork = {changePage(mainMenu)},
- machines = {toggleQuarry(), toggleDrill(), changePage(mainMenu)}
- }
- -- RIGHT HERE
- print("New2")
- local xPos
- local yPos = 3
- for i = 1, #buttons.mainMenu do
- local width = 22
- local height = 2
- if i % 2 == 1 then
- xPos = 2
- yPos = yPos + 4
- else
- xPos = 27
- end
- pages.mainMenu:add(buttons.mainMenu[i], buttonFuncs.mainMenu[i], xPos, yPos, xPos + width, yPos + height, colors.red, colors.lime)
- end
- --[[for i = 1, #buttons.reactorControl do
- local width = 22
- local height = 2
- if i % 2 == 1 then
- xPos = 2
- yPos = yPos + 4
- else
- xPos = 27
- end
- print(xPos)
- print(yPos)
- mainMenu:add(buttons.reactorControl[i], buttonFuncs.reactorControl[i], xPos, yPos, xPos + width, yPos + height, colors.red, colors.lime)
- end]]--
- -- Fetch cells
- getCells()
- -- Get amount of total storage available
- for i,v in ipairs(cells) do
- maxEnergy = maxEnergy + modem.callRemote(v, "getMaxEnergyStored", "direction")
- end
- while true do
- t:draw()
- e, p1, p2, p3, p4, p5 = mainMenu:handleEvents(os.pullEvent())
- if e == "modem_message" then
- getEnergy()
- if curTotalEnergyPercent <= 10 then
- setEnergy(true)
- elseif curTotalEnergyPercent >= 90 then
- setEnergy(false)
- end
- elseif e == "button_click" then
- t.buttonList[p1].func()
- end
- drawGUI()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement