63 posts
Location
Amsterdam
Posted 10 March 2012 - 10:57 AM
Hey everyone,
I've been playing around with computercraft for a few days now, making simple locks, clocks, etc. Now I'm working on a missle launch system for my rocket sience IC2 addon. But now i've ran into a little issue.
When I launch the code it doesn't display the text: "Password: ", it only shows up after I entered the username. Is there a way to fix this? I'm fairly new to programming so it's probably easy to fix, I just can't find out how. The program is not even close to being finished but I just ran into this and was wondering how I could fix it.
term.clear()
term.setCursorPos(1,1)
username = "1v2l3a4m5e6n"
password = "pass"
passsymbol = "*"
debug = "debug"
print("Missle Launch System V1.0")
print(" ")
print("Enter login details:")
write("Username: ")
uinput = io.read()
write("Password: ")
pinput = io.read(passsymbol)
term.clear()
term.setCursorPos(1,1)
if uinput == username and pinput == password then
shell.run("disk/launch")
end
Thanks in advance,
1v2l3a4m5e6n
411 posts
Posted 10 March 2012 - 11:30 AM
io.read and read for that matter, stop the program until input is givin
You could print both those lines then use
term.setCursorPos(x,y)
to make your input appear at the right place
63 posts
Location
Amsterdam
Posted 10 March 2012 - 11:49 AM
io.read and read for that matter, stop the program until input is givin
You could print both those lines then use
term.setCursorPos(x,y)
to make your input appear at the right place
io.read and read for that matter, stop the program until input is givin
You could print both those lines then use
term.setCursorPos(x,y)
to make your input appear at the right place
Alright, thanks.
So it should be like this?
term.clear()
term.setCursorPos(1,1)
username = "1v2l3a4m5e6n"
password = "board"
passsymbol = "*"
debug = "glow"
print("Missle Launch System V1.0")
print(" ")
print("Enter login details:")
write("Username: ")
write("Password: ")
term.setCursorPos(x,y)
uinput = io.read()
pinput = io.read(passsymbol)
term.clear()
term.setCursorPos(1,1)
if uinput == username and pinput == password then
shell.run("disk/launch")
end
44 posts
Location
Livonia
Posted 10 March 2012 - 01:46 PM
well i replaced in my code this"if enteredKey = io.read()" to "if enteredKey = io.read(passkey)" and it tells me "io:5: Unsupported format" what did i do wrong? P.S. your 'passsymbol' is my 'passkey'
724 posts
Posted 10 March 2012 - 02:11 PM
if enteredKey = io.read(passkey)
You should use "==" for comparison, "=" for assignment.
"io:5: Unsupported format"
unsupported format means other than "w", "r", "a", "rb", "wb", "ab" modes in line 5
44 posts
Location
Livonia
Posted 10 March 2012 - 02:18 PM
oh… ok thanks
44 posts
Location
Livonia
Posted 10 March 2012 - 02:24 PM
print("Please Enter Your Password:")
local enteredKey = io.read(passkey)
if enteredKey == password then
print("Your Login Is Succesful, Pieiscool32")
shell.run "servermissioncontrol"
elseif enteredKey == password2 then
print("Your Login Is Succesful, Guest")
shell.run "servermissioncontrol"
else print("Please Try Again")
now it says line 2 has an unexpected symbol.
724 posts
Posted 10 March 2012 - 02:41 PM
function io.read( _sFormat )
if _sFormat and _sFormat ~= "*l" then
error( "Unsupported format" )
end
return _G.read()
end
As you see, argument can be only "*l"
It seems you need read() instead of io.read()
44 posts
Location
Livonia
Posted 10 March 2012 - 04:28 PM
thanks, it works now…