Posted 20 November 2015 - 08:14 PM
I'm reading an input from the user and comparing it against a saved number, all of it works flawlessly for having quickly put it together. However, it seems that the input is dividing it self by 100 without any math being acted upon it. It always returns that the input is greater than the overall number if you do anything less than 100/total number. So, if the total was 500 and I inputted 99 it would say that it was wrong.
P.S: messy code cause it's wip.
P.S: messy code cause it's wip.
playername="user"
zero = "0"
if fs.exists(playername) then
local playeraccount = fs.open(playername, "r")
playerbalance = playeraccount.readLine(1)
playeraccount.close()
term.setCursorPos(1,2)
dbalance = textutils.serialize(playerbalance)
displayBalance = playerbalance
protoBalance = playerbalance
term.setCursorPos(2,7)
print(displayBalance)
term.setCursorPos(1,2)
local input = read()
math.ceil(input)
term.setTextColour(colours.white)
if input > protoBalance then
print("Too Much/Not A Number!")
print(input)
sleep(3)
shell.run("startup")
elseif (input>zero) and (input <= protoBalance) then
print("Withdrawing amount...")
protoBalance = protoBalance - input
local playeraccount = fs.open(playername, "w")
playeraccount.writeLine(tostring(protoBalance))
playeraccount.writeLine(protoBalance)
playeraccount.close()
print("Done.")
sleep(5)
os.reboot()
else
shell.run("startup")
term.setCursorPos(1,1)
shell.run("startup")
end
end