I am trying to perform calculations for each year, when a user enters a specific number of years. The do while loop info I’ve found for Lua doesn’t mention anything abut incrementing variable names as well. Can someone please look this over and let me know if it is possible, and if so what am I doing wrong? Thanks!
Sean
[code]
i = 1
ii = 1
fsti3 = 5
while i < fsti3 do
if ( i == 1 ) then
fstiYr[i]Rtn = fsti1 + fstiYrConWI
else
fstiYr[i]Rtn = fsti1 + fstiYrConWI + fstiYr[i - 1]Rtn
end
fstiYr[i]LsExp = fstiYr[i]Rtn - 300
while ii < fsti3 do
local fstiYr[i]_h = display.newText( "Year " … [i], 0, 0, native.systemFont, 16 )
local fstiYr[i]RtnTxt = display.newText( “Return: $” … fstiYr[i]Rtn, 0, 0, native.systemFont, 14 )
local fstiYr[i]LsExpTxt = display.newText( “Less Expenses: $” … fstiYr[i]LsExp, 0, 0, native.systemFont, 14 )
if ( i == 1 ) then
fstiYr[i]_h.x = _w / 2; fstiYr[i]_h.y = backBtn.y + 35
else
fstiYr[i]_h.x = _w / 2; fstiYr[i]_h.y = fstiYr[i-1]RtnTxt.y + 25
end
fstiYr[i]RtnTxt.x = _w / 3; fstiYr[i]RtnTxt.y = fstiYr[i]_h.y + 25
fstiYr[i]LsExpTxt.x = _w / 1.5; fstiYr[i]LsExpTxt.y = fstiYr[i]RtnTxt.y + 25
ii = ii + 1
end
i = i + 1
end
[/code] [import]uid: 157382 topic_id: 30435 reply_id: 330435[/import]