Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if shell.getRunningProgram() ~= "startup" then
- print("script not properly installed")
- print("do you want to install autoreactor to this computer and reboot? [y/n]")
- input= read("*")
- if input == "y" or input == "Y" then
- if fs.exists("/startup") == true then
- print ("setup has detected a startup on this computer, overwrite? y/n")
- input = read("*")
- if input == "N" or input == "n" then
- os.exit()
- else
- shell.run("rm /startup")
- end
- end
- shell.run("cp "..shell.getRunningProgram().." /startup")
- print ("Copy compleete, please remove anny disks")
- while true do
- if fs.exists("/disk/startup") == false then
- os.reboot()
- end
- os.sleep(5)
- end
- end
- end
- sides = {"top","front","back","bottom","left","right"}
- reactorstring = "BigReactors-Reactor"
- turbinestring = "BigReactors-Turbine"
- monitorstring = "monitor"
- modemstring = "modem"
- modemchannel = 666 -- dont ask me why
- modemsendrate = 1.0
- reactorside = nil
- turbineside = nil
- monitorside = nil
- modemside = nil
- mincoolant = 5000
- targetspeed = 1839.2
- speedupto = 1500
- panniccoolant = 1000
- delay = 0.2
- print "detecting sides "
- for a= 1,6 do
- if peripheral.isPresent(sides[a]) then
- device = peripheral.getType(sides[a])
- print (sides[a]..": "..device)
- if device == reactorstring then
- print("Found a reactor on side: ".. sides[a])
- reactorside = sides[a]
- elseif device == turbinestring then
- print("Found a Turbine on side: ".. sides[a])
- turbineside = sides[a]
- elseif device == modemstring then
- print("Found a modem on side: "..sides[a])
- modemside = sides[a]
- elseif device == monitorstring then
- print("Found a monitor on side: "..sides[a])
- monitorside = sides[a]
- end
- end
- end
- if reactorside ~= nil and turbineside ~= nil then
- error("You cant controle both with one computer")
- elseif reactorside==nil and turbineside==nil and monitorside == nil then
- error("You need to place this computer agianst a computerport or a monitor!")
- elseif monitorside ~= nil and modemside == nil then
- error("Found a monitor but no modem")
- end
- if monitorside ~= nil then
- print("monitor started")
- modem = peripheral.wrap(modemside) -- bothway
- modem.open(modemchannel)
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- print("The message was: "..message)
- print("The sender is: "..(senderDistance or "an unknown number of").." blocks away from me.")
- end
- print("setup fase finished!")
- if reactorside ~= nil then
- if modemside ~= nil then
- modem = peripheral.wrap(modemside)
- modem.open(modemchannel)
- modem.transmit(modemchannel,modemchannel,"test")
- end
- -- reactorscript
- term.clear()
- reactor = peripheral.wrap(reactorside)
- maxfluid = reactor.getHotFluidAmountMax()
- pump = false
- while true do
- hotfluid = reactor.getHotFluidAmount()
- coolant= reactor.getCoolantAmount()
- if coolant < mincoolant then
- for a=1,6 do
- rs.setOutput(sides[a],true)
- end
- pump = true
- elseif pump == true then
- pump = false
- for a=1,6 do
- rs.setOutput(sides[a],false)
- end
- end
- t = hotfluid / maxfluid
- if coolant < panniccoolant then
- t = 1
- end
- reactor.setAllControlRodLevels(t*100)
- term.setCursorPos(1,1)
- -- reminder we can also catch fuel levels
- sendstring = "RDATA"
- print ("rodlevel: "..(t*100).."%")
- sendstring = sendstring .. ":"..t
- print ("Fuel temp: "..reactor.getFuelTemperature().." C")
- sendstring = sendstring .. ":".. reactor.getFuelTemperature()
- print ("Casing temp: "..reactor.getCasingTemperature().." C")
- sendstring = sendstring .. ":".. reactor.getCasingTemperature()
- print ("Steam : "..reactor.getHotFluidProducedLastTick() .." Mb/t")
- sendstring = sendstring .. ":".. reactor.getHotFluidProducedLastTick()
- print ("coolant: "..reactor.getCoolantAmount() .." Mb")
- sendstring = sendstring .. ":".. reactor.getCoolantAmount()
- print ("is running: "..tostring( reactor.getActive()) )
- sendstring = sendstring .. ":".. tostring(reactor.getActive())
- print ("reactor rods: "..reactor.getNumberOfControlRods())
- print ("reactor fuelspace :"..reactor.getFuelAmountMax())
- local maxx,maxy,maxz = reactor.getMaximumCoordinate()
- local minx,miny,minz = reactor.getMinimumCoordinate()
- print ("Reactorsize : ".. (1+(maxx-minx)).." X "..(1+(maxz-minz)).." X "..(1+(maxy-miny)))
- print ("Cyanide : "..reactor.getWasteAmount())
- print ("Fuel: "..reactor.getFuelAmount())
- print ("Consumtion rate: "..reactor.getFuelConsumedLastTick())
- print ("Fertilization: "..reactor.getFuelReactivity())
- modem.transmit(modemchannel,modemchannel,sendstring)
- os.sleep(delay)
- end
- end
- if turbineside ~= nil then
- if modemside ~= nil then
- modem =peripheral.wrap(modemside)
- modem.open(modemchannel)
- modem.transmit(modemchannel,modemchannel,"Ttest")
- end
- -- turbine script
- term.clear()
- turbine = peripheral.wrap(turbineside)
- turbine.setVentNone()
- vent = false
- while true do
- if turbine.getOutputAmount() > (turbine.getFluidAmountMax()/2) then
- turbine.setVentAll()
- vent = true
- elseif vent == true then
- vent = false
- turbine.setVentNone()
- end
- term.setCursorPos(1,1)
- speed = turbine.getRotorSpeed()
- if speed < speedupto then
- turbine.setInductorEngaged(false)
- turbine.setFluidFlowRateMax(2000)
- elseif speed > targetspeed then
- if turbine.getEnergyStored() > 900000 then
- turbine.setInductorEngaged(false)
- else
- turbine.setInductorEngaged(true)
- end
- overspeed = speed - targetspeed
- turbine.setFluidFlowRateMax(2000 -math.pow( overspeed,overspeed))
- else
- turbine.setFluidFlowRateMax(2000)
- if turbine.getEnergyStored() > 900000 then
- turbine.setInductorEngaged(false)
- else
- turbine.setInductorEngaged(true)
- end
- end
- print("speed: "..speed.. " RPM")
- print ("producing: "..turbine.getEnergyProducedLastTick ().." rf/t")
- print ("Flowrate: "..turbine.getFluidFlowRate().." Mb/t")
- print ("inductor: "..tostring(turbine.getInductorEngaged()))
- print ("is running: "..tostring(turbine.getActive()) )
- print ("RotorMass: "..turbine.getRotorMass())
- print ("Efficiency: "..turbine.getBladeEfficiency())
- print ("Output: "..turbine.getOutputAmount())
- print ("Blade: "..turbine.getNumberOfBlades())
- print ("Energy: "..turbine.getEnergyStored())
- print ("Input: "..turbine.getInputAmount())
- print ("Flow: "..turbine.getFluidFlowRate())
- local maxx,maxy,maxz = turbine.getMaximumCoordinate()
- local minx,miny,minz = turbine.getMinimumCoordinate()
- print ("turbineSize: "..(1+(maxx-minx)).." X "..(1+(maxz-minz)).." X "..(1+(maxy-miny)))
- os.sleep(delay)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement