1 posts
Posted 23 November 2012 - 08:19 PM
i spent like 6 hours trying to get a code to work but i had no luck…
i want to write a program that has a password and once you enter the password it brings you to a prompt where you can turn the system on or off.
i tried it so many ways but i dont really know where to start
any and all help would be apreacheted
p.s. my grammer is bad becaues its late and im about to fall asleep….. (huge minecraft session today)
767 posts
Posted 23 November 2012 - 10:31 PM
Hey!
you could try learning some basic password systems, then
i can give you an example here.
Edit startup on your computer, and enter this:
Spoiler
os.pullEvent = os.pullEventRaw
function RunPrompt()
local pr = true
while pr do
term.clear()
term.setCursorPos(1,1)
print("type "exit" to exit, or "start" to start!")
term.setCursorPos(1,10)
write("command > ")
ip = read()
if ip == "start" or ip == "Start" then
pr = false
-- your function name, for your "start"
elseif ip == "exit" or ip == "Exit" then
sleep(1)
os.shutdown()
end
end
end
function passask()
local password = "hello"
local running = "true"
while running do
term.clear()
term.setCursorPos(1,1)
print("password:")
write(" > ")
local passinput = read("#")
if passinput == password then
term.clear()
term.setCursorPos(1,1)
running = false
RunPrompt()
else
term.clear()
term.setCursorPos(1,1)
end
end
end
142 posts
Location
In the depths of my computer.
Posted 24 November 2012 - 12:06 PM
Lol woops, wrong one.
Edited on 24 November 2012 - 11:10 AM
4 posts
Posted 25 November 2012 - 01:56 AM
local running = "true" while running do
Doesn't true in a string produce an error?
2088 posts
Location
South Africa
Posted 25 November 2012 - 02:40 AM
local running = "true" while running do
Doesn't true in a string produce an error?
Yeah should be
local running = true
But I think if he were to do while running == "true" do might work
767 posts
Posted 25 November 2012 - 05:28 AM
I did not make the
Running = "true"
i did make this
local pr = true
so dont cut me down, please.
2088 posts
Location
South Africa
Posted 25 November 2012 - 05:56 AM
I did not make the Running = "true" i did make this local pr = true so dont cut me down, please.
Look on the 2nd line of your passask function, what is that then?
767 posts
Posted 25 November 2012 - 06:57 AM
Oh. Lol, i'm really sorry about thar xD
you've right remi :-D
4 posts
Posted 25 November 2012 - 08:52 AM
Haha, sure I can specify the line when Im gonna cut someone down next time. So… I guess we're both cut now huh?