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

Help with a Passworded system

Started by btmull, 23 November 2012 - 07:19 PM
btmull #1
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)
Goof #2
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
Expenox #3
Posted 24 November 2012 - 12:06 PM
Lol woops, wrong one.
Edited on 24 November 2012 - 11:10 AM
per56231 #4
Posted 25 November 2012 - 01:56 AM
 local running = "true" while running do  

Doesn't true in a string produce an error?
remiX #5
Posted 25 November 2012 - 02:40 AM
local running = "true"
 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
Goof #6
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.
remiX #7
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?
Goof #8
Posted 25 November 2012 - 06:57 AM
Oh. Lol, i'm really sorry about thar xD

you've right remi :-D
per56231 #9
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?