Jump to content




Trying to make a locked computer

computer command wireless

3 replies to this topic

#1 ZegMaarWilly

  • New Members
  • 1 posts

Posted 07 November 2015 - 08:54 PM

Hello everybody,

Ive been trying to make an locked computer and it hasnt quite worked out for me,
i'm new to this all and need some help on this, everytime i enter my code it says "Access Granted" but than puts me back on the login screen
My next step will be trying to make a locked communication system / floppy disks, so if you got any tips for those :)

Here is the code (I didn't know how to put it in any other way)

os.pullEvent = os.pullEventRaw
if true than do
term.clear()
term.setCursorPos(1, 1)
textutils.slowPrint("Enter Password:")
input = ("*")
if input == "Hello" then
term.clear()
term.setCursorpos(1, 1)
textutils.slowPrint("Welcome User!")
else
textutils.slowPrint("Incorrect Password!")
sleep(5)
end
end
end

Thanks for the help :D!

#2 Creator

    Mad Dash Victor

  • Members
  • 2,168 posts
  • LocationYou will never find me, muhahahahahaha

Posted 07 November 2015 - 10:42 PM

I believe you want to change the second line to "while true do". By the way, the keyword is then, not than. Also, after printing "Welcome user" add break on a new line. The code should look like this:
os.pullEvent = os.pullEventRaw
while true do
term.clear()
term.setCursorPos(1, 1)
textutils.slowPrint("Enter Password:")
input = ("*")
if input == "Hello" then
term.clear()
term.setCursorpos(1, 1)
textutils.slowPrint("Welcome User!")
break
else
textutils.slowPrint("Incorrect Password!")
sleep(5)
end
end
end


#3 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 07 November 2015 - 11:05 PM

By the way, "*" will never equal "Hello". You may want to use read( "*" )

Edited by KingofGamesYami, 07 November 2015 - 11:06 PM.


#4 Hydrotronics

  • Members
  • 131 posts
  • LocationThe hall of 1000 monkeys and only 1 typewriter

Posted 07 November 2015 - 11:26 PM

View PostZegMaarWilly, on 07 November 2015 - 08:54 PM, said:


os.pullEvent = os.pullEventRaw
if true than do
term.clear()
term.setCursorPos(1, 1)
textutils.slowPrint("Enter Password:")
input = ("*")
if input == "Hello" then
term.clear()
term.setCursorpos(1, 1)
textutils.slowPrint("Welcome User!")
else
textutils.slowPrint("Incorrect Password!")
sleep(5)
end
end
end

I've noticed that if you get it wrong, it allows you into the computer anyway, so i was thinking maybe for the end result of getting it wrong you could do:
--Password Code
else
textutils.slowPrint("Incorrect Password")
sleep(1)
os.reboot()
end

I also changed the sleep time as waiting 5 seconds is just boring.

also, i have a strongish lock if you're willing to use:

os.pullEvent = os.pullEventRaw

term.clear()
term.setCursorPos(1,1)
print"Enter Password"
write""
input = read("*")
if input == "hello" then
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("Welcome...")
sleep(1)
term.clear()
term.setCursorPos(1,1)
print"CraftOS 1.7"
else
term.clear()
term.setCursorPos(1,1)
textutils.slowPrint("Incorrect Password")
sleep(1)
os.reboot()
end

It is a simple yet effective password.
I didn't bother making it look pretty either, but you can do that yourself if you want :)
Also, This code means you dont need to have tons of ends at the end of the code, also, it doesn't use a while loop, which isn't very good i think.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users