Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Times = {6.00,21.00}
- local Open = false
- local Lockdown = false
- local Power = false
- local Transaction = false
- local Gate = 0
- local Security = 0
- local Atmo = 0
- local Pwr = nil
- local Announcements = {}
- local Facilities = {}
- peripheral.find("modem",rednet.open)
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- function PlayAnnouncement(I)
- Announcements[I][1] = true
- shell.run("Transmitter",Announcements[I][3])
- end
- function CheckSchedule()
- while true do
- if Transaction = true and Open = false and os.time() > Times[1] and os.time() < Times[2] then Open = true Transaction = false else Open = false Transaction = false end
- if Open == true then
- if os.time() > 17.00 then Atmo("Da",false) Atmo("Ni",true") end
- for i =1, #Announcements do
- if Announcements[i][1] == false and os.time() > Announcements[i][2] then PlayAnnouncement(i) end
- end
- end
- if Transaction == false then
- if Open == true then
- rednet.send(Gate,"Open")
- rednet.send(Security,"Open")
- Atmo("Da",true)
- elseif Open == false then
- rednet.send(Gate,"Close")
- rednet.send(Security,"Close")
- Atmo("Ni",false)
- end
- Transaction = true
- end
- if os.time() > 23.00 and os.time() < 23.10 then break end
- end
- end
- function Atmo(t,R)
- local Da
- if t == "Em" then
- Da = {"E_Lights",R}
- rednet.send(Atmo,Da,Protocol)
- elseif t == "No" then
- Da = {"M_Lights",R}
- rednet.send(Atmo,Da,Protocol)
- elseif t == "Ni" then
- Da = {"N_Effects",R}
- rednet.send(Atmo,Da,Protocol)
- elseif t == "Da" then
- Da = {"D_Effects",R}
- rednet.send(Atmo,Da,Protocol)
- end
- end
- function Int()
- local Menu = "Base"
- term.setBackgroundColor(colors.lightBlue)
- Clear()
- while true do
- local options
- Clear()
- print("Park Control Terminal")
- if Menu == "Base" then
- options = {"lockdown","schedule","facilities"}
- elseif Menu == "Schedule" then
- options = {"return"}
- print(textutils.serialize(Times))
- print(textutils.serialize(Announcements))
- elseif Menu == "Facilities" then
- options = {"return"}
- print(textutils.serialize(Facilities))
- end
- local n = CUI(options)
- if options[n] == "lockdown" then Open = false end
- if options[n] == "return" then Menu = "Base" end
- if options[n] == "schedule" then Menu = "Schedule" end
- if options[n] == "facilities" then Menu = "Facilities" end
- end
- end
- function PoCheck()
- while true do
- local id, message = rednet.receive()
- if id == Pwr and message == false then Power = false break end
- end
- if Power == false then
- rednet.send(Gate,"Close")
- rednet.send(Security,"Off")
- Atmo("Ni",false)
- Atmo("Da",false)
- Atmo("No",false)
- Atmo("Em",true)
- end
- end
- function GetFiles()
- local Content
- local F1 = fs.open("Times.txt","r")
- Content = F1.readAll()
- Times = textutils.unserialize(Content)
- F1.close()
- local F2 = fs.open("Announcements.txt","r")
- Content = F2.readAll()
- Announcements = textutils.unserialize(Content)
- F2.close()
- end
- function Runner()
- GetFiles()
- parallel.waitForAny(Int,CheckSchedule,PoCheck)
- os.reboot()
- end
- function Standby()
- Clear()
- term.setCursorPos(7,10)
- print("no power")
- while true do
- local id, message = rednet.receive()
- if id == Pwr and message == true then Power = true break end
- end
- if Power == true then
- Runner()
- else
- os.sleep(4)
- os.reboot()
- end
- end
- if Pwr ~= nil then
- rednet.send(Pwr,"status")
- local H, J, K = rednet.receive()
- Power = J
- else
- Power = true
- end
- if Power == true then
- Runner()
- else
- Standby()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement