I recently found an old project that i was making a year ago, and since i have not wrote anything in a while, im a bit confused .
What i was trying to do is an algebric calculator that uses bhaskara to solve equations.
Here is what i was able to do.
function Results:init(x)
showKeyboard()
end
function Results:draw()
buffer = keyboardBuffer()
if buffer then
buffer = tbuffer{a,b,c}
d = math.pow(b,2)- 4 * a * c
x1 = (-b + math.sqrt(d))/2*a
x2 = (-b-math.sqrt(d))/2*a
fill(255)
fontSize(40)
font("AmericanTypewriter-Bold")
textWrapWidth(WIDTH)
text(a.."x^2+"..b.."x+" ..c.. " = 0", WIDTH/2,HEIGHT -100)
fill(255, 0, 0, 255)
text("Delta = "..b.."^2 - 4*"..a.."*"..c,WIDTH/2,HEIGHT -150)
text("Delta = "..b*b.." - "..4*a*c,WIDTH/2,HEIGHT -200)
text("Delta = "..d,WIDTH/2, HEIGHT-250)
fill(0, 21, 255, 255)
text("X1 = ",201,HEIGHT -315)
text(-b.."+".."?"..d,WIDTH/2,HEIGHT-300)
text("____________",WIDTH/2,HEIGHT-300)
text("2 * "..a,WIDTH/2,HEIGHT-340)
text("X1 = ",201,HEIGHT-405)
text(-b.."+"..math.sqrt(d),WIDTH/2,HEIGHT-390)
text("____________",WIDTH/2,HEIGHT-390)
text(2*a,WIDTH/2,HEIGHT-430)
text("X1 = "..x1,WIDTH/2,HEIGHT-480)
fill(255, 158, 0, 255)
text("X2 = ",201,HEIGHT -545)
text(-b.."-".."?"..d,WIDTH/2,HEIGHT-530)
text("____________",WIDTH/2,HEIGHT-530)
text("2 * "..a,WIDTH/2,HEIGHT-570)
text(-b.."-"..math.sqrt(d),WIDTH/2,HEIGHT-620)
text("____________",WIDTH/2,HEIGHT-620)
text(2*a,WIDTH/2,HEIGHT-660)
text("X2 = ",201,HEIGHT -635)
text("X2 = "..x2,WIDTH/2,HEIGHT-710)
end
end
What i inteded here is to input for example 1,-6,5 and it would return a=1,b=-6,c=5.
The program says tbuffer = nil, and i dont know how to get multiple values from the keyboard.
Sorry for the messy code, its my first one