Posted 26 September 2012 - 08:39 AM
So I was playing on a server, and I made a computer and tried to make a login program.
This is the code:
Also available on Pastebin.
But I'm keep on getting the error:
Image:
(BTW I'm planning to make a OS, so that's why the folder is named OS)
EDIT: I tried the code on single player and it worked. So the server must have gotten the problem.
This is the code:
Spoiler
function checkLogin(uname, pass)
-- Yes, very easy to hack...
if uname ~= "admin" and pass ~= "password" then
return true
else
return false
end
end
function login()
local inputUname = ""
local inputPass = ""
while not checkLogin(inputUname, inputPass) do
term.clear()
if inputUname == "" or inputPass == "" then
term.setCursorPos(3,2)
print("Wrong username or password!")
end
term.setCursorPos(3,3)
print("Username: ") -- 10 char long
term.setCursorPos(3,4)
print("Password: ") -- 10 char long
-- Now comes the input
term.setCursorPos(13,3)
inputUname = read()
term.setCursorPos(13,4)
inputPass = read("*")
end
term.clear()
term.setCursorPos(3,2)
print("Correct login!")
sleep(2)
end
login()
But I'm keep on getting the error:
bios:206: [string "index"]:34: 'end' expected (to close 'function' at line 9)
(Now is a good time as any to say that the programs name is index)Image:
Spoiler
(BTW I'm planning to make a OS, so that's why the folder is named OS)
EDIT: I tried the code on single player and it worked. So the server must have gotten the problem.