os.loadAPI("buttonAPI") page1=buttonAPI.new() page2=buttonAPI.new() reactorTemp = 600 rotorSpeed = 1800 info = {} t = {} m = {} r = {} c = {} function getDevices() for _, name in pairs(peripheral.getNames()) do if peripheral.getType(name) == "BigReactors-Turbine" then table.insert(t, peripheral.wrap(name)) elseif peripheral.getType(name) == "monitor" then table.insert(m, peripheral.wrap(name)) elseif peripheral.getType(name) == "BigReactors-Reactor" then table.insert(r, peripheral.wrap(name)) elseif peripheral.getType(name) == "draconic_rf_storage" then table.insert(c, peripheral.wrap(name)) elseif peripheral.getType(name) == "Induction Matrix" then IM = peripheral.wrap(name) IMtf = true end end print("Turbines found: "..#t) print("monitors found: "..#m) print("Reactors found: "..#r) print("Energy Cores : "..#c) end function numberMonitors() for i = 1, #m do m[i].setBackgroundColor(colors.black) m[i].clear() m[i].setCursorPos(1,1) m[i].setTextScale(5) m[i].write(tostring(i)) end end function addMon(name) mon = string.gsub(name,"%a","") mon = string.gsub(mon,"%s","") mon = tonumber(mon) m[mon].write(" OK") table.insert(info, currentText..": "..mon) if numOfMonitors == 2 then currentPage = page2 else numOfMonitors = numOfMonitors + 1 end end function addPage1Buttons() posX = 1 posY = 4 for i=1,#m do page1:add("monitor "..i, nil, posX, posY, posX+11, posY+2, colors.blue, colors.lime) posY=posY+4 if posY >= 17 then posY=4 posX=posX+13 end end end function addPage2Buttons() local reactor100 = { " -100 ", label = "r-100" } local reactor10 = { " -10 ", label = "r-10" } local reactor5 = { " -5 ", label = "r-5" } local reactorr5 = { " +5 ", label = "r+5" } local reactorr10 = { " +10 ", label = "r+10" } local reactorr100 = { " +100 ", label = "r+100" } page2:add(reactor100, function() reactorTemp = reactorTemp - 100 end, 1, 5, 6, 5, colors.purple, colors.lime) page2:add(reactor10, function() reactorTemp = reactorTemp - 10 end, 8, 5, 13, 5, colors.purple, colors.lime) page2:add(reactor5, function() reactorTemp = reactorTemp - 5 end, 15, 5, 20, 5, colors.purple, colors.lime) page2:add(reactorr5, function() reactorTemp = reactorTemp + 5 end, 32, 5, 37, 5, colors.purple, colors.lime) page2:add(reactorr10, function() reactorTemp = reactorTemp + 10 end, 39, 5, 44, 5, colors.purple, colors.lime) page2:add(reactorr100, function() reactorTemp = reactorTemp + 100 end, 46, 5, 51, 5, colors.purple, colors.lime) local turbine100 = { " -100 ", label = "t-100" } local turbine10 = { " -10 ", label = "t-10" } local turbine5 = { " -5 ", label = "t-5" } local turbinee5 = { " +5 ", label = "t+5" } local turbinee10 = { " +10 ", label = "t+10" } local turbinee100 = { " +100 ", label = "t+100" } page2:add(turbine100, nil, 1, 12, 6, 12, colors.purple, colors.lime) page2:add(turbine10, nil, 8, 12, 13, 12, colors.purple, colors.lime) page2:add(turbine5, nil, 15, 12, 20, 12, colors.purple, colors.lime) page2:add(turbinee5, nil, 32, 12, 37, 12, colors.purple, colors.lime) page2:add(turbinee10, nil, 39, 12, 44, 12, colors.purple, colors.lime) page2:add(turbinee100, nil, 46, 12, 51, 12, colors.purple, colors.lime) page2:add("save",function() end,46,19,51,19,colors.lime,colors.purple) page2:add("exit",function() end,1,19,6,19,colors.purple,colors.lime) end function numBoxes() if currentPage == page2 then term.setTextColor(colors.white) term.setBackgroundColor(colors.gray) pos = {} pos[1] = 3 pos[2] = 10 for v=1,2 do for i=1,3 do term.setCursorPos(22,pos[v]+i) term.write(string.rep(" ",9)) end end term.setCursorPos(25,5) term.write(tostring(reactorTemp)) term.setCursorPos(25,12) term.write(tostring(rotorSpeed)) end end function title() term.setTextColor(colors.orange) term.setBackgroundColor(colors.black) if currentPage == page1 then if numOfMonitors == 0 then currentText = "Reactors" elseif numOfMonitors == 1 then currentText = "Turbines" elseif numOfMonitors == 2 then currentText = "Energy Cores" end term.setCursorPos(12,2) term.write("Select a monitor for: "..currentText) else term.setCursorPos(14,3) term.write("Avg. Reactor Temperature") term.setCursorPos(18,10) term.write("Avg. Rotor Speed") end end function save() local file = fs.open("config","w") local text = "" for _, line in pairs(info) do text = text..line.."\n" end file.write(text) file.close() end numOfMonitors = 0 currentPage=page1 getDevices() numberMonitors() addPage1Buttons() addPage2Buttons() while true do currentPage:draw() title() numBoxes() local event, p1 = currentPage:handleEvents(os.pullEvent()) if event == "button_click" then if currentPage == page1 then if not page1.buttonList[p1].active then page1:toggleButton(p1) addMon(p1) end else if p1 == "exit" then break elseif p1 == "save" then save() else page2:flash(p1) page2:run(p1) end end end end