ElapsedTime

@ Simeon

Did something change with ElapsedTime. Here is a small example. This program takes about 6 seconds to run, but all 3 values for ElapsedTime are the same and nowhere near 6 seconds. See example output that I included at the end.


function setup()

    et1=ElapsedTime  -- program start
    
    for x=1,100 do
       print(x)
    end
    
    et2=ElapsedTime  -- halfway thru
    
    for x=1,100 do
       print(x)
    end
    
    et3=ElapsedTime  -- program end
    
    print("\
\
ElapsedTime")
    print(et1)
    print(et2)
    print(et3)  
 
end

function draw()
    background(40, 40, 50)
end

--[[  

output showing the ElapsedTime I get

96
97
98
99
100


ElapsedTime
0.135546
0.135546
0.135546

--]]


.@Dave1707, this is because ElapsedTime is only updated after (or before) the draw loop, kind of like the CurrentTouch variable, I remember there was some talk about making it update sub-frame, but you would notice this would happen as it would become a function (think about that you cant interrupt a function to change a variable), and it would have a different name, as to keep compatibility with older code.
Jordan