Posted 07 July 2015 - 03:54 AM
ok i will need some help from you guys, and its actually quite embarassing because a fewyears back i used to be the one helping people. But my memory of LUA has faded and please do not be like "Well the answers obvious!, blah blah blah" because i have tried many different commands and different syntax to make this work, it is not even close to finished as a project but im hoping it to be a credit card, you enter a pin, then you either add, subtract, or just check your money. i even tried making them go into their own programs using shell.run() i still have many intentions for this code once i can get this far. so anyways here is my testing code i am working on:
AB = 100
write("Enter PIN: ")
if read("*")==0741 then
textutils.slowPrint("Withdraw, Deposit, or just checking?")
if read() == "withdraw" then
function withdraw()
textutils.slowPrint("How much will you be taking out?")
d = read("$")
num = tonumber(d)
if num~=nil then
if num < AB then
AB = AB - num
textutils.slowPrint("New Balance: "..AB)
end
if num > AB then
textutils.slowPrint("Not enough money in your account…")
end
end
end
if num==nil then
textutils.slowPrint(d.." is not a number")
end
end
end
if read() == "deposit" then
function deposit()
textutils.slowPrint("How much money did you make?")
d = read("$")
num = tonumber(d)
if num~=nil then
AB = AB + num
textutils.slowPrint("New Balance: "..AB)
end
end
else
print("Wrong PIN")
end
AB = 100
write("Enter PIN: ")
if read("*")==0741 then
textutils.slowPrint("Withdraw, Deposit, or just checking?")
if read() == "withdraw" then
function withdraw()
textutils.slowPrint("How much will you be taking out?")
d = read("$")
num = tonumber(d)
if num~=nil then
if num < AB then
AB = AB - num
textutils.slowPrint("New Balance: "..AB)
end
if num > AB then
textutils.slowPrint("Not enough money in your account…")
end
end
end
if num==nil then
textutils.slowPrint(d.." is not a number")
end
end
end
if read() == "deposit" then
function deposit()
textutils.slowPrint("How much money did you make?")
d = read("$")
num = tonumber(d)
if num~=nil then
AB = AB + num
textutils.slowPrint("New Balance: "..AB)
end
end
else
print("Wrong PIN")
end