Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Extreme Reactors Utility Script Mk 1
- Author: Evan Robertson
- Created: 2023-06-02
- Updated: 2023-06-02
- A generic utility script to be used with Computer Craft / CC:Tweaked and Extreme Reactors
- ]]--
- --[[
- Globals
- ]]
- local clock = os.clock
- --[[
- clearScreen
- clears the computer's output
- ]]
- local function clearScrean()
- for i=1,13 do
- print("")
- end
- end
- local function displayMenu()
- clearScrean()
- print("Reactor Toolkit Mk1")
- print("~~~~~")
- print("WIP!")
- print("~~~~~")
- print("Please Choose an option:")
- print("")
- print("1. Monitor Mode")
- print("")
- print("Type help to view help menu or exit to quit")
- end -- function printMenu
- local function displayHelpMenu()
- clearScrean()
- print("Reactor Toolkit Mk1")
- print("~~~~~")
- print("Choose an option to get help on:")
- print("~~~~~")
- print("Please Choose an option:")
- print("")
- print("1. Monitor Mode")
- print("")
- print("Enter exit to return to main menu")
- end -- function printHelpMenu
- local function displayOptionHelp(option)
- if option == nil then
- print("invalid option!")
- print("Press enter to return")
- read()
- return
- end -- if nil or NaN
- if option == 1 then
- clearScrean()
- print("Monitor Mode: ")
- print("~~~~~")
- print("Attach to a reactor's computer port and the computer will monitor the reactor's energy storage.")
- print("When storage is full, turns off the reactor to preserve fuel.")
- print("WIP - Monitoring heat, fuel consumption levels, and compiling data so you can be more informed as to how to improve reactor efficiency.")
- print("Press enter to return")
- read()
- end -- if option 1
- end -- function displayOptionHelp
- --[[
- sleep
- makes the program wait n number of seconds
- ]]
- local function pauseProg(n) -- seconds
- local t0 = clock()
- while clock() - t0 <= n do end
- end -- function sleep
- --[[
- wrapReactor
- Checks for a reactor peripheral and wraps it onto a global
- returns the wrapped reactor or false if no reactor was found
- ]]
- local function wrapReactor()
- local wrappedReactor
- wrappedReactor = peripheral.wrap('back')
- if peripheral.getType(wrappedReactor) == "BigReactors-Reactor" then
- return wrappedReactor
- end
- wrappedReactor = peripheral.wrap('left')
- if peripheral.getType(wrappedReactor) == "BigReactors-Reactor" then
- return wrappedReactor
- end
- wrappedReactor = peripheral.wrap('right')
- if peripheral.getType(wrappedReactor) == "BigReactors-Reactor" then
- return wrappedReactor
- end
- wrappedReactor = peripheral.wrap('front')
- if peripheral.getType(wrappedReactor) == "BigReactors-Reactor" then
- return wrappedReactor
- end
- wrappedReactor = peripheral.wrap('top')
- if peripheral.getType(wrappedReactor) == "BigReactors-Reactor" then
- return wrappedReactor
- end
- wrappedReactor = peripheral.wrap('bottom')
- if peripheral.getType(wrappedReactor) == "BigReactors-Reactor" then
- return wrappedReactor
- end
- return false
- end -- function wrapReactor
- --[[
- monitorReactor
- Monitors the reactor's fuel level, energy storage, and toggles the power on/off
- ]]
- local function monitorReactor(reactor)
- local fuel
- local maxFuel
- local caseTemp
- local energy
- local maxEnergy
- local energyStats
- local fuelStats
- local isActive
- -- to turn on: reactor.setActive()
- fuel = reactor.getFuelAmount()
- maxFuel = reactor.getFuelAmountMax()
- energy = reactor.getEnergyStored()
- maxEnergy = reactor.getEnergyCapacity()
- caseTemp = reactor.getCasingTemperature()
- energyStats = reactor.getEnergyStats()
- fuelStats = reactor.getFuelStats()
- isActive = reactor.getActive()
- if fuel == 0 then
- print("Ran out of fuel!")
- return
- else
- print("Fuel:",fuel)
- end
- if energy < maxEnergy then
- if not isActive then
- reactor.setActive(true)
- end
- else
- if isActive then
- reactor.setActive(false)
- end
- end
- if isActive then print("Reactor Status: Powered on") else print("Reactor Status: Powered off") end
- pauseProg(5)
- sleep(0)
- monitorReactor(reactor)
- end -- monitorReactor
- -- main program
- local input
- local success
- input = ""
- while input ~= "exit" do
- displayMenu()
- input = read()
- if input == "1" then
- clearScrean()
- success = wrapReactor()
- if not success then
- print("No reactor found! Ensure a Reactor Computer Port and a working reactor are connected to the computer.")
- return
- end
- monitorReactor(success)
- return
- elseif input == "help" then
- input = ""
- while input ~= "exit" do
- displayHelpMenu()
- input = read()
- displayOptionHelp(input)
- end
- input = ""
- end
- end
- print("Program exit. Thank you for using Reactor Toolkit Mk1.")
- --[[
- for key, value in pairs(rea) do print(key) read() end
- ]]
Advertisement
Comments
-
- the string SXZXNJZr line 93 isnt working error saying getType string or table expected, got nil.
Add Comment
Please, Sign In to add comment
Advertisement