This error is rare: in all of Kitely, there are only a few scripts that cause it. So if you see this error on-screen then know that you are special

Here's an example of one script where this happens: a door-opening script that's used in Kitely Welcome Center, among other places. When you touch a door that contains this script, the door swings open (or closes, if it was already open). The problem is that the door animates the opening and closing by changing the prim's rotation by tiny increments, for the duration of 1 second. Every time the prim's rotation changes, the script is supposed to get an event. But because the script is busy in the animation loop it can't receive the event, so XEngine saves the event, intending to send it to the script later. Once over 1,000 events have been saved like this, you will start seeing the error "too many events".
I have fixed this particular script so that the error doesn't appear in Kitely Welcome Center anymore. The way that I've fixed it may be useful to other scripters who encounter this error, so here's how I did it: I limited how smooth the animation is. The script originally tried to generate as many rotation increments as possible over 1 second. This created over 100,000 rotation increments! This is extremely wasteful since no one has a computer that can render 100,000 frames per second. So I made the script generate exactly 100 rotation increments instead. Since the rotation takes place over 1 second, this means that the smoothness is 100 fps, which is still plenty!
This was the original animation code (it generates as many rotation increments as possible):
Code: Select all
llResetTime();
while (llGetTime() < SECONDS_TO_ROTATE) {
float time = llGetTime();
if (! gClosed)
/*
* Invert the timer for closing direction
*/
time = SECONDS_TO_ROTATE - time;
rotation rotationThisStep = llEuler2Rot(gRotationPerSecond * time) * gRotationClosed;
vector positionThisStep = hingePosition - HINGE_POSITION * rotationThisStep;
llSetLinkPrimitiveParamsFast(linkNumber, [PRIM_ROT_LOCAL, rotationThisStep, PRIM_POS_LOCAL, positionThisStep]);
}
Code: Select all
float ANIMATION_STEPS = 100;
llResetTime();
float lastUpdateTime = 0.0;
while (llGetTime() < SECONDS_TO_ROTATE) {
float time = llGetTime();
if (time - lastUpdateTime >= SECONDS_TO_ROTATE/ANIMATION_STEPS) {
lastUpdateTime = time;
if (! gClosed)
/*
* Invert the timer for closing direction
*/
time = SECONDS_TO_ROTATE - time;
rotation rotationThisStep = llEuler2Rot(gRotationPerSecond * time) * gRotationClosed;
vector positionThisStep = hingePosition - HINGE_POSITION * rotationThisStep;
llSetLinkPrimitiveParamsFast(linkNumber, [PRIM_ROT_LOCAL, rotationThisStep, PRIM_POS_LOCAL, positionThisStep]);
}
}