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

ATM help

Started by sflynn, 04 April 2014 - 10:30 PM
sflynn #1
Posted 05 April 2014 - 12:30 AM
local password1=4449
term.clear()
sleep(0.1)
term.setCursorPos(1,1)
term.clear()
term.setTextColor(colors.green)
print("Hello")
print("Acount id")
sleep(1)
term.setTextColor(colors.white)
term.setCursorPos(1,3)
local inputid = read()  -- variables are stated infront of prevent "awkrad behavior"
if inputid == 1 then
  local input = read("*")
  print("pin: ")
  if input == password1 then
	print("correct pin!")
  else print("incorrect pin")
	sleep(1)
	os.reboot()
  end
end
Hey so I was trying to make a bank program I know what I am going to do for the actual currency and stuff but its a problem with the pin and account id that confuses me. Whenever I run the ATM style id and pin it just ask's me for my account id(1) so I type 1 and then it goes back to the termianal like the end of a program without asking me for my pin.
Edited on 04 April 2014 - 10:32 PM
Inumel #2
Posted 05 April 2014 - 12:48 AM
Read returns a string, you are comparing it to a number.. try

local inputid = tonumber(read())
also your pin check

  local input = tonumber(read("*"))
Edited on 04 April 2014 - 10:49 PM
sflynn #3
Posted 05 April 2014 - 02:09 AM
OK Thanks