7 posts
Posted 12 October 2016 - 06:11 PM
Hi! I made a code for a password protected computer. The password part works but when i type it in the screen just goes blank.
Here is the code:
os.pullEvent = os.pullEventRaw
while true do
term.clear()
term.setCursorPos(1, 1)
print("CreeperCity Computer Security")
write("Password: ")
if read("*") == "2007" then
print("Access Granted")
sleep(2)
term.clear()
term.setCursorPos(1, 1)
break
else
print ("Incorrect Password")
sleep(1)
end
end
os.pullEvent = oldPull
353 posts
Location
Orewa, New Zealand
Posted 12 October 2016 - 08:39 PM
Firstly, you should get into the habit of using CODE tags when inserting code, makes it easier to read.
os.pullEvent = os.pullEventRaw
while true do
term.clear()
term.setCursorPos(1, 1)
print("CreeperCity Computer Security")
write("Password: ")
if read("*") == "2007" then
print("Access Granted")
sleep(2)
term.clear()
term.setCursorPos(1, 1)
break
else
print ("Incorrect Password")
sleep(1)
end
end
os.pullEvent = oldPull
Where are you defining oldPull? It should be `local oldPull = os.pullEvent` on the first line, before you override it.
My guess is you are setting pullEvent to nil, and then ComputerCraft is completely crashing when the main shell tries to yield.
Edited on 12 October 2016 - 06:40 PM
54 posts
Location
Italy
Posted 12 October 2016 - 09:44 PM
-snip-
My guess is you are setting pullEvent to nil, and then ComputerCraft is completely crashing when the main shell tries to yield.
I think you're right. Just add at the top of the code
oldPull=os.pullEvent
7 posts
Posted 17 October 2016 - 12:20 AM
Firstly, you should get into the habit of using CODE tags when inserting code, makes it easier to read.
os.pullEvent = os.pullEventRaw
while true do
term.clear()
term.setCursorPos(1, 1)
print("CreeperCity Computer Security")
write("Password: ")
if read("*") == "2007" then
print("Access Granted")
sleep(2)
term.clear()
term.setCursorPos(1, 1)
break
else
print ("Incorrect Password")
sleep(1)
end
end
os.pullEvent = oldPull
Where are you defining oldPull? It should be `local oldPull = os.pullEvent` on the first line, before you override it.
My guess is you are setting pullEvent to nil, and then ComputerCraft is completely crashing when the main shell tries to yield.
It works now thanks!