This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Moofy's profile picture

Have a door lock open automatic and disable edit files.

Started by Moofy, 22 July 2012 - 06:45 PM
Moofy #1
Posted 22 July 2012 - 08:45 PM
I made a program called "open" which gives this code:
[color=#000000][font=monospace,]local side = "left" -- Change left to whatever side your door / redstone is on, E.G: left, right, front, back, bottom, top. Be sure to leave the "s around it, though[/font][/color]
local password = "bacon" -- Change bacon to what you want your password to be. Be sure to leave the "s around it, though
local opentime = 5 -- Change 5 to how long (in seconds) you want the redstone current to be on. Don't put "s around it, though
term.clear() -- Clears the screen
term.setCursorPos(1,1) -- Fixes the cursor position
write("Password: ") -- Prints 'Password: ' to the screen
local input = read("*") -- Makes the variable 'input' have the contents of what the user types in, the "*" part censors out the password
if input == password then -- Checks if the user inputted the correct password
 term.clear() -- Already explained up top
 term.setCursorPos(1,1)
 print("Password correct!") -- Prints 'Password correct!' to the screen
 rs.setOutput(side,true) -- Output a redstone current to the side you specified
 sleep(opentime) -- Wait the amount of seconds you specifed, then..
 rs.setOutput(side,false) -- Stop outputting a redstone current
 os.reboot() -- Reboot the computer, reopening the lock
else -- Checks if the user didn't input the correct password
 term.clear()
 term.setCursorPos(1,1)
 print("Password incorrect!") -- Prints 'Password incorrect!' to the screen
 sleep(2) -- Waits 2 seconds
 os.reboot() -- Reboot the computer, reopening the lock
end

with my own inputs, what i wan't is to disable the CTRL + T
I just add on top of it: 

os.pullEvent = os.pullEventRaw
But i need after the os.reboot() to acces the program "open" by default.


What to do?
KevinW1998 #2
Posted 22 July 2012 - 09:06 PM
ah uhm just save the old os.pullEvent in a variabel and load it after it again e.g.

tmp = os.pullEvent
os.pullEvent = os.pullEventRaw
-- Code
-- After Success
os.pullEvent = tmp
Lyqyd #3
Posted 22 July 2012 - 09:12 PM
ah uhm just save the old os.pullEvent in a variabel and load it after it again e.g.

tmp = os.pullEvent
os.pullEvent = os.pullEventRaw
-- Code
-- After Success
os.pullEvent = tmp

What? That's completely unrelated to what he asked.

To answer the question, add this line to the startup file on the computer:


shell.run("open")