Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- <<< Settings >>> --
- local sleepTime = 0 -- Time to sleep (values greater than 0.5 will save energy consumed by the computer)
- local maxRate = 90 -- Maximum injectionrate to heat up
- local wantedRate = 20 -- Wanted injectionrate for the fuel
- local minRate = 10 -- Minimum injectionrate cool down (NOT LOWER THAN 1 OR YOUR REACTOR WILL TURN OFF!)
- local enableGui = false -- Enable the Gui on the screen (true or false)
- -- <<< Code >>> --
- components = require("component")
- event = require("event")
- r = components.proxy(components.list("reactor_logic_adapter")())
- energyGenerated = 0
- screenScale = 4
- r.setInjectionRate(wantedRate)
- maxCaseHeat = r.getMaxCaseHeat()
- maxPlasmaHeat = r.getMaxPlasmaHeat()
- rate = wantedRate
- caseHeat = tonumber(r.getCaseHeat())
- plasmaHeat = tonumber(r.getPlasmaHeat())
- hasFuel = r.hasFuel()
- isIgnited = r.isIgnited()
- function overheated()
- if r.getCaseHeat() > maxCaseHeat then
- return true
- elseif r.getPlasmaHeat() > maxPlasmaHeat then
- return true
- else
- return false
- end
- end
- function round(x, dezimals)
- local multi = 10^(dezimals or 0)
- return ((x * multi) + 0.5 - (x * multi + 0.5) % 1) / multi
- end
- function regulation()
- local percent = round((((plasmaHeat/maxPlasmaHeat) * 100) + ((caseHeat/maxCaseHeat) * 100)) / 2, 1)
- local newRate = wantedRate
- if percent > 100.2 then
- if rate > wantedRate then
- rate = wantedRate
- end
- newRate = rate - 1
- elseif percent < 99.8 then
- if rate < wantedRate then
- rate = wantedRate
- end
- newRate = rate + 1
- end
- if newRate < minRate then
- newRate = minRate
- elseif newRate > maxRate then
- newRate = maxRate
- end
- r.setInjectionRate(newRate)
- end
- local run = true
- while run do
- rate = tonumber(r.getInjectionRate())
- caseHeat = tonumber(r.getCaseHeat())
- plasmaHeat = tonumber(r.getPlasmaHeat())
- energyGenerated = tonumber(r.getEnergy()) * 0.4
- regulation()
- if enableGui then
- gui()
- end
- local e = event.pull(sleepTime, "key_down")
- if e then
- run = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment