I am working on a Disk that would program the startup to a locking program, but I need to beable to make whatever you need to input to be read then set to variable. How would I need to do that?
How to make an input = setpassword?
Started by SNWLeader, Sep 30 2012 04:16 AM
9 replies to this topic
#1
Posted 30 September 2012 - 04:16 AM
#2
Posted 30 September 2012 - 04:20 AM
Does this do what you're looking for?
password = read()
#4
Posted 30 September 2012 - 04:31 AM
That's exactly what read() does. If your variable is named "input", then do:
An applicable example:
input = read()
An applicable example:
password = 'yourpassword'
while true do
term.clear()
term.setCursorPos(1,1)
print 'Password?'
input = read()
if input == password then
print 'Access Granted'
rs.setOutput('left', true)
sleep(3)
rs.setOutput('left', false)
else
print 'Access Denied'
end
end
#5
Posted 30 September 2012 - 04:39 AM
Kingdaro, on 30 September 2012 - 04:31 AM, said:
That's exactly what read() does. If your variable is named "input", then do:
An applicable example:
input = read()
An applicable example:
password = 'yourpassword'
while true do
term.clear()
term.setCursorPos(1,1)
print 'Password?'
input = read()
if input == password then
print 'Access Granted'
rs.setOutput('left', true)
sleep(3)
rs.setOutput('left', false)
else
print 'Access Denied'
end
end
I am making a disk to program that automatically into a computer as a startup
#6
Posted 30 September 2012 - 04:53 AM
So are you asking how to get the user's input or how to copy a program from the disk to the computer as the disk's startup routine?
If you want the input thing:
if you want the copy thing
Any program called startup will be run when a computer or turtle boots up.
if there is a disk in a disk drive and it contains a program called startup, that program will have priority over the computer's startup program.
If you want the input thing:
input = read() --input will then become whatever the user types before pressing enter
if you want the copy thing
shell.run("copy", "disk/password", "startup") --copies the program 'password' on the disk onto the computer as a the program 'startup'
Any program called startup will be run when a computer or turtle boots up.
if there is a disk in a disk drive and it contains a program called startup, that program will have priority over the computer's startup program.
#7
Posted 30 September 2012 - 05:02 AM
Actually I need it to set the password of the lock system. how do I get it to do that?
#8
Posted 30 September 2012 - 05:15 AM
Oh, so you want it to write a program file to the computer, setting a variable declared inside that program file to whatever the user enters? You'll want to use a multi-line string, then add the line with user input where appropriate.
#9
Posted 30 September 2012 - 05:20 AM
well my problem is I need it to print the variable in this command
in here
fs.open("startup","w").writeLine("password = _____")
what happens to me if say the variable is A then in the document it says just A. i need it to input what A equals.
in here
fs.open("startup","w").writeLine("password = _____")
what happens to me if say the variable is A then in the document it says just A. i need it to input what A equals.
#10
Posted 30 September 2012 - 05:52 AM
Try this:
print("Input password, please")
local pass = read("*")
handle = fs.open("startup", "w")
if handle then
handle.writeLine([[local password = "]]..pass..[["]])
handle.write([[ while true do
term.clear()
term.setCursorPos(1, 1)
print("Input Password:")
input = read("*")
if input == password then openDoorOrWhatever() end
end]])
handle.close()
end
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











