CODE
state_entry() {
llRotTarget(llGetRot(), 1 * DEG_TO_RAD);
update(); // update the compass face
}
not_at_rot_target() {
update(); // update the compass face
llRotTarget(llGetRot(), 1 * DEG_TO_RAD);
}Whenever my current rotation varies by a degree or so, the compass is updated, and the rotational target is changed to match my current rotation.The above works great 99% of the time. That remaining one percent is annoying the heck out of me, though. When I sit on a prim, not_at_rot_target() fires continuously, even though I am at the rotational target. I've stuck debug stuff in the script to have it spit out my current and target rotations, so I'm pretty sure that part of the script is working correctly.
Here's where it gets even stranger. If I rez a box at zero rotation and sit on it facing east (my butt on face 0, my legs over face 2), the script behaves as it should. If I sit facing any other way on the box, not_at_rot_target() fires despite the target rotation and my current rotation matching. This behavior persists regardless of the prim's rotation, as well. So long as I sit on face 0 with my legs over any face but face 2, it acts weird.
And now for strangess part three: if I add an at_rot_target() handler, even an empty one, this odd behavior described above goes away.

I could just add an at_rot_target() handler, I suppose, but I wanted to reduce lag if possible, and not having events firing constantly just from sitting down seemed a good way to avoid that. Am I doing something wrong up above, or is this just some oddball behavior of LSL I have to work around or live with?