2

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."

1 Answer 1

2

Lua uses .. to concatenate strings, not +. Change

"Name: " + name

to

"Name: " .. name
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.