Posted 15 February 2013 - 08:47 AM
Title : Problem with a code locked door
Hi there,
Today, I've made a code locked door but it doesn't work…
I used the code
to make people unavaliable to stop the program whitout an admin password…
But when the line
is censed to run, it doesn't and I can't stop the program…
If someone could help me it would be very kind ;-P
Thanks and have a good day !
Here is my code : (french parts are just printed texts)
Hi there,
Today, I've made a code locked door but it doesn't work…
I used the code
local pullEvent = os.pullEvent
os.pullEvent = os.pullEventRaw
-- If the desired conditions are met, you can run this line to allow the program to be terminated.
os.pullEvent = pullEvent
to make people unavaliable to stop the program whitout an admin password…
But when the line
os.pullEvent = pullEvent
is censed to run, it doesn't and I can't stop the program…
If someone could help me it would be very kind ;-P
Thanks and have a good day !
Here is my code : (french parts are just printed texts)
local pullEvent = os.pullEventRaw
os.pullEvent = os.pullEventRaw
local side1 = "left"
local side2 = "right"
local opentime = 5
local musictime = 30
local pswd = "ftb"
local guest = "guest"
local admin = "admin"
local adminpswd = "..."
while true do
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.white)
print("Entrez le mot de passe")
term.setTextColor(colors.lightGray)
print("(Si vous ne connaissez pas le code tapez 'guest' !)")
term.setTextColor(colors.white)
local input = read("*")
if input == pswd then
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.lime)
print("Bienvenue !")
rs.setOutput(side1,true)
sleep(opentime)
rs.setOutput(side1,false)
elseif input == guest then
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.blue)
print("Attendez que l'on vienne vous ouvrir !")
disk.playAudio(side2)
sleep(musictime)
disk.stopAudio(side2)
elseif input == admin then
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.yellow)
print("ADMIN MODE")
print("Please enter Admin password:")
input = read(*)
if input == adminpswd then
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.lime)
print("You can now stop this program !")
os.pullEvent = pullEvent
sleep(opentime)
else
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.red)
print("Wrong admin password !")
sleep(opentime)
end
else
term.clear()
term.setCursorPos(1,1)
term.setTextColor(colors.red)
print("Mauvais mot de passe !")
sleep(opentime)
end
end