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

[Lua][Error]Sorry again, I got a new problem

Started by Spongy141, 10 March 2013 - 08:35 PM
Spongy141 #1
Posted 10 March 2013 - 09:35 PM
Well as the title says, I got a Error: bios:338: [string "DynationOS"]:19: '}' expected (to close '{' at line 17)
the weird thing is, is it is closed… can someone help me out by fixing it? Don't worry, I didn't make you guys have to hunt for the section I need help in, the full program is not even close to being finished and already 150 lines.
Spoiler



  term.setTextColor(colors.blue)
  print("Account name: ")
  term.setTextColor(colors.white)
  local user = 
  { 
    file = fs.open("Account","r")  
    user = file:readLine()
  }  
  local name = read()
  if name == (user) then
    file.close()
    term.setTextColor(colors.blue)
print("Password: ")
local pass = 
{ 
 file = fs.open("Account","r")  
 pass = file:readLine()  
}
term.setTextColor(colors.white)
local passw = read()
elseif passw == (pass) then
 file.close()
 User()
  else
    file.close()
    term.setTextColor(colors.red)
print("Sorry account does not exist")
sleep(1.5)
print("Redirecting you to setup")
setup()
  end
theoriginalbit #2
Posted 10 March 2013 - 09:39 PM
each entry in a table must be separated by a comma. you have not done this. so fix that and you should be good.

EDIT: Well actually idk what you're doing there

is it meant to be this

local handle = fs.open("Account","r")
local user = handle.readLine()
or is it meant to be this

local user = {}
user["file"] = fs.open("Account","r")
user["user"] = user.file.readLine()
immibis #3
Posted 10 March 2013 - 09:49 PM
It's meant to be this:

local user = 
  { 
    file = fs.open("Account","r"),
    user = file:readLine()
  }  
Note the comma.
Spongy141 #4
Posted 10 March 2013 - 09:50 PM
each entry in a table must be separated by a comma. you have not done this. so fix that and you should be good.

EDIT: Well actually idk what you're doing there

is it meant to be this

local handle = fs.open("Account","r")
local user = handle.readLine()
or is it meant to be this

local user = {}
user["file"] = fs.open("Account","r")
user["user"] = user.file.readLine()
Lol well I didn't want to post the ENTIRE program code, but what that function does it allows you to login… so I was trying to call the users information from one file to the main program.
EDIT: I put the commas in, it didn't give me a error, but it didn't work correctly… I probably need to fix the account file..
theoriginalbit #5
Posted 10 March 2013 - 09:50 PM
It's meant to be this:

local user =
  {
	file = fs.open("Account","r"),
	user = file:readLine()
  }  
Note the comma.
Could that not cause problems considering you are trying to reference a table element while constructing the second element?
immibis #6
Posted 10 March 2013 - 09:52 PM
It's meant to be this:

local user =
  {
	file = fs.open("Account","r"),
	user = file:readLine()
  }  
Note the comma.
Could that not cause problems considering you are trying to reference a table element while constructing the second element?
Oh - yeah, that won't work.
It's also file.readLine not file:readLine
io uses :, fs uses .

And in your code, user["file"] and user["user"] can be replaced by user.file and user.user
theoriginalbit #7
Posted 10 March 2013 - 09:57 PM
And in your code, user["file"] and user["user"] can be replaced by user.file and user.user
I've found it doesn't always work for me, but either way, using . notation is just syntactical sugar, its not functionally any different.
Spongy141 #8
Posted 10 March 2013 - 10:01 PM
If one of you thinks they can help way more by seeing the entire code PM me, since it still doesn't work as I want it too.