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

My banking system keeps looping need help!

Started by WolfDood, 29 October 2016 - 05:10 AM
WolfDood #1
Posted 29 October 2016 - 07:10 AM
Ok so I would first like to say I am a beginner at lua so I might make some mistakes here is the code:

else -- Create an account
reset(colors.black, 1, 1)
write("Choose a username : ")
newuser = read()
print("Verifying account...")
randsleep(2, 5)
for i = 1, noacc do
  if newuser == accounts[i] then
   error("Account already exists")
end
print("Making account with the username: "..newuser)
write("Now enter the PIN you want : ")
newpin = read()
for i = 1, noacc do -- Gos through list of pins of username to verify account
  if newpin == pins[i] then
   pinverify = true
  else i = i + 1 end
end
noacc = noacc + 1
accounts[noacc] = newuser
pins[noacc] = newpin
print(accounts[noacc])
end
end
Near the last bit it loops. It keeps saying:
Choose a username: /username/
Verifying account…
Making account with the username: /username/
Now enter the PIN you want: 1111
/username/
Now enter the PIN you want:

It keeps on looping any ideas??

EDIT : It only loops 5 times as noacc (meaning number of accounts) is 5 I agree that I misplaced an end it must be around here somewhere
Edited on 29 October 2016 - 09:48 PM
Bomb Bloke #2
Posted 29 October 2016 - 09:58 AM
Seems you've got an "end" in the wrong place, though that won't have it ask for just the PIN over and over. Fix your indentation, and if you still don't see the problem after that, post the full code to pastebin and provide a link back here.
WolfDood #3
Posted 29 October 2016 - 09:08 PM
Seems you've got an "end" in the wrong place, though that won't have it ask for just the PIN over and over. Fix your indentation, and if you still don't see the problem after that, post the full code to pastebin and provide a link back here.
Ok I will try fixing it :)/>