Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Script by Savage_Me55iah of CraftAu.com.au--
- --Version 1.7--
- --Needs corresponding "Savage Monitor v1.7" script--
- tArgs = { ... }
- adjust = tArgs[1] or false
- local variables = {
- ["status"] = true,
- ["timer"] = 2,
- ["save"] = "variables",
- ["side"] = "left",
- ["rednet"] = true,
- ["rednet_color"] = colors.white,
- ["reversal"] = false,
- ["nuke"] = false,
- ["time_on"] = 80,
- ["time_off"] = 110
- }
- local sides2 = {["front"] = true, ["back"] = true, ["left"] = true, ["right"] = true, ["top"] = true, ["bottom"] = true}
- local colors2 = {["white"] = colors.white, ["orange"] = colors.orange, ["magenta"] = colors.magenta, ["lightblue"] = colors.lightBlue, ["yellow"] = colors.yellow, ["lime"] = colors.lime, ["pink"] = colors.pink, ["gray"] = colors.gray, ["lightgray"] = colors.lightGray, ["cyan"] = colors.cyan, ["purple"] = colors.purple, ["blue"] = colors.blue, ["brown"] = colors.brown, ["green"] = colors.green, ["red"] = colors.red, ["black"] = colors.black}
- color_from_decimal = {[1] = "white", [2] = "orange", [4] = "magenta", [8] = "lightBlue", [16] = "yellow", [32] = "lime", [64] = "pink", [128] = "gray", [256] = "lightGray", [512] = "cyan", [1024] = "purple",[2048] = "blue", [4096] = "brown", [8192] = "green", [16384] = "red", [32768] = "black"}
- function find_peripheral(t, e)
- e = e or nil
- sides = {[1] = "front", [2] = "back", [3] = "left", [4] = "right", [5] = "top", [6] = "bottom"}
- peripheral_found = false
- for num=1, 6 do
- type = peripheral.getType(sides[num])
- if type == t then
- if e == "wireless" then
- if peripheral.call(sides[num], "isWireless") then
- return sides[num]
- end
- elseif e == "remote" then
- if not peripheral.call(sides[num], "isWireless") then return sides[num] end
- elseif e == nil then
- return sides[num]
- end
- end
- end
- if peripheral_found ~= true then
- error("No " .. t .. " attached to the computer", 0)
- end
- end
- id2 = os.getComputerID()
- label = os.getComputerLabel() or false
- if label == false then
- print("Please Type label here: ")
- os.setComputerLabel(tostring(read()))
- end
- rednet.open(find_peripheral("modem", "wireless"))
- function load()
- fileHandle = fs.open (variables["save"], 'r')
- variables = textutils.unserialize (fileHandle.readAll())
- fileHandle.close()
- end
- function save()
- fileHandle = fs.open (variables["save"], 'w')
- fileHandle.write (textutils.serialize (variables))
- fileHandle.close()
- end
- function switch(command)
- if command then
- if variables["rednet"] then
- rs.setBundledOutput(variables["side"], variables["rednet_color"])
- else
- redstone.setOutput(variables["side"], true)
- end
- else
- if variables["rednet"] then
- rs.setBundledOutput(variables["side"], 0)
- else
- redstone.setOutput(variables["side"], false)
- end
- end
- end
- function nuke(command, command2)
- if command or not command2 then
- switch(false)
- term_draw(false)
- os.startTimer(tonumber(variables["time_off"]))
- on = false
- elseif not command and command2 then
- switch(true)
- os.startTimer(tonumber(variables["time_on"]))
- term_draw(true)
- on = true
- end
- end
- if adjust ~= false or not fs.exists(variables["save"]) then
- print("SETTINGS: ")
- repeat
- print("Output Side?: front/back/left/right/top/bottom")
- text = tostring(read())
- text = text:lower()
- until sides2[text]
- variables["side"] = text
- repeat
- print("Rednet/Bundled cables?: true/false: ")
- text2 = tostring(read())
- text2 = text2:lower()
- until text2 == "true" or text2 == "false"
- if text2 == "true" then
- variables["rednet"] = true else
- variables["rednet"] = false
- end
- if variables["rednet"] then
- repeat
- print("Rednet Color?: ")
- text = tostring(read())
- text = text:lower()
- until colors2[text] ~= nil
- variables["rednet_color"] = colors2[text]
- end
- repeat
- print("Reversal (for machines that turn off with redstone signal): true/false: ")
- text2 = tostring(read())
- text2 = text2:lower()
- until text2 == "true" or text2 == "false"
- if text2 == "true" then
- variables["reversal"] = true else
- variables["reversal"] = false end
- repeat
- print("Alternating redstone signal for IC2 reactors?: true/false: ")
- text2 = tostring(read())
- text2 = text2:lower()
- until text2 == "true" or text2 == "false"
- if text2 == "true" then
- variables["nuke"] = true
- -- repeat
- print("How long turned on?: seconds: ")
- time = tonumber(read())
- -- until type(time) == "number"
- variables["time_on"] = time
- -- repeat
- print("How long turned off? (cooldown): seconds: ")
- time = tonumber(read())
- -- until type(time) == "number"
- variables["time_off"] = time
- else
- variables["nuke"] = false
- end
- save()
- else
- load()
- end
- function change_colors(command, color_1, color_2)
- command.setTextColor(color_1 or colors.white)
- command.setBackgroundColor(color_2 or colors.black)
- end
- function term_write(text, command, xpos, ypos)
- term.setCursorPos(xpos, ypos)
- if term.isColor() then
- if command then change_colors(term, colors.black, colors.green) else change_colors(term, colors.black, colors.red) end
- else
- if command then change_colors(term, colors.black, colors.white) else change_colors(term) end
- end
- term.write(text)
- change_colors(term)
- end
- function term_draw(command)
- term.clear()
- term_write(" " .. label .. ":" .. id2 .. " ", true, 2, 2)
- term_write(" Status ", variables["status"], 2, 4)
- term_write(" Nuclear Reactor ", variables["nuke"], 2, 6)
- if not variables["nuke"] then
- term_write(" Cooldown ", false, 2, 8)
- term_write(" Reactor Active ", false, 2, 10)
- else
- if command then
- term_write(" Cooldown: " .. variables["time_off"] .. " ", false, 2, 8)
- term_write(" Reactor Active: " .. variables["time_on"] .. " ", true, 2, 10)
- else
- term_write(" Cooldown: " .. variables["time_off"] .. " ", true, 2, 8)
- term_write(" Reactor Active: " .. variables["time_on"] .. " ", false, 2, 10)
- end
- end
- term_write(" Rednet ", variables["rednet"], 2, 12)
- term_write(" Reverse ", variables["reversal"], 2, 14)
- term.setCursorPos(1, 16)
- end
- os.startTimer(0.1)
- term_draw(false)
- on = true
- while true do
- while event == "redstone" or event == nil do event, id, text = os.pullEvent() end
- if event == "rednet_message" then
- if variables["reversal"] then
- if text == "activate" then
- variables["status"] = false
- else
- variables["status"] = true
- end
- else
- if text == "activate" then
- variables["status"] = true
- else
- variables["status"] = false
- end
- end
- if variables["nuke"] and variables["status"] then os.startTimer(variables["time_off"]) end
- end
- if not variables["nuke"] then
- switch(variables["status"])
- term_draw()
- else
- if event == "timer" then
- nuke(on, variables["status"])
- term_draw(on)
- end
- end
- save()
- event = nil
- end
Advertisement
Add Comment
Please, Sign In to add comment