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

'=' expected error

Started by rick3333, 16 January 2013 - 11:33 AM
rick3333 #1
Posted 16 January 2013 - 12:33 PM
hi I keep getting a '=' expected error at line 5 of my 8 digit number generator code

code:

for i = 1, 8 do
  local ranChar = math.random(1,8)
  pass = pass ranChar
end
print("password is ",pass)
I sat at my computer for hours and could find it.
I need help with this problem
D3matt #2
Posted 16 January 2013 - 12:38 PM
You need to concatenate ranchar with pass using ..

The code should look like this:

pass = ""
for i = 1, 8 do
  local ranChar = math.random(1,8)
  pass = pass..ranChar
end
print("password is ",pass)
rick3333 #3
Posted 16 January 2013 - 01:01 PM
You need to concatenate ranchar with pass using ..

The code should look like this:

pass = ""
for i = 1, 8 do
  local ranChar = math.random(1,8)
  pass = pass..ranChar
end
print("password is ",pass)
thanks for the help