Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Script by Savage_Me55iah of CraftAu.com.au--
- --Version 1.4--
- --Needs corresponding "Savage Monitor v1.4" 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
- }
- 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}
- 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
- peripheral_side = sides[num]
- peripheral_found = true
- end
- elseif e == "remote" then
- if not peripheral.call(sides[num], "isWireless") then
- peripheral_side = sides[num]
- peripheral_found = true
- end
- elseif e == nil then
- peripheral_side = sides[num]
- peripheral_found = true
- 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: ")
- label = read()
- label = tostring(label)
- os.setComputerLabel(label)
- end
- find_peripheral("modem", "wireless")
- rednet.open(peripheral_side)
- function load()
- print("loading")
- fileHandle = fs.open (variables["save"], 'r')
- variables = textutils.unserialize (fileHandle.readAll())
- fileHandle.close()
- print("loaded")
- end
- function save()
- print("saving")
- fileHandle = fs.open (variables["save"], 'w')
- fileHandle.write (textutils.serialize (variables))
- fileHandle.close()
- print("saved")
- end
- function switch()
- if variables["status"] 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
- if adjust ~= false or not fs.exists(variables["save"]) then
- print("SETTINGS: ")
- repeat
- print("Output Side?: front/back/left/right/top/bottom")
- text = read()
- text = tostring(text)
- text = text:lower()
- until sides2[text]
- variables["side"] = text
- repeat
- print("Rednet/Bundled cables?: true/false: ")
- text = read()
- text2 = tostring(text)
- 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 = read()
- text = tostring(text)
- 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: ")
- text = read()
- text2 = tostring(text)
- until text2 == "true" or text2 == "false"
- if text2 == "true" then
- variables["reversal"] = true
- else
- variables["reversal"] = false
- end
- save()
- else
- load()
- end
- switch()
- while true do
- print(label .. ":" .. id2)
- event, id, text = os.pullEvent()
- 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
- end
- print(variables["status"])
- save()
- switch()
- end
Advertisement
Add Comment
Please, Sign In to add comment