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

ATM Math

Started by crazylady77, 06 August 2012 - 10:43 AM
crazylady77 #1
Posted 06 August 2012 - 12:43 PM
I need somebody to help me buy filling in the small part they I dont understand. I need it to subtract 1 from the bal file unless the bal file is = 0 then is says "No enough Funding"





if fs.exsits('/disk/bal') then
local money = tonumber (read())
for dontmesswith=1, money do
fs.open('/disk/bal', 'w')
(Need something to subtract 1 from the bal file)
KaoS #2
Posted 06 August 2012 - 02:15 PM
why the loop, why not just subtract the 'money' variable from it?
Noodle #3
Posted 06 August 2012 - 02:52 PM
Why the loop?
tFile = fs.open("/disk/bal", "r")
current = tFile.read()
tFile.close()
hFile = fs.open("/disk/bal", "w")
hFile.write(tonumber(current) - tonumber(read()))
hFile.close()