Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Savage_Me55iah--
- --http://pastebin.com/ZVduDAB1--
- tArgs = { ... }
- first_run = tArgs[1] or false
- local variables = {
- ["status"] = true,
- ["timer"] = 2,
- ["save"] = "variables",
- ["side"] = "left",
- ["rednet"] = "y",
- ["rednet_color"] = colors.white,
- ["wireless"] = "right",
- ["reversal"] = "N"
- }
- id2 = os.getComputerID()
- label = os.getComputerLabel()
- rednet.open(variables["wireless"])
- 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"] == "y" then
- -- c = colors.combine(c, variables["rednet_color"])
- rs.setBundledOutput(variables["side"], variables["rednet_color"])
- else
- redstone.setOutput(variables["side"], true)
- end
- else
- if variables["rednet"] == "y" then
- -- c = colors.subtract(c, variables["rednet_color"])
- rs.setBundledOutput(variables["side"], 0)
- else
- redstone.setOutput(variables["side"], false)
- end
- end
- end
- if first_run == false then
- load()
- else
- save()
- end
- switch()
- while true do
- print(label .. " " .. id2)
- event, id, text = os.pullEvent()
- if event == "rednet_message" then
- if variables["reversal"] == "N" then
- if text == "activate" then
- variables["status"] = true
- else
- variables["status"] = false
- end
- else
- if text == "activate" then
- variables["status"] = false
- else
- variables["status"] = true
- end
- end
- end
- print(variables["status"])
- save()
- switch()
- event = "turd"
- end
Advertisement
Add Comment
Please, Sign In to add comment