Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Settings
- _G.Units = {
- [1] = {"Flux", "KiloFlux", "MegaFlux", "GigaFlux", "TeraFlux", "PetaFlux", "ExaFlux", "ZettaFlux", "YottaFlux"};
- [2] = {"RF", "KRF", "MRF", "GRF", "TRF", "PRF", "ERF", "ZRF", "YRF"}
- }
- integtick = 10
- UnitMult = 1000
- -- Peripherals
- _G.m = peripheral.wrap("left")
- _G.ec = peripheral.wrap("Induction Matrix_4")
- _G.ae = peripheral.wrap("appliedenergistics2:energy_acceptor_0")
- _G.meter = peripheral.wrap("rfmeter_1")
- function _G.testae(ae)
- if ae == nil then
- rs.setOutput("back",true)
- sleep(1)
- rs.setOutput("back",false)
- sleep(1)
- rs.setOutput("back",true)
- sleep(1)
- rs.setOutput("back",false)
- sleep(1)
- ae = peripheral.wrap("appliedenergistics2:energy_acceptor_0")
- else ae = ae end
- return ae
- end
- sleep(1)
- _G.ae = testae(ae)
- -- Peripheral Stuff
- _G.maxX, _G.maxY = m.getSize()
- -- Initialization
- m.setTextScale(0.5)
- m.clear()
- m.setCursorPos(1,1)
- _G.function m.print(STR)
- Mx, My = m.getCursorPos()
- m.write(STR)
- m.setCursorPos(1,My+1)
- end
- _G.hr = ("-"):rep(maxX)
- notation = 1
- -- Buttons
- _G.buttons = {} -- format: title = {x1=x1,y1=y1,x2=x2,y2=y2,callback}
- --[[
- common functions start here
- ]]--
- -- Printing to screen
- function _G.writeIndent(str, indent)
- if indent == nil then indent = 20 end
- local y = ({m.getCursorPos()})[2]
- m.setCursorPos(indent, y)
- m.write((" "):rep(maxX - indent))
- m.setCursorPos(indent, y)
- m.write(str)
- m.setCursorPos(1, y+1)
- end
- -- Colors
- function _G.themeComponent(bg, fg)
- local component = {}
- component.bg = bg
- component.fg = fg
- function component:apply()
- m.setBackgroundColor(self.bg)
- m.setTextColor(self.fg)
- end
- return component
- end
- _G.theme = {
- primary = themeComponent(colors.black, colors.white),
- button = themeComponent(colors.yellow, colors.white),
- button_muted = themeComponent(colors.black, colors.white)
- }
- -- Rounding
- function _G.round(num, numDecimalPlaces)
- local mult = 10^(numDecimalPlaces or 0)
- return math.floor(num * mult + 0.5) / mult
- end
- -- Energy Formatting
- function _G.formatEnergy(E, Unit)
- if E < 0 then
- M = -1
- else
- M = 1
- end
- local I = 1
- E = E*M
- while E >= UnitMult do
- E = E/UnitMult
- I = I+1
- end
- E = E*M
- return round(E,2).." "..Units[Unit][I]
- end
- --[[
- event processing starts here
- ]]--
- function _G.onTouch(x,y)
- for k,v in pairs(buttons) do
- if v.x1 <= x and
- v.y1 <= y and
- v.x2 >= x and
- v.y2 >= y then
- v.callback(k, x, y)
- end
- end
- end
- --[[
- per-peripheral functions start here
- ]]--
- function _G.totalAEItems()
- local all = ae.listAvailableItems()
- local total = 0
- for k,v in pairs(all) do
- total = total + v.count
- end
- return total
- end
- --[[
- custom notation nonsense starts here
- ]]--
- m.setCursorPos(1,maxY)
- m.write("Notation: ")
- m.setCursorPos(20,maxY)
- local _G.NotationText = {"Long", "Short"}
- function _G.renderButtons()
- local before = {m.getCursorPos()}
- m.setCursorPos(20, maxY)
- if notation == 1 then theme.button:apply() else theme.button_muted:apply() end
- m.write(NotationText[1])
- m.setCursorPos(25, maxY)
- if notation == 2 then theme.button:apply() else theme.button_muted:apply() end
- m.write(NotationText[2])
- theme.primary:apply()
- m.setCursorPos(unpack(before))
- end
- function changeNotation(notationId)
- notation = notationId
- renderButtons()
- end
- buttons[1] = {x1 = 20, y1 = maxY, x2 = 23, y2 = maxY, callback = changeNotation}
- buttons[2] = {x1 = 25, y1 = maxY, x2 = 28, y2 = maxY, callback = changeNotation}
- --[[
- more nonsense starts here
- ]]--
- function _G.formatTimer(S)
- local M = 0
- local H = 0
- local D = 0
- S2 = S%60
- M = (S-S2)/60
- M2 = M%60
- H = (M-M2)/60
- H2 = H%24
- D = (H-H2)/24
- S, M, H = S2, M2, H2
- if S <= 9 then S = "0"..S end
- if M <= 9 then M = "0"..M end
- if H <= 9 then H = "0"..H end
- if D <= 9 then D = "0"..D end
- return (D..":"..H..":"..M..":"..S)
- end
- m.setCursorPos(1,1)
- m.print("AE Stuff")
- m.print(hr)
- m.print("AE Energy Usage: ")
- m.print("AE Energy Storage: ")
- m.print(hr)
- m.print("I/O Rate: ")
- m.setCursorPos(1,10)
- m.print("Energy Stuff")
- m.print(hr)
- m.print("Energy Net: ")
- m.setTextColor(colors.lime)
- m.print("|Energy Input: ")
- m.setTextColor(colors.red)
- m.print("|Energy Output: ")
- m.setTextColor(colors.white)
- m.print("Energy Meter: ")
- m.print("Energy Available: ")
- m.print("Energy Storage: ")
- m.print("Time Till 0 RF: ")
- m.setCursorPos(1,21)
- m.print("Notation Conversion")
- m.print(hr)
- m.print("Kilo - Thousand (K - K)")
- m.print("Mega - Million (M - M)")
- m.print("Giga - Billion (G - B)")
- m.print("Tera - Trillion (T - T)")
- m.print("Peta - Quadrillion (P - Qa)")
- m.print("Exa - Quintillion (E - Qi)")
- m.print("Zetta - Sextillion (Z - Sx)")
- m.print("Yotta - Septillion (Y - Sp)")
- renderButtons()
- lastTotal = 0
- lastIOTime = os.clock()
- parallel.waitForAny(function()
- Tnum = 0
- Tneb = {}
- while true do
- --shell.run("ExtrTresBG")
- sleep(0)
- end
- end,
- function()
- while true do
- local event, side, x, y = os.pullEvent("monitor_touch")
- onTouch(x,y)
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement