Closed HowardBaxton closed 5 years ago
Well, I don't think so. The times stored in the list are not the times you use in the command (in your example T1=20s) but the times the timer should trigger (llGetTime() + T1)
Example:
Just after a script reset you add the timer T1=20s:
llGetTime()=0; T1=20s;
time stored in list = llGetTime() + T1 = 0+20 = 20;
19s later you add T2=25:
llGetTime()=19; T2=25s;
time stored in list = llGetTime() + T2 = 19+25 = 44;
After adding a new timer the list get sorted and the checkTimer() function is called. In the checkTimer() function it gets the first list entry (20) and the current script time is substracted (20-19=1). Then the timer event is set 1.
To test it you could add a little script like this (I can't test it because I'm currently not online):
//adds 10 timers: T0=10s; T1=11s; T2=12s ....
//the time between the TIMER_ADD commands is 5s
default {
state_entry() {
integer i;
for(i=0; i<10; i++) {
llMessageLinked(LINK_SET, -600, "T" + (string)i + "|" + (string)(i+10) + "|LINKMSG|5000|This is a test", NULL_KEY);
llSleep(5.0);
}
}
}
Thank you once again. I was overlooking that one simple detail which is adding timer time to llGetTime when the value is added to the list. The sort is being done on when the timer should time out, not what's entered in the notecard. Very efficient routine!
On Fri, Jan 4, 2019 at 2:48 AM LeonaMorro notifications@github.com wrote:
Well, I don't think so. The times stored in the list are not the times you use in the command (in your example T1=20s) but the times the timer should trigger (llGetTime() + T1)
Example: Just after a script reset you add the timer T1=20s: llGetTime()=0; T1=20s; time stored in list = llGetTime() + T1 = 0+20 = 20;
19s later you add T2=25: llGetTime()=19; T2=25s; time stored in list = llGetTime() + T2 = 19+25 = 44;
After adding a new timer the list get sorted and the checkTimer() function is called. In the checkTimer() function it gets the first list entry (20) and the current script time is substracted (20-19=1). Then the timer event is set 1.
To test it you could add a little script like this (I can't test it because I'm currently not online):
//adds 10 timers: T0=10s; T1=11s; T2=12s .... //the time between the TIMER_ADD commands is 5s default { state_entry() { integer i; for(i=0; i<10; i++) { llMessageLinked(LINK_SET, -600, "T" + (string)i + "|" + (string)(i+10) + "|LINKMSG|5000|This is a test", NULL_KEY); llSleep(5.0); } } }
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nPoseTeam/nPose-SAT-NOTSAT-Plugin/issues/3#issuecomment-451398772, or mute the thread https://github.com/notifications/unsubscribe-auth/ADcmopyYM9hTGK3Gjw6VqbYaM55-r7r-ks5u_yNxgaJpZM4ZpBC4 .
I was looking at this timer for a possible use in a different situation. If I understand correctly how this timer is working, there is a possibility of extending the first timer out to almost double what it is supposed to run.
T1 is added with a time of 20 seconds. 19 seconds later T2 is added for 25 seconds. The list gets sorted and timer T1 is first in the list with a 20 second time. T1 runs for a total of 39 seconds.
The add timer function does not update and compensate for elapsed time is what I am thinking.