Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ NOTE
- // With automode on the code will try to keep
- // around 10% RF in its internal storage, it does this by regulating the control rod
- // after the demand OF rf, moving up slowly.
- --]]
- -- Wrapping and requireing essentials API's and components --
- component = require("component")
- reactor = component.br_reactor
- event = require("event")
- term = require("term")
- gpu = component.gpu
- event = require("event")
- keyboard = require("keyboard")
- ------------------
- -- Color table --
- colors = { black = 0x000000, white = 0xf8f8ff, blue = 0x0000ff, lightGray = 0xd9d9d9, red = 0xff0000,
- purple = 0x9b30ff, carrot = 0xffa500, magenta = 0xcd00cd, lightBlue = 0x87cefa, yellow = 0xffff00,
- lime = 0x32cd32, pink = 0xffc0cb, gray = 0x696969, brown = 0x8b4500, green = 0x006400, cyan = 0x008b8b,
- olive = 0x6b8e23, gold = 0x8b6914, orangered = 0xdb4e02, diamond = 0x0fa7c7,crimson = 0xaf002a,fuchsia = 0xfd3f92,
- folly = 0xff004f, frenchBlue = 0x0072bb, lilac = 0x86608e, flax = 0xeedc82, darkGray = 0x563c5c,
- englishGreen = 0x1b4d3e, eggplant = 0x614051, deepPink = 0xff1493, ruby = 0x843f5b, orange = 0xf5c71a,
- lemon = 0xffd300, darkBlue = 0x002e63, bitterLime = 0xbfff00 }
- -------------------------
- -- Settings for screen --
- gpu.setBackground(colors.black)
- gpu.setForeground(colors.orange)
- gpu.setResolution(50,10)
- term.clear()
- -------------------------
- --Vars --
- auto = false
- numm = 100
- --
- -- Functions --
- function display()
- if auto == false then
- if stat == true then
- gpu.set(19,2, "ON ")
- else
- gpu.set(19,2, "OFF ")
- end
- elseif auto == true then
- gpu.set(19,2, "---- ")
- end
- gpu.set(1,1, "Reactor Info....: ")
- gpu.set(1,2, "Reactor status..: ")
- gpu.set(1,3, "RF Production...: ".. string.format("%.2f", reactor.getEnergyProducedLastTick()).." RF/T ")
- gpu.set(1,4, "RF Internal.....: ".. reactor.getEnergyStored() .."/"..reactor.getEnergyCapacity().."(".. math.floor((reactor.getEnergyStored()/reactor.getEnergyCapacity()*100)) .."%) RF ")
- gpu.set(1,5, "Fuel use........: ".. string.format("%.2f", reactor.getFuelConsumedLastTick()) .."mB")
- gpu.setBackground(colors.white)
- gpu.setForeground(colors.black)
- gpu.set(2,6, " ON ")
- --gpu.setBackground(colors.blue)
- gpu.set(6,6, " OFF ")
- --gpu.setBackground(colors.)
- gpu.set(11,6, " Auto ")
- gpu.setBackground(colors.black)
- gpu.set(17,6," ")
- gpu.setBackground(colors.black)
- gpu.setForeground(colors.orange)
- end
- function buttonPress()
- if x~=nil and y ~= nil then
- if x >= 1 and x <= 4 and y == 6 then
- if auto == false then
- gpu.setBackground(colors.black)
- gpu.set(2,6," ON ")
- reactor.setAllControlRodLevels(0)
- stat = true
- end
- elseif x >= 5 and x <= 9 and y == 6 then
- if auto == false then
- gpu.setBackground(colors.black)
- gpu.set(5,6," OFF ")
- reactor.setAllControlRodLevels(100)
- stat=false
- end
- elseif x >= 11 and x <= 17 and y == 6 then
- if auto == false then
- auto = true
- else
- auto = false
- end
- end
- end
- end
- function autoMode()
- if auto == true then
- gpu.set(1,6, " ")
- gpu.set(9,6, "AUTO MODE ON")
- if reactor.getEnergyStored() >= (reactor.getEnergyCapacity() / 100 * 10) then
- reactor.setAllControlRodLevels(100)
- stat = false
- numm = 100
- elseif reactor.getEnergyStored() <= (reactor.getEnergyCapacity()/100 * 10) then
- startinit()
- reactor.setAllControlRodLevels(numm)
- stat = true
- elseif reactor.getEnergyStored() <= (reactor.getEnergyCapacity()/100 * 2) then
- reactor.setAllControlRodLevels(0)
- stat = true
- end
- end
- end
- function startinit()
- os.sleep(.3)
- numm = numm - 1
- end
- ------------------------
- -- Main Loop --
- term.clear()
- while true do
- display()
- autoMode()
- gpu.set(1,15, tostring(auto))
- _,_,x,y = event.pull(1, "touch")
- buttonPress()
- if keyboard.isKeyDown(keyboard.keys.w) and keyboard.isControlDown() then
- term.clear()
- w,h = gpu.maxResolution()
- gpu.setResolution(w,h)
- os.exit()
- end
- os.sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement