Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Created and Developed by jaypar(Lapito1297)
- for k,v in pairs(rs.getSides()) do
- if (peripheral.getType(v) == "openperipheral_bridge") then
- glass = peripheral.wrap(v)
- break
- end
- end
- function current()
- if fs.exists("startup") == true then
- c = fs.open("startup", "r")
- ch = c.readAll()
- checked = ch
- return checked
- end
- end
- function update()
- shell.run("pastebin get bE1Kt29y update")
- term.clear()
- term.setCursorPos(1,1)
- u = fs.open("update", "r")
- ud = u.readAll()
- cur = ud
- return cur
- end
- function resp()
- print("Do you wish to update?(please type yes or no)")
- res = io.read()
- term.clear()
- return res
- end
- function upd()
- if firstTime() == false then
- while true do
- if (update() ~= current()) and (resp() == "yes") then
- p = fs.open("startup", "w")
- p.write(ud)
- p.flush()
- shell.run("pastebin get A9NYRnka changelog")
- ch = fs.open("changelog", "r")
- cha = ch.readAll()
- print(cha)
- print("Restart will begin in 25 seconds")
- sleep(20)
- term.clear()
- term.setCursorPos(1,1)
- term.write("Restarting in 5 seconds for update")
- sleep(1)
- term.clear()
- term.setCursorPos(1,1)
- term.write("Restarting in 4 seconds for update")
- sleep(1)
- term.clear()
- term.setCursorPos(1,1)
- term.write("Restarting in 3 seconds for update")
- sleep(1)
- term.clear()
- term.setCursorPos(1,1)
- term.write("Restarting in 2 seconds for update")
- sleep(1)
- term.clear()
- term.setCursorPos(1,1)
- term.write("Restarting in 1 seconds for update")
- sleep(1)
- term.clear()
- term.setCursorPos(1,1)
- term.write("Restarting")
- sleep(0.5)
- shell.run("reboot")
- end
- if fs.exists("changelog") then
- fs.delete("changelog")
- end
- fs.delete("update")
- sleep(0.5)
- end
- end
- end
- function firstTime()
- if fs.exists("reactorOptions") == false then
- return false
- else
- return true
- end
- end
- function onoff(bool)
- react.setActive(bool)
- end
- function reactor()
- Options = {}
- o = fs.open("reactorOptions", "r")
- p = o.readAll()
- Options = textutils.unserialize(p)
- powerMax = Options.powerMax
- powerMin = Options.powerMin
- side = Options.side
- react = peripheral.wrap(side)
- while true do
- power = react.getEnergyStored()
- if power >= powerMax then
- onoff(false)
- end
- if power <= powerMin then
- onoff(true)
- end
- sleep(0.1)
- end
- end
- function main()
- if firstTime() == false then
- Options = {}
- Options = fs.open("reactorOptions", "w")
- term.clear()
- term.setCursorPos(11,1)
- term.write("What side is the Reactor on?")
- term.setCursorPos(11,2)
- term.write("(Examples: back, top, left,")
- term.setCursorPos(16,3)
- term.write("right, bottom)")
- term.setCursorPos(22,4)
- side = io.read()
- term.clear()
- term.setCursorPos(11,1)
- term.write("When do you want the reactor")
- term.setCursorPos(11,2)
- term.write("to turn off?(example: 9000000)")
- term.setCursorPos(22,3)
- powerMax = io.read()
- powerMax2 = textutils.unserialize(powerMax)
- term.clear()
- term.setCursorPos(11,1)
- term.write("When do you want the reactor")
- term.setCursorPos(11,2)
- term.write("to turn on?(Example: 1000)")
- term.setCursorPos(22,3)
- powerMin = io.read()
- powerMin2 = textutils.unserialize(powerMin)
- tab = {
- side = side,
- powerMax = powerMax2,
- powerMin = powerMin2
- }
- Options.write(textutils.serialize(tab))
- Options.flush()
- reactor()
- else
- reactor()
- end
- end
- parallel.waitForAll(main, upd)
Add Comment
Please, Sign In to add comment