updated code, again...
cycleVTable <-{
"cnListPinch" : 0, "swListPinch" : 0, "wkListPinch" : 0,
"cnListRed" : 0, "swListRed" : 0, "wkListRed" : 0,
"cnListGreen" : 0, "swListGreen" : 0, "wkListGreen" : 0,
"cnListBlue" : 0, "swListBlue" : 0, "wkListBlue" : 0,
}
function cycleValue( ttime, counter, switcher, workValue, minV, maxV, BY, speed ) {
if (cycleVTable[counter] == 0)
cycleVTable[counter] = ttime;
////////////// 1000 = 1 second //////////////
if (ttime - cycleVTable[counter] > speed){
if (cycleVTable[switcher]==0){
cycleVTable[workValue] += BY;
if (cycleVTable[workValue] >= maxV)
cycleVTable[switcher] = 1;
}
else
if (cycleVTable[switcher]==1){
cycleVTable[workValue] -= BY;
if (cycleVTable[workValue] <= minV)
cycleVTable[switcher] = 0;
}
cycleVTable[counter] = 0;
}
return cycleVTable[workValue];
}
fe.add_ticks_callback( "textTickles" );
function textTickles( ttime ) {
//To get a negative, need to use a temporary var and - it.
local temp = cycleValue(ttime, "cnListPinch", "swListPinch", "wkListPinch", 10, 25, 1, 20);
romListSurf.pinch_x = -temp;
local RED = cycleValue(ttime,"cnListRed","swListRed","wkListRed",100,254,1,20);
local GREEN = cycleValue(ttime,"cnListGreen","swListGreen","wkListGreen",100,254,1.5,20);
local BLUE = cycleValue(ttime,"cnListBlue","swListBlue","wkListBlue",100,254,2,20);
romList.set_rgb(RED, GREEN, BLUE);
gameTitle.set_rgb(RED, GREEN, BLUE);
listPosition.set_rgb(RED, GREEN, BLUE);
}
And the comment to help explain it;
// This function should be pretty self explanatory;
// cycleValue( ttime, this is the tick time.
// counter, this keeps track of time passed since last call.
// switcher, this keeps track of wether to increment or decrement.
// workValue, this is the value that is passed to the function, worked on and returned.
// minV and maxV are the min/max to decrement or increment up to.
// BY, is the amount to increase or decrease workVakue by.
// speed is the length of time to wait to run again. 500 = half second.
////
// This function does require the table to work correctly.
I hope this comes in useful for all sorts of things for everyone...