Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local log_file = "LOG"
- local button_log = "BUTTON_LOG"
- local save_direct = "saves"
- do
- if fs.exists(tostring(save_direct.."/"..log_file)) then fs.delete(tostring(save_direct.."/"..log_file)) end
- if fs.exists(tostring(save_direct.."/"..button_log)) then fs.delete(tostring(save_direct.."/"..button_log)) end
- log_add = function(...)
- local params = {...}
- local text = tostring(params[1])
- local filehandler = fs.open(tostring(save_direct.."/"..log_file), 'a')
- if params[2] then text = "--"..params[1] end
- filehandler.write(text)
- filehandler.write("\n")
- filehandler.close()
- return true
- end
- log_button = function(...)
- local params = {...}
- local text = tostring(params[1])
- local filehandler = fs.open(tostring(save_direct.."/"..button_log), 'a')
- if params[2] then text = "--"..params[1] end
- filehandler.write(text)
- filehandler.write("\n")
- filehandler.close()
- return true
- end
- end
- -- LABEL --
- if not os.getComputerLabel() then
- term.clear() term.setCursorPos(1,1)
- log_add("no computer label")
- print("Enter computer label: ")
- os.setComputerLabel(read())
- log_add("computer label added: "..os.getComputerLabel())
- term.clear()
- end
- -- SETTINGS --
- local settings_file = "config"
- local settings_template = [[-- adjust these configuration options as necessary.
- -- IMPORTANT!, API won't load if there are spaces in the values
- COMPUTER_LABEL = "${label}"
- COMPUTER_ID = ${id}
- HEADING = "${heading}"
- HOPPER_DIRECTION = "${hopper_direction}"
- CHEST_DIRECTION = "${chest_direction}"
- SCREEN_REFRESH_RATE = ${refresh_rate}
- TEXT_SCALE = ${text_scale}
- CONTROL_ROD = ${control_rod}
- REACTOR_ON = "${reactor_on}"
- ]]
- local function interpolate(s, params)
- return s:gsub('($%b{})', function(w) return params[w:sub(3, -2)] or w end)
- end
- do
- save_settings = function()
- local filehandler = fs.open(tostring(save_direct.."/"..settings_file), "w")
- settings = {
- label = COMPUTER_LABEL or os.getComputerLabel(),
- id = os.getComputerID(),
- heading = HEADING or "Savage_Reactor",
- hopper_direction = HOPPER_DIRECTION or "south",
- chest_direction = CHEST_DIRECTION or "down",
- refresh_rate = SCREEN_REFRESH_RATE or 300,
- text_scale = TEXT_SCALE or 1,
- control_rod = CR or CONTROL_ROD or 50,
- reactor_on = RO or REACTOR_ON or "false"
- }
- filehandler.write(interpolate(settings_template, settings))
- filehandler.close()
- log_add("settings saved")
- end
- load_settings = function()
- if fs.exists(tostring(save_direct.."/"..settings_file)) == false then
- log_add("Settings file not found", true)
- log_add("Generating Settings")
- save_settings()
- return
- else
- os.unloadAPI(tostring(save_direct.."/"..settings_file))
- if os.loadAPI(tostring(save_direct.."/"..settings_file)) == false then log_add("Could not load the settings file!", true) end
- CONFIG = nil
- for k, v in pairs(_G) do
- if k == settings_file then CONFIG = v break end
- end
- if CONFIG == nil then log_add("CONFIG came up nil", true) end
- end
- end
- load_settings()
- end
- -- SAVE/LOAD --
- do
- load_one = function(command)
- if fs.exists(command) then
- local fileHandler = fs.open(command, 'r')
- return textutils.unserialize(fileHandler.readAll())
- end
- end
- save_one = function(command1, command2)
- local fileHandler = fs.open(command1, 'w')
- fileHandler.write(textutils.serialize(command2))
- fileHandler.close()
- log_add("Saving: "..command1)
- end
- end
- local sides = {[1] = "front", [2] = "back", [3] = "left", [4] = "right", [5] = "top", [6] = "bottom"}
- local screens, capacitors, appl_energ, echest, stats, reactor = {[1] = term}, {}, {}, {}, {}, {}
- if fs.exists(save_direct.."/stats") then stats = load_one(tostring(save_direct.."/stats")) else save_one(tostring(save_direct.."/stats"), stats) end
- local value = {["item.ingotyellorium"] = 1,
- ["item.eyeofender"] = 0.5}
- value["item.ingotcyanite"] = value["item.ingotyellorium"] / 2
- value["item.ingotblutonium"] = value["item.ingotyellorium"]
- value["item.dustcyanite"] = value["item.ingotyellorium"] / 2
- value["item.dustyellorium"] = value["item.ingotyellorium"]
- value["item.dustblutonium"] = value["item.ingotyellorium"]
- value["tile.brmetal.0"] = value["item.ingotyellorium"] * 9
- value["tile.brmetal.1"] = value["item.ingotcyanite"] * 9
- value["tile.brmetal.3"] = value["item.ingotblutonium"] * 9
- value["item.enderpearl"] = value["item.eyeofender"] / 2
- value["item.blazepowder"] = value["item.eyeofender"] / 2
- value["item.blazerod"] = value["item.eyeofender"] * 2
- local turbines = 18
- -- PERIPHERALS --
- do
- peripherals_find = function()
- log_add("Finding Peripherals Direct")
- peripheral_list = {[1] = term}
- local num = 2
- for k,v in ipairs(sides) do
- p_type = peripheral.getType(v) or nil
- if p_type ~= nil then peripheral_list[num] = v num = num + 1 log_add("Found Peripheral: "..v.." "..p_type) end
- end
- log_add("Find Peripherals Direct Complete") log_add("Checking for Remote")
- local remote = nil
- for k,v in ipairs(peripheral_list) do
- if peripheral.getType(tostring(v)) == "modem" then
- if not peripheral.call(v, "isWireless") then remote = peripheral.wrap(v) log_add("Remote found: "..tostring(v)) end
- end
- end
- if remote ~= nil then
- log_add("Finding Peripherals Remote")
- peripheral_list = {}
- peripheral_list = remote.getNamesRemote()
- peripheral_list[(table.maxn(peripheral_list) + 1)] = peripheral_list[1]
- peripheral_list[1] = term
- local num = (table.maxn(peripheral_list) + 1)
- for k,v in ipairs(sides) do
- p_type = peripheral.getType(v) or nil
- if p_type ~= nil then peripheral_list[num] = v num = num + 1 end
- end
- else
- log_add("Remote not found", true)
- end
- end
- end
- -- PERIPHERAL SORTER --
- function decimal(number)
- log_add("Converting #: "..tostring(number))
- if type(number) == "number" then
- local text, num = ".", number
- if num >= 1000 then text = "K" end
- if num >= 1000000 then text = "M" end
- if num >= 1000000000 then text = "B" end
- if num >= 1000000000000 then text = "T" end
- while num >= 1000 do
- num = num / 1000
- end
- if text ~= "." then
- text = tostring(math.floor(num)..text) or 0
- else
- text = tostring(math.floor(num)) or 0
- end
- log_add("# Conversion complete: "..text)
- return text
- else
- return number
- end
- end
- do
- peripherals_echest_sort = function(...)
- local params = {...}
- log_add("Sorting Ender Chests")
- local answer, num, itemlist = {}, 1, nil
- for a,b in pairs(echest) do
- log_add("Sorting Ender Chest: "..b)
- peripheral.call(b, "condenseItems")
- itemlist = peripheral.call(b, "getAllStacks")
- for c,d in pairs(itemlist) do
- log_add("Running through Inv: ".."c: "..itemlist[c]["rawName"]..": "..itemlist[c]["name"])
- if itemlist[c]["rawName"] == "item.paper" then
- local side = b
- echest[a] = {["side"] = b, ["name"] = itemlist[c]["name"]}
- log_add("Paper Found: "..tostring(echest[a]["name"])..": "..tostring(echest[a]["side"]))
- end
- end
- end
- for a,b in pairs(echest) do
- local matched = false
- for c,d in pairs(stats) do
- if echest[a]["name"] == stats[c]["name"] then
- stats[a]["name"] = echest[a]["name"]
- stats[a]["side"] = echest[a]["side"]
- log_add("Matched Ender Chest User: "..echest[a]["name"])
- matched = true
- end
- end
- if not matched then
- local num = table.maxn(stats) + 1
- stats[num] = {}
- stats[num]["name"] = echest[a]["name"]
- stats[num]["side"] = echest[a]["side"]
- stats[num]["time"] = 0
- stats[num]["on"] = true
- log_add("Adding Ender Chest User: "..echest[a]["name"])
- end
- end
- log_add("Ender Chest Sort End.")
- end
- peripherals_capacitor = function(...)
- local params = {...}
- log_add("Getting Capacitor details: "..tostring(params[1]))
- local answer = {[1] = false}
- local command = peripheral.wrap(params[1])
- local p_methods = peripheral.getMethods(tostring(params[1]))
- for k,v in ipairs(p_methods) do
- if v == "getMaxEnergyStored" then answer[1] = true end
- end
- if answer[1] then
- log_add("Method <getMaxEnergyStored> applicable: "..tostring(params[1]))
- answer["capacity"] = command.getMaxEnergyStored("north") or 0
- answer["stored"] = command.getEnergyStored("north") or 0
- answer["percentage"] = math.floor((answer["stored"] / answer["capacity"])).."%" or "0%"
- log_add(tostring(params[1]).." Details: "..answer["capacity"].." "..answer["stored"].." "..answer["percentage"])
- else
- log_add("Method <getMaxEnergyStored> not applicable: "..tostring(params[1]), true)
- end
- return answer
- end
- peripherals_compile = function()
- local answer = {[1] = 0, [2] = 0, [3] = 0}
- local details = {}
- log_add("Compiling Capacitors data")
- for k,v in ipairs(capacitors) do
- details = peripherals_capacitor(v)
- answer[2] = answer[2] + details["capacity"] or 0
- answer[1] = answer[1] + details["stored"] or 0
- end
- answer[3] = tostring(math.floor((answer[1] / answer[2]) * 100)) .. "%"
- log_add("Compile Results: "..answer[2].." "..answer[1].." "..answer[3])
- return answer
- end
- peripherals_applied_energ = function(command)
- local params = {[1] = command or nil}
- log_add("Getting AE details: "..tostring(params[1]))
- local answer, applicable = {}, false
- if tostring(params[1]) == "nil" then params[1] = appl_energ[1] end
- if tostring(params[1]) ~= "nil" then
- local p_methods = peripheral.getMethods(params[1])
- for k,v in pairs(p_methods) do
- if v == "getTotalBytes" then applicable = true end
- end
- if applicable then
- log_add("Method <getTotalBytes> applicable: "..tostring(params[1]))
- answer[2] = peripheral.call(params[1], "getTotalBytes") or 0
- answer[1] = (answer[2] - peripheral.call(params[1], "getFreeBytes")) or 0
- answer[3] = tostring(math.floor((answer[1] / answer[2]) * 100)) .. "%"
- answer[5] = peripheral.call(params[1], "getTotalItemTypes") or 0
- answer[4] = (answer[5] - peripheral.call(params[1], "getRemainingItemTypes")) or 0
- answer[6] = tostring(math.floor((answer[4] / answer[5]) * 100)) .. "%"
- log_add(tostring(params[1]).." Details: "..answer[1].." "..answer[2].." "..answer[3])
- log_add(tostring(params[1]).." Details: "..answer[4].." "..answer[5].." "..answer[6])
- else
- log_add("Method <getTotalBytes> not applicable: "..tostring(params[1]), true)
- end
- end
- return answer
- end
- peripherals_sort = function()
- log_add("Sorting peripherals")
- local mon, cap, ae, ec, react, turb = 2, 1, 1, 1, 1, 1
- screens, capacitors, appl_energ, echest, reactor, turbine = {[1] = term}, {}, {}, {}, {}, {}
- for num=2,table.maxn(peripheral_list) do
- log_add("Sorting Peripheral: "..tostring(peripheral_list[num]))
- local test1, test2 = {}, {}
- test1 = peripherals_capacitor(peripheral_list[num])
- test2 = peripherals_applied_energ(peripheral_list[num])
- if peripheral.getType(peripheral_list[num]) == "monitor" then
- screens[mon] = peripheral_list[num] log_add("Adding Monitor: "..tostring(peripheral_list[num])) mon = mon + 1
- elseif test1["capacity"] ~= nil then
- capacitors[cap] = peripheral_list[num] log_add("Adding Capacitor: "..tostring(peripheral_list[num])) cap = cap + 1
- elseif test2[2] ~= nil then
- appl_energ[ae] = peripheral_list[num] log_add("Adding AE: "..tostring(peripheral_list[num])) ae = ae + 1
- elseif peripheral.getType(peripheral_list[num]) == "modem" then
- if peripheral.call(peripheral_list[num], "isWireless") then
- wireless = peripheral_list[num] log_add("Found Wireless Modem: "..tostring(peripheral_list[num]))
- end
- elseif peripheral.getType(peripheral_list[num]) == "ender_chest" then
- echest[ec] = peripheral_list[num] log_add("Adding Ender Chest: "..tostring(peripheral_list[num])) ec = ec + 1
- elseif peripheral.getType(peripheral_list[num]) == "BigReactors-Reactor" then
- reactor[react] = peripheral_list[num] log_add("Adding Reactor: "..tostring(peripheral_list[num])) react = react + 1
- elseif peripheral.getType(peripheral_list[num]) == "BigReactors-Turbine" then
- turbine[turb] = peripheral_list[num] log_add("Adding Turbine: "..tostring(peripheral_list[num])) turb = turb + 1
- end
- end
- if wireless ~= nil then
- rednet.open(wireless) log_add("Wireless added")
- else
- log_add("Failure to add Wireless Modem: Program Terminated", true) print("Failure to find Wireless Modem: Program Terminated") shell.exit()
- end
- end
- end
- -- SCREENS --
- do
- screen_change_colors = function(...)
- local params = {...}
- local color1, color2 = params[2] or colors.white, params[3] or colors.black
- params[1].setTextColor(color1)
- params[1].setBackgroundColor(color2)
- log_add("Changing colors to: "..color1.." "..color2)
- end
- screen_text = function(...)
- local params = {...}
- params[1].setCursorPos(params[3], params[4])
- screen_change_colors(params[1], (params[5] or nil), (params[6] or nil))
- log_add("Writting on: "..tostring(params[1]).." "..tostring(params[2]).." "..tostring(params[3]).." "..tostring(params[4]))
- params[1].write(params[2]:upper())
- screen_change_colors(params[1])
- end
- screen_box = function(...)
- local params = {...}
- term.redirect(params[1])
- paintutils.drawLine(params[5], params[4], params[3], params[4], params[2])
- paintutils.drawLine(params[3], params[4], params[3], params[6], params[2])
- paintutils.drawLine(params[5], params[6], params[3], params[6], params[2])
- paintutils.drawLine(params[5], params[4], params[5], params[6], params[2])
- term.restore()
- end
- time_calc = function(number)
- log_add("Converting #: "..tostring(number))
- if type(number) == "number" then
- local text, num = ".", number
- if num >= 20 then num = num / 20 text = "secs" end
- if num >= 60 and text == "secs" then num = num / 60 text = "mins" end
- if num >= 60 and text == "mins" then num = num / 60 text = "hrs" end
- if num >= 24 and text == "hrs" then num = num / 24 text = "days" end
- if text ~= "." then
- text = tostring(math.floor(num)..text) or 0
- else
- text = tostring(math.floor(num)) or 0
- end
- log_add("# Conversion complete: "..text)
- return text
- else
- return number
- end
- end
- screen_drawall = function(...)
- local params = {...}
- mon_button = {[1] = {}}
- term_button = {[1] = {}}
- if current_screen == nil then current_screen = "main" end
- num = 2
- log_add("Draw All: Drawing Screen: "..tostring(screens[num]))
- if screens[num] == term then mon = screens[num] else mon = peripheral.wrap(screens[num]) end
- mon.clear()
- if num == 1 then
- term_x, term_y = mon.getSize()
- term_x, term_y = term_x - 2, term_y - 4
- term_x1, term_y1, term_x2, term_y2 = 2, 4, term_x + 1, term_y + 2
- if capacitors[1] ~= nil or appl_energ[1] ~= nil then display_energy = true term_x, term_x1 = term_x - 9, term_x1 + 9 end
- term_rows, term_cols = math.floor(term_y / 2), math.floor(term_x / button_length())
- term_total = term_rows * term_cols
- log_add("Term Details log: "..term_x.." "..term_y) log_add("Term Details log: "..term_x1.." "..term_y1.." "..term_x2.." "..term_y2) log_add("Term Details log: "..term_rows.." "..term_cols.." "..term_total)
- elseif num == 2 then
- mon.setTextScale(tonumber(CONFIG.TEXT_SCALE))
- mon_x, mon_y = mon.getSize()
- mon_x, mon_y = mon_x - 2, mon_y - 4
- mon_x1, mon_y1, mon_x2, mon_y2 = 2, 4, mon_x + 1, mon_y + 2
- if capacitors[1] ~= nil or appl_energ[1] ~= nil then display_energy = true mon_x, mon_x1 = mon_x - 9, mon_x1 + 9 end
- -- mon_rows, mon_cols = math.floor(mon_y / 2), math.floor(mon_x / button_length())
- -- mon_total = mon_rows * mon_cols
- -- log_add("Mon Details log: "..mon_x.." "..mon_y) log_add("Mon Details log: "..mon_x1.." "..mon_y1.." "..mon_x2.." "..mon_y2) ---log_add("Mon Details log: "..mon_rows.." "..mon_cols.." "..mon_total)
- end
- if peripheral.getType(tostring(screens[num])) == "monitor" then mon.setTextScale(tonumber(CONFIG.TEXT_SCALE)) end
- local x, y, x1, y1, x2, y2 = 2, 2, 1, 1, 1, 1
- if tostring(CONFIG.REACTOR_ON) == "true" then color1 = colors.green else color1 = colors.red end
- screen_text(mon, tostring("reactor on: "..tostring(CONFIG.REACTOR_ON)), x, y, color1)
- x, y = mon.getCursorPos() x = x + 1
- screen_text(mon, (" "..string.gsub(tostring(CONFIG.HEADING), "_", " ").." "), x, y, colors.white, colors.blue)
- x, y = 2, 4
- local temp1, temp2, details = peripheral.wrap(tostring(reactor[1])), peripheral.wrap(tostring(turbine[1])), {}
- if tostring(temp1.getActive()) == "true" then
- details = {[1] = "CR: + - "..tostring(temp1.getControlRodLevel(1)).."%",
- [2] = "Steam: "..tostring(decimal(temp1.getEnergyProducedLastTick())).."b/t",
- [3] = "Fuel: "..tostring(decimal(temp1.getFuelAmount())).."/"..tostring(decimal(temp1.getFuelAmountMax())).." mb",
- [4] = "Usage: "..tostring(math.floor(temp1.getFuelConsumedLastTick() * 1000) / 1000).." mb/t",
- [5] = "Speed: "..tostring(math.floor(temp2.getRotorSpeed())).."rpm",
- [6] = "Power: "..tostring(decimal(tonumber(temp2.getEnergyProducedLastTick() * turbines))).."rf/t",
- [7] = "rf-ingot = "..tostring(decimal(((1000 / temp1.getFuelConsumedLastTick()) * temp2.getEnergyProducedLastTick() * turbines))).." rf",
- [8] = "t-ingot = "..tostring(math.floor(1000 / tonumber(temp1.getFuelConsumedLastTick()))) }
- else
- details = {[1] = "CR: + - "..tostring(CONFIG.CONTROL_RODS).."%",
- [2] = "Steam: NIL b/t",
- [3] = "Fuel: NIL mb",
- [4] = "Usage: NIL mb/t",
- [5] = "Speed: NIL rpm",
- [6] = "Power: NIL rf/t",
- [7] = "rf-ingot = NIL rf",
- [8] = "t-ingot = NIL" }
- end
- for k,v in pairs(details) do
- screen_text(mon, tostring(v), x, y, colors.yellow)
- x2, y2 = mon.getCursorPos()
- if x2 > x1 then x1 = x2 end
- y = y + 2
- end
- x, y = x1 + 2, 4
- for k,v in pairs(stats) do
- if stats[k]["time"] ~= 0 and stats[k]["on"] then color1 = colors.green else color1 = colors.red end
- screen_text(mon, tostring(stats[k]["name"]..": "..tostring(time_calc(tonumber(stats[k]["time"])))), x, y, color1)
- y = y + 1
- end
- log_add("Draw All: Drawing Screen: "..tostring(screens[num])..": Complete")
- end
- -- PROGRAM --
- program_check_ec = function(...)
- local answer, temp = {}, temp
- local list, ticks = {}, nil
- for k,v in pairs(stats) do
- temp = peripheral.wrap(tostring(stats[k]["side"]))
- list = {}
- list = temp.getAllStacks()
- stats[k]["on"] = true
- for c,d in pairs(list) do
- if tostring(value[list[c]["rawName"]]) ~= "nil" then
- if tostring(peripheral.call(tostring(reactor[1]), "getActive")) == "true" then
- ticks = peripheral.call(tostring(reactor[1]), "getFuelConsumedLastTick")
- else
- ticks = 0.06
- end
- stats[k]["time"] = stats[k]["time"] + (math.floor(tonumber(1000 / ticks) * tonumber(list[c]["qty"]) * tonumber(value[list[c]["rawName"]])))
- temp.pushItem(tostring(CONFIG.HOPPER_DIRECTION), tonumber(c), tonumber(list[c]["qty"]))
- elseif list[c]["rawName"] == "item.stick" then
- stats[k]["on"] = false
- elseif list[c]["rawName"] ~= "tile.stone" and list[c]["rawName"] ~= "item.paper" then
- temp.pushItem(tostring(CONFIG.HOPPER_DIRECTION), tonumber(c), tonumber(list[c]["qty"]))
- end
- end
- end
- end
- program_reducetime = function(...)
- for k,v in pairs(stats) do
- if stats[k]["on"] then
- stats[k]["time"] = stats[k]["time"] - (tonumber(CONFIG.SCREEN_REFRESH_RATE) * 20)
- if stats[k]["time"] <= 0 then stats[k]["time"] = 0 end
- end
- end
- end
- program_checktimes = function(...)
- local params, list, temp = {...}, {}, nil
- for a,b in pairs(stats) do
- list = {}
- if stats[a]["time"] >= 1 and stats[a]["on"] then
- list = peripheral.call(tostring(stats[a]["side"]), "getAllStacks")
- for c,d in pairs(list) do
- if list[c]["rawName"] == "tile.stone" then
- temp = peripheral.wrap(tostring(stats[a]["side"]))
- temp.pushItem(tostring(CONFIG.CHEST_DIRECTION), tonumber(c), tonumber(list[c]["qty"]), 1)
- end
- end
- else
- temp = peripheral.wrap(tostring(stats[a]["side"]))
- temp.pullItem(tostring(CONFIG.CHEST_DIRECTION), 1)
- end
- end
- end
- program_adjustreactor = function(...)
- local answer, temp = {}, nil
- local temp = peripheral.wrap(tostring(reactor[1]))
- temp.setAllControlRodLevels(control_rod)
- while tonumber(peripheral.call(tostring(turbine[1]), "getFluidFlowRate") * turbines) <= tonumber(peripheral.call(tostring(reactor[1]), "getEnergyProducedLastTick")) and control_rod ~= 1 do
- control_rod = tonumber(temp.getControlRodLevel(1)) - 1
- if control_rod <= 1 then control_rod = 1 end
- temp.setAllControlRodLevels(control_rod)
- sleep(20)
- end
- end
- program_adjustreactor2 = function(...)
- local answer, temp = {}, nil
- local temp = peripheral.wrap(tostring(reactor[1]))
- temp.setAllControlRodLevels(control_rod)
- if tonumber(peripheral.call(tostring(turbine[1]), "getFluidFlowRate") * turbines) <= tonumber(peripheral.call(tostring(reactor[1]), "getEnergyProducedLastTick")) and control_rod ~= 1 then
- control_rod = tonumber(temp.getControlRodLevel(1)) - 1
- if control_rod <= 1 then control_rod = 1 end
- temp.setAllControlRodLevels(control_rod)
- end
- end
- end
- peripherals_find()
- peripherals_sort()
- peripherals_echest_sort()
- --if tostring(peripheral.call(tostring(reactor[1]), "getActive")) == "true" then
- -- local temp = peripheral.wrap(tostring(reactor[1]))
- -- if tonumber(temp.getControlRodLevel(1)) == 1 then control_rod = 90 else control_rod = tonumber(temp.getControlRodLevel(1)) end
- -- program_adjustreactor()
- --end
- temp = peripheral.wrap(tostring(reactor[1]))
- temp.setAllControlRodLevels(tonumber(CONFIG.CONTROL_ROD))
- os.startTimer(tonumber(CONFIG.SCREEN_REFRESH_RATE))
- RO = tostring(CONFIG.REACTOR_ON)
- while true do
- if event == "timer" then
- program_reducetime()
- os.startTimer(tonumber(CONFIG.SCREEN_REFRESH_RATE))
- end
- if event == "monitor_touch" then
- temp = peripheral.wrap(tostring(reactor[1]))
- RO = tostring(CONFIG.REACTOR_ON)
- if x >= 2 and x <= 18 and y == 2 then
- if RO == "true" then
- RO = "false"
- else
- RO = "true"
- end
- end
- save_settings()
- load_settings()
- end
- if event == "monitor_touch" and tostring(CONFIG.REACTOR_ON) == "true" then
- temp = peripheral.wrap(tostring(reactor[1]))
- CR = tonumber(temp.getControlRodLevel(1))
- if x == 6 and y == 4 then
- CR = tonumber(CR) + 1
- elseif x == 8 and y == 4 then
- CR = tonumber(CR) - 1
- end
- save_settings()
- load_settings()
- temp.setAllControlRodLevels(tonumber(CR))
- end
- if RO == "true" then
- temp.setActive(true)
- elseif RO == "false" then
- temp.setActive(false)
- end
- program_check_ec()
- program_checktimes()
- screen_drawall()
- -- program_adjustreactor2()
- save_one("saves/stats", stats)
- event, id, x, y = os.pullEvent()
- end
Advertisement
Add Comment
Please, Sign In to add comment