Posted 10 December 2013 - 10:31 AM
I'm trying to write a system that will save and load a password, username, ect. However, I cannot seem to get past these errors:
Please help!
--This is the start of a Terminal Glasses OS
--All original code is by Castform
--2013-2014
local user = "admin" --this initializes the variable
if fs.isDir("/tungsten") then --checks for directory for the OS
--don't need to do anything
else
fs.makeDir("/tungsten") -- if not there, creates the directory
end
if fs.exists("/tungsten/username") then
local user = fs.read("/tungsten/username","r") --throws error here
--tungstenos:14: attempt to call nil
print(user)
else
print("Please enter your desired username...") --notification to player
local user = read() --read the input
local userHandle = fs.open("/tungsten/username","w") --open file in write mode
userHandle.write(user) --write user
print(user) --this is to make sure the user variable being null is not the problem (it isn't)
userhandle.close() --also throws error here
--tungstenos:22:attempt to index ? (a nil value)
end
print(user)
Please help!