I came up with this, I've been trying to refine some parts of my layout, and wanted my increment over time code, to be in a single function that could be used for any purpose, rather than copy/paste style.
switchVals <-{
"swTEST" : 0,
"tTEST" : 0,
"rTEST" : 0
}
function increment( ttime, counter, switcher, returnVal ) {
if (switchVals[counter] == 0)
switchVals[counter] = ttime;
print("counter = "+switchVals[counter]+"\n");
////////////// 1000 = 1 second //////////////
if (ttime - switchVals[counter] > 100){
print("In to switch block\n");
if (switchVals[switcher]==0){
switchVals[returnVal] += 1;
if (switchVals[returnVal] >= 25){
switchVals[switcher] = 1;
}
}
else
if (switchVals[switcher]==1){
switchVals[returnVal] -= 1;
if (switchVals[returnVal] <= 10)
switchVals[switcher] = 0;
}
switchVals[counter] = 0;
}
return switchVals[returnVal];
}
fe.add_ticks_callback( "textTickles" );
function textTickles( ttime ) {
switchVals["rTEST"] = increment(ttime,"tTEST","swTEST","rTEST");
print(switchVals["rTEST"]+"\n");
}
I'll probably refine it a bit more after work.