Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --theinsekt's player detector lock
- --pastebin get juRJgwTe startup
- --function to set to enable or disable ctrl-t
- --http://www.computercraft.info/forums2/index.php?/topic/2732-disable-ctrlt/
- local pullEventCopy = os.pullEvent
- function setCtrlT(value)
- if value then
- os.pullEvent = pullEventCopy
- else
- os.pullEvent = os.pullEventRaw
- end
- end
- function loadIntoTable(path)
- if not fs.exists(path) then
- return nil
- end
- local h=fs.open(path, "r")
- if h==nil then
- return nil
- end
- local table={}
- while(true) do
- local value=h.readLine()
- if value==nil then break end
- table[value]=true
- end
- h.close()
- return table
- end
- function adminClick(admin, adminSide, openSide)
- print()
- print("right click open side to add player")
- print("right click admin side to go to admin mode")
- local event, dside, player=os.pullEvent("player")
- if dside==adminSide then
- if player==admin then
- print()
- print("hold ctrl-t to terminate program")
- print("right click a detector to exit admin mode")
- setCtrlT(true)--enable ctrl-t
- os.pullEvent("player")
- setCtrlT(false)--enable ctrl-t
- else
- return
- end
- elseif dside==openSide then
- print("not yet implemented")
- print("should try to add to openers")
- sleep(3)
- return
- end
- print("Unknown side")
- end
- function clear()
- term.clear()
- term.setCursorPos(1, 1)
- end
- local openers={
- }
- local admins={
- ["theinsekt"]=true,
- }
- local savePath="dataValues"
- local doorSide="bottom"
- local openSide="back"
- local adminSide="right"
- local doorTime=3
- local testing=true
- setCtrlT(false)--disable ctrl-t
- clear()
- print("booting...")
- sleep(1)
- while(true) do
- clear()
- if testing then
- print("debug mode...")
- setCtrlT(true)--enable ctrl-t
- end
- print("adminSide: ",adminSide, " openSide: ",openSide, " doorSide: ",doorSide)
- print()
- print("right click openDide to open door")
- print("right click adminSide to add player, or twice to enter admin mode")
- print()
- local event,dside,player = os.pullEvent("player")
- if dside==adminSide and admins[player]~=nil then
- local admin=player
- print("admin stuff*****")
- adminClick(admin, adminSide, openSide)
- elseif dside==openSide and (openers[player]~=nil or admins[player]~=nil) then
- print("Opening!")
- redstone.setOutput(doorSide,true)
- sleep(doorTime)
- redstone.setOutput(doorSide,false)
- else
- print("Not allowed!")
- end
- sleep(1)
- end
- setCtrlT(true)--enable ctrl-t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement