5
I created a system quickly to test a new variable, but I do not know how to print the users inserted in the table, and when I give print
he shows it: table: 0035AE18
My code:
Conta = {balance = 0}
Contas = {}
Senhas = {}
Inicial = 5000
function Conta:withdraw (v)
Conta.Balance = Conta.Balance - v
end
function Login()
io.write("Digite seu Usuario\n")
usuariol = io.read()
io.write("Digite sua senha\n")
senhal = io.read()
for i=0, #Contas do
for j=0, #Senhas do
if usuariol == Contas[i] and senhal == Senhas[j] then
io.write("Logado com sucesso!")
Cadastro()
end
end
end
end
function Cadastro()
io.write("Ola, seja bem vindo ao sistema de Banco 1.0 By Charles \n")
io.write("Deseja criar uma conta? \n")
resposta = io.read()
if resposta == "sim" or resposta == "Sim" then
io.write("Ok, informe seu nome de usuario \n")
usuario = io.read()
io.write("Informe sua senha \n")
senha = io.read()
io.write("Aguarde um instante!\n")
if #Contas == 0 and #Senhas == 0 then
table.insert(Contas, 1, usuario)
table.insert(Senhas, 1, senha)
else
table.insert(Contas, usuario)
table.insert(Senhas, senha)
end
Login()
elseif resposta == "tabela" then
print(#Contas)
print(#Senhas)
end
end
Cadastro()
The system works like this: it creates the account, then you log back into it for account creation.
Let’s suppose I created 3 accounts and then in the "you want to create account" part I type "table" it will show me the number of accounts and passwords created.
But I want to display them not in size capacity but by string. Ex:
t = {'teste'}
print(t)
Console:
table: test
There was a vote to undo the exclusion of your question, which indicates that probably someone wants to answer it. So I broke the exclusion. Please let me know if you don’t like it. Thank you.
– bfavaretto
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero