Jump to content




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


  • You cannot reply to this topic
3 replies to this topic

#1 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 22 April 2013 - 11:10 PM

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?

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 22 April 2013 - 11:14 PM

local file2 = fs.open("users/"..usrName.."/bg", a)
you missed the ' around the a

#3 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 22 April 2013 - 11:15 PM

Oh, thanks.

#4 Mackan90096

  • Signature Abuser
  • 518 posts
  • LocationIn my basement.

Posted 22 April 2013 - 11:36 PM

-- Ignore this post --





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users