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

[Lua][Error] startup:427: Expected string, string

Started by Mackan90096, 22 April 2013 - 10:10 PM
Mackan90096 #1
Posted 23 April 2013 - 12:10 AM
Hi! I'm trying to make a thing for my OS (MackOS) for storing settings specific to the user.

But I get an error: startup:427: Expected string, string

Line 427 is in this ccase line 17.

Code:


function register()
term.clear()
term.setCursorPos(math.floor(w-string.len("New User"))/2, 1)
print("New User")
term.setCursorPos(math.floor(w-string.len("Username:"))/2, 4)
write("Username: ")
usrName = read()
term.setCursorPos(math.floor(w-string.len("Password:"))/2, 6)
write("Password: ")
local pass = read("*")
fs.makeDir("users")
if not fs.exists("users/"..usrName) then
  fs.makeDir("users/"..usrName)
local file = fs.open("users/"..usrName.."/usrName", "a")
file.writeLine(pass)
file.close()
local file2 = fs.open("users/"..usrName.."/bg", a)
local bgLine = paintutils.loadImage(".logo")
file2.writeLine(bgLine)
file2.close()
sleep(0.5)
term.clear()
term.setCursorPos(math.floor(w-string.len("Registered:"))/2, 2)
print("Registered!")
sleep(0.5)
term.clear()
drawDesktop2()
elseif fs.exists("users/"..usrName) then
term.clear()
term.setCursorPos(math.floor(w-string.len("Username already in use!"))/2, 2)
print("Username already in use!")
sleep(1)
term.clear()
drawDesktop()
end
end

What am I doing wrong?
theoriginalbit #2
Posted 23 April 2013 - 12:14 AM
local file2 = fs.open("users/"..usrName.."/bg", a)
you missed the ' around the a
Mackan90096 #3
Posted 23 April 2013 - 12:15 AM
Oh, thanks.
Mackan90096 #4
Posted 23 April 2013 - 12:36 AM
– Ignore this post –