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

startup:6: attempt to concatenate string and nil

Started by Angel_Code, 29 November 2013 - 01:41 AM
Angel_Code #1
Posted 29 November 2013 - 02:41 AM
i keep getting this error
i have searched the forums but none of them seem to fix my specific problem
startup:6: attempt to concatenate string and nil
on line 6

i have no programing knowledge this is just what i have pulled from other programs and have been messing with to see how things work.

any help is greatly appreciated


my computer logon

if not fs.exists("users") then
fs.makeDir("users")
shell.run("startup")

else
local check = fs.open("users/"..username, "r")
local pass = check.readAll()
write("username: ")
local username = read()
write("password: ")
local password = read()
if not fs.exists("users/"..username) then
print("user does not exist")
os.reboot()
else
if password == pass then
term.clear()
term.setCursorPos(1,1)
else
t = 1
while true do
print("password was incorrect")
textutils.slowPrint("System Shutting Down in"..t)
t = t+ 1
sleep(10.1)
os.reboot()
end
end
end
end
TheOddByte #2
Posted 29 November 2013 - 11:17 AM
Well..

local check = fs.open("users/" .. username, "r")
Where is 'username' declared?

You're declaring it after you are trying to use it, May that be the problem? I think so :P/>
Edited on 29 November 2013 - 10:20 AM
Angel_Code #3
Posted 01 December 2013 - 01:57 AM
Thank you for the assistance