Reputation: 49
I'm trying to make a basic account creator for a "bank" type thing in my personal time, and I've run into a problem. I created a file called "newAccount" to serve the purpose of making new accounts, but when I run it, it only asks the first question, and then it stops working.
Here's what I have so far.
print("What is the user's name?")
name = read()
file = io.open(name ,"w")
file:write(1, "Name: " + name, "\n")
print("What do they owe?")
owe = read()
file:write(2, "Owe: " + owe, "\n")
print("What is their account balance?")
balance = read()
file:write(3, "Balance: " + balance, "\n")
file:close(name)
After it stops running, it says:
newAccount:4: attempt to perform arithmetic __add on string and string
App has finished, press any key to exit."
Upvotes: 2
Views: 421
Reputation: 122463
Lua uses ..
to concatenate strings, not +
. Change
"Name: " + name
to
"Name: " .. name
Upvotes: 2