Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mon = peripheral.wrap("top")
- sense = peripheral.wrap("left")
- local plist = sense.getPlayerNames()
- local cScan = textutils.serialize(plist)
- local RadarActive = true
- local isSecure = false
- local lockdown = false
- mon.setTextScale(1)
- mon.clear()
- --Terminal Main()
- function termMain
- local attempts = 0
- while true do
- term.clear()
- term.setCursorPos(1,1)
- local locked = true
- print("This is a secure Terminal. Your actions may be monitored")
- print("for quality assurance purposes.")
- print("Please enter your name:")
- local chek = read()
- if fs.exists("Clearance/"..chek) then
- local csec=tonumber(curr.readLine())
- if csec==1 then
- local chek=curr.readLine()
- print("Welcome "..cList[i]..". Please enter your password")
- local chek2 = read()
- if chek2 == chek then
- adminTerm()
- end
- end
- end
- end
- end
- --admin functions on terminal
- function adminTerm()
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.gray)
- term.clearLine()
- print("Set Player Security Status")
- term.setCursorPos(1,3)
- term.clearLine()
- print("Reset Player Security Status")
- term.setCursorPos(1,5)
- term.clearLine()
- print("Set Book Clearance Level")
- term.setCursorPos(1,7)
- term.clearLine()
- print("Remove Secured Book")
- term.setCursorPos(1,9)
- term.clearLine()
- print("Lock Down Gate")
- term.setCursorPos(1,11)
- term.clearLine()
- print("Quit")
- local b,x,y = term.mouse_click()
- if y == 13 then
- print("Goodbye.")
- os.sleep(0.5)
- termMain()
- end
- end
- adminTerm()
- --resets the security status of a player
- function resetSec(qName)
- setSecStat(qName,0)
- end
- --sets the security status of a player
- --does not allow the editing of an admin
- function setSecStat(qName,newSS)
- local locked = false
- if fs.exists("Clearances/"..qName) then
- local curr = fs.open("Clearances/"..qName,"r")
- local cSec = tonumber(curr.readLine())
- if cSec == 1 then
- locked=true
- end
- end
- if locked==false then
- local curr = fs.open("Clearances/"..qName,"w")
- curr.writeLine(newSS)
- curr.close()
- elseif locked==true then
- print("You do not have permission to edit this user.")
- end
- end
- --checks if user has file, if not creates it
- --if so, returns security level
- function secStatus(qName)
- local qList = fs.list("Clearances/")
- local sLev = 0
- local found = false
- for i=1, #qList do --check user files, return secLev
- if qName==qList[i] then
- local curr = fs.open("Clearances/"..qName,"r")
- print("Player: "..qName)
- sLev = tonumber(curr.readLine())
- print("sLev: "..sLev)
- curr.close()
- found = true
- end
- end
- if found == false then --create a new default user
- local curr = fs.open("Clearances/"..qName,"w")
- curr.writeLine("0")
- curr.close()
- end
- return sLev
- end
- --checks for Clearances directory, if not creates
- --it and stores a new admin
- function startChk()
- if fs.exists("Clearances/") == false then
- fs.makeDir("Clearances")
- term.clear()
- term.setCursorPos(1,1)
- local admin
- if RadarActive == true then
- if #plist>1 then
- print("Please Secure Area. Only 1 admin is allowed")
- while #plist>1 do
- plist = sense.getPlayerNames()
- end
- term.clear()
- end
- admin = plist[1]
- else
- print("Radar is currently offline")
- print("Please enter your name")
- admin = read()
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Welcome "..admin)
- print("Please enter a password")
- local adpass = read()
- local secStat = 1
- local file = fs.open("Clearances/"..admin,"w")
- file.writeLine(secStat)
- file.writeLine(adpass)
- file.close()
- end
- end
- function scan()
- while true do
- plist = sense.getPlayerNames()
- local nScan = textutils.serialize(plist)
- os.sleep(0.15)
- for i=1,#plist do
- mon.setTextColor(colors.white)
- mon.setCursorPos(2,2*i-1)
- mon.write(plist[i])
- local level = secStatus(plist[i])
- mon.setTextColor(colors.red)
- mon.write(" "..level)
- end
- if cScan~=nScan then
- mon.clear()
- cScan=nScan
- end
- end
- end
- function getClick()
- event,side,x,y = os.pullEvent("monitor_touch")
- mon.setCursorPos(x,y)
- mon.setBackgroundColor(colors.cyan)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- end
- function main()
- while true do
- getClick()
- end
- end
- startChk()
- --parallel.waitForAll(scan, main)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement