Posted 24 September 2012 - 09:28 PM
Ok, So I am writing an A.T.M machine for our server bank, I have been hitting problems on line 79, and 56. Any help is welcome,
PS, Who ever figures this out is a legend :P/>/>
PS, Who ever figures this out is a legend :P/>/>
--Global Vars
version="0.1 Alpha"
--STARTUP CODE FOR DIRECTORY
if(fs.exists("/bank/")) then
print("Bank Has Been Set Up Locally, version "..version.." Doesn't support wire-less storage")
else
fs.makeDir("/bank")
end
sleep(5)
--end
--MONEY DECLORATIONS
--local money="0"
--local account_money=money
--end
--MAIN LOOP
while(true) do
if money~="0" then
--account_money=money
--money="0"
end
term.clear()
term.setCursorPos(1,1)
print("Money Server "..version)
print("")
print("Please note, this is monitored 24/7")
write("Account name: ")
account=read()
if(account) then
if(fs.exists("bank/"..account)) then
local file1 = fs.open("bank/"..account,"r")
readln=file1.readLine()
if(readln=="") then
account_money1="0"
--account_money1=money
end
if(readln) then
account_money1=readln
else
print("No Data To Read!")
end
file1.close()
--print(account.." contains $"..account_money1)
write("Edit? ")
ans=read()
if(ans=="yes") then
if(readln) then
account_money1=readln
end
write("Amount to withdraw: ")
if(account_money-read()>0) then
money=account_money-read()
file1.close()
else
file1.close()
print("Can't withdraw, no money left in account")
sleep(3)
--money=0
end
local file = fs.open("bank/"..account,"w")
--file.clear("bank/"..account)
file.writeLine(money)
file.close()
end
if(ans=="debug") then
term.clear()
term.setCursorPos(1,1)
write("Account name: ")
debuguser=read()
if(debuguser) then
term.clear()
term.setCursorPos(1,1)
write("Amount to add: ")
debugamount=read()
money=account_money+debugamount
end
end
else
term.clear()
term.setCursorPos(1,1)
print("Account does not exist, please contact a member of staff!")
sleep(2)
term.clear()
end
end
end