Home AMX User Forum AMX Technical Discussion

Can you fast forward a timeline?

Say you have a timeline with some long events and you want to make a button that skips the timeline to the next event and the timeline keeps going. I'm going to go try it out right now.


edit: ok here it is, mostly.
LONG TimingArray[] = {
10000,
10001,
10002,
10003
}

TIMELINE_CREATE(SHOW_TIMELINE,DayTimingArray,MAX_LENGTH_ARRAY(DayTimingArray),TIMELINE_RELATIVE,TIMELINE_REPEAT)


DEFINE_FUNCTION LONG get_absolute_time(LONG timeline_array[], INTEGER sequence)
{
    LOCAL_VAR INTEGER I;
    LOCAL_VAR LONG absolute_time
    absolute_time = 0;
    
    FOR(i=1;i<=sequence+1;i++)
    {
	absolute_time = absolute_time + timeline_array[i];
    }
    
    RETURN absolute_time;
}

TIMELINE_EVENT[SHOW_TIMELINE] 
{
    TIMELINE_SEQUENCE = TIMELINE.SEQUENCE
    SEND_STRING 0, "'TIMELINE.SEQUENCE', ITOA(TIMELINE_SEQUENCE)"
}





CHANNEL_EVENT[dvTest, 1]
{
    ON:
    {
    	LONG XYZZ
	XYZZ = get_absolute_time(DayTimingArray, TIMELINE_SEQUENCE);
	SEND_STRING 0, "'TIMELINE.SEQUENCE', ITOA(TIMELINE_SEQUENCE)"
	SEND_STRING 0, "'current timeline time: ',ITOA(TIMELINE_GET(SHOW_TIMELINE))"
	TIMELINE_SET(SHOW_TIMELINE, XYZZ )
	SEND_STRING 0, "'setting timeline to: ',  ITOA(XYZZ)"
	SEND_STRING 0, "'current timeline time: ',ITOA(TIMELINE_GET(SHOW_TIMELINE))"
    }
}

Comments

  • DHawthorneDHawthorne Posts: 4,584
    The TIMELINE_SET function will set your timeline to any value you like. I mostly use it to reset the timeline to zero, but there is no reason you can't pass it one of your time values from the timer array to jump right to that sequence event.
  • travistravis Posts: 180
    DHawthorne wrote: »
    The TIMELINE_SET function will set your timeline to any value you like. I mostly use it to reset the timeline to zero, but there is no reason you can't pass it one of your time values from the timer array to jump right to that sequence event.

    The only hassle is using a relative timeline because the timeline still counts absolute, hence the function to add all the times in the array up to the current sequence id/index.

    PS. isn't here already TIMELINE_RESET?
  • yuriyuri Posts: 861
    TIMELINE_KILL() and TIMELINE_CREATE() ? :)
  • to set the timeline to sequence 3 immediately:
    TIMELINE_SET(MyTimelineID,MyTimingArray[3]-5) // I give a 5ms prerun
    
    This should work to both on absolute and relative timeline. In the back, the timeline handler would take care to set the timer correct depending on the timeline type.
  • travistravis Posts: 180
    to set the timeline to sequence 3 immediately:
    TIMELINE_SET(MyTimelineID,MyTimingArray[3]-5) // I give a 5ms prerun
    
    This should work to both on absolute and relative timeline. In the back, the timeline handler would take care to set the timer correct depending on the timeline type.

    I think that's what I tried first. I hope I did and I didn't write all those loops for nothing.
Sign In or Register to comment.