Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local event = require("event")
- local term = require("term")
- local colors = require("colors")
- local gpu = component.gpu
- local screen = component.screen
- local reactor = component.br_reactor
- local turbine = component.br_turbine
- local bigbat = component.big_battery
- local rfm = component.rfmeter
- local running = true
- local active = false
- local function printXY(x, y, text)
- term.setCursor(x, y)
- print(text)
- end
- local function round(num, idp)
- local mult = 10 ^ (idp or 0)
- return math.floor((num * mult) + 0.5) / mult
- end
- local function shutdown()
- event.ignore("touch")
- setStatus(false)
- active = false
- running = false
- end
- local function checkThreshold(value, threshold, method, param)
- if value < threshold then do
- method(param)
- end
- end
- local function percentage(max, value)
- return (max / value) * 100
- end
- local function getClick(_, x, y, _, _)
- if x > 1 and x < 3 and y > 1 and y < 3 and active == false then do
- setStatus(true)
- end
- else if x > 1 and x < 3 and y > 1 and y < 3 and active == true then do
- setStatus(false)
- end
- else if x > 72 and x < 74 and y > 0 and y < 2 then do
- shutdown()
- end
- end
- local function setStatus(bool)
- reactor.setActive(bool)
- for adress, componentType in component.list(br_turbine) do
- component.invoke(adress, "setInductorEngaged(bool)")
- engaged = bool
- end
- end
- event.listen("touch", getClick)
- setStatus(active)
- term.clear()
- term.setCursorBlink(false)
- screen.setTouchModeInverted(true)
- screen.setPrecise(true)
- gpu.setResolution(73, 50)
- while running do
- checkThreshold(percentage(bigbat.getMaxEnergyStored(), bigbat.getEnergyStored()), 5, setStatus, true)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement