Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --startup actions and declorations
- monitor = peripheral.wrap("right")
- serverMon = peripheral.wrap("monitor_0")
- rednet.open("top")
- -- create functions
- function setAllGood()
- monitor.clear()
- monitor.setCursorPos(1,1)
- monitor.setTextColor(colors.white)
- monitor.write("Buildings on Network - CFW")
- monitor.setCursorPos(1,3)
- monitor.write("Bldg Ab: ")
- monitor.setTextColor(colors.green)
- monitor.setCursorPos(10,3)
- monitor.write("Good")
- monitor.setTextColor(colors.white)
- monitor.setCursorPos(15,3)
- monitor.write(" - ")
- monitor.setTextColor(colors.green)
- monitor.setCursorPos(19,3)
- monitor.write("Locked")
- end
- function setOneOrMoreError(b1, b1Why)
- if (b1) then
- if (b1Why == "No Response") then
- monitor.setCursorPos(1,3)
- monitor.clearLine()
- monitor.setTextColor(colors.white)
- monitor.write("Bldg Ab: ")
- monitor.setTextColor(colors.red)
- monitor.setCursorPos(10,3)
- monitor.write("ERROR - No Response")
- end
- if (b1Why == "Wrong CPID") then
- monitor.setCursorPos(1,3)
- monitor.clearLine()
- monitor.setTextColor(colors.white)
- monitor.write("Bldg Ab: ")
- monitor.setTextColor(colors.red)
- monitor.setCursorPos(10,3)
- monitor.write("ERROR - Wrong CP-ID")
- end
- if (b1Why == "Wrong Code") then
- monitor.setCursorPos(1,3)
- monitor.clearLine()
- monitor.setTextColor(colors.white)
- monitor.write("Bldg Ab: ")
- monitor.setTextColor(colors.red)
- monitor.setCursorPos(10,3)
- monitor.write("ERROR - Wrong Code")
- end
- end
- end
- function setOneOrMoreOnRequest(b1)
- if (b1) then
- monitor.setCursorPos(1,3)
- monitor.clearLine()
- monitor.setTextColor(colors.white)
- monitor.write("Bldg Ab: ")
- monitor.setTextColor(colors.green)
- monitor.setCursorPos(10,3)
- monitor.write("Good")
- monitor.setTextColor(colors.white)
- monitor.setCursorPos(15,3)
- monitor.write(" - ")
- monitor.setCursorPos(19,3)
- monitor.setTextColor(colors.yellow)
- monitor.write("Request")
- end
- end
- local function testBuildings()
- isBad = false
- message = nil
- rednet.send(73, "C^Y|cE5krz")
- sender, message, disT = rednet.receive(5)
- if not (sender == 73) then
- term.setCursorPos(1,3)
- term.write(sender or "No Sender")
- setOneOrMoreError(true, "Wrong CPID")
- isBad = true
- elseif not (message == "Vy;vR;F6jrC,k!n") then
- setOneOrMoreError(true, "Wrong Code")
- isBad = true
- elseif (message == nil) then
- setOneOrMoreError(true, "No Response")
- isBad = true
- end
- if (isBad) then
- return false
- else
- return true
- end
- end
- local function timerEnd()
- event, timerID = os.pullEvent("timer")
- end
- local function readPassword()
- password = read("*")
- end
- --Main Code
- term.clear()
- term.setCursorPos(1,1)
- print("Version 1.0")
- print("Running...")
- setAllGood()
- if not (testBuildings()) then
- --term.clear()
- term.setCursorPos(1,10)
- print("Error! to reset hit any key")
- os.pullEvent("key")
- os.reboot()
- end
- print("")
- print("Enter Password to set a building to 'request'")
- while (true) do
- timer = os.startTimer(300)
- parallel.waitForAny(readPassword, os.pullEvent("timer"))
- if (password == "BeastmdoeJD24") then
- term.clear()
- term.setCursorPos(1,1)
- print("what of the following buildings would you like to set to request?")
- bldg = read()
- if (bldg == "Ab") then
- setOneOrMoreOnRequest(true)
- sender, message, disT = rednet.receive(180)
- if (sender == 73 and message == "vLctbt8LLG7shFoNDKw7") then
- rednet.send(73, "3Zu1eCzbkQsvCmCoRw9R")
- else
- os.reboot()
- end
- else
- print("That is not a vaild building")
- sleep(3)
- os.reboot()
- end
- else
- term.clear()
- term.setCursorPos(1,1)
- print("Invaild Password")
- sleep(3)
- os.reboot()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment