Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This Program keeps track of a prisoners Schedule and ensures the Cells main systems run
- Settings_PrisonerID = 'n'
- Settings_StorageBlock = -1
- Settings_PrisonerName = 'n'
- Settings_PrisonerAccess = -1
- Settings_CellSleep = 0
- Settings_CellAwake = 0
- CellState = "start"
- PersonalID = 0
- SystemMode = "StandBy"
- start()
- function start()
- if fs.exists("Prisoner") == false then
- local file = fs.open("Prisoner","w")
- file.writeLine("Disabled")
- file.close()
- end
- GetPrisonerData()
- if CellState == "Disabled" then
- DISABLED()
- else
- MAIN()
- end
- end
- function DISABLED()
- term.clear()
- print("Cell is Currently Disabled, to reenable, go to")
- print("file called 'Prisoner' and set the first line to")
- print("Prisoners Name, the 2nd line to 'need Update' and the 3rd Line")
- print(" to the Prisoners ID")
- print("then restart the computer, the Program should Continue")
- end
- function MAIN()
- local Time = os.time("ingame")
- while true do
- Time = os.time("ingame")
- if Time == Settings_CellCleep then
- CellMode("Sleep")
- elseif Time == Settings_CellAwake then
- ScheduleUpdate()
- CellMode("Wake")
- elseif SystemMode == "StandBy" then
- ScheduleCheck(Time)
- else
- break
- end
- end
- end
- function ScheduleCheck(Time)
- local file = fs.open("Schedule","r")
- for i = 1, #24 do
- if file.readLine(i*2-1) == Time
- file.close()
- ScheduleAction(i*2)
- end
- end
- end
- function ScheduleAction(I)
- local file = fs.open("Schedule","r")
- if file.readLine(I) == "Testing" then
- CellManager("Testing","Move",0)
- elseif file.readLine(I) == "Search" then
- CellManager("Cell","Search",1)
- elseif file.readLine(I) == "Repairs" then
- CellManager("Cell","Repairs","Cell")
- elseif file.readLine(I) == "Meal" then
- elseif file.readLine(I) == "RollCall" then
- end
- file.close()
- end
- function ScheduleUpdate()
- rednet.open("bottom")
- rednet.send(PersonalID,"Schedule",1000)
- rednet.send(PersonalID,Settings_PrisonerName,1000)
- repeat
- local id, message = rednet.receive()
- until message == "Method"
- rednet.send(PersonalID,"view",1000)
- repeat
- local id, message = rednet.receive()
- until id == PersonalID
- local file = fs.open("Schedule","w")
- file.write(message)
- file.close()
- end
- function CellManager(Target,Action,Variable)
- if Target == "Cell" then
- if Action == "Search" then
- Bots("Security","Watch","Prisoner")
- Bots("Maintenance","Search","Containers")
- elseif Action == "Repairs" then
- Bots("Maintenance","Repair","Furniture")
- elseif Action == "CleanUp" then
- Bots("Maintenance","Repair","All")
- end
- elseif Target == "Testing" then
- elseif Target == "Prisoner" then
- elseif Target == "Turtles" then
- end
- end
- function CellMode(Action)
- end
- function Bots(Group,Action,Target)
- rednet.open("bottom")
- local file = fs.open("BotIDs","r")
- if Group == "Security then
- if Action == "Watch" then
- rednet.send(file.readLine(1),"Watch",0)
- elseif Action == "Eliminate" then
- rednet.send(file.readLine(1),"Eliminate",0)
- rednet.send(file.readLine(1),PrisonerName,0)
- end
- elseif Group == "Maintenance" then
- if Action == "Search" then
- if Target == "Player" then
- rednet.send(file.readLine(2),"S_Player",0)
- elseif Target == "Containers" then
- rednet.send(file.readLine(2),"S_Containers",0)
- end
- elseif Action == "Repair" then
- if Target == "All" then
- elseif Target == "Furniture" then
- end
- end
- end
- file.close()
- end
- function GetPrisonerData()
- rednet.open("bottom")
- local file = fs.open("Prisoner","r")
- if file.readLine(1) == "Disabled" then
- CellState = "Disabled"
- elseif file.readLine(1) ~= "Disabled and file.readLine(2) == "Need Update" then
- CellState = "Data Required"
- Settings_PrisonerID = file.readLine(3)
- file.delete()
- rednet.broadcast(Settings_PrisonerID,1000)
- repeat
- local id, message, protocol = rednet.receive()
- until protocol == 1203
- local file = fs.open("Prisoner","w")
- file.write(message)
- file.close()
- CellState = "Operating"
- else
- CellState = "Operating"
- Settings_PrisonerID = file.readLine(3)
- Settings_PrisonerName = file.readLine(1)
- Settings_PrisonerAccess = file.readLine(4)
- Settings_CellSleep = file.readLine(5)
- Settings_CellAwake = file.readLine(6)
- Settings_StorageBlock = file.readLine(7)
- end
- file.close()
- end
Add Comment
Please, Sign In to add comment