I'm trying to write a script for a friend to rotate a prim around another prim in the same object (which may or may not be an attachment; if it's an important distinction then assume it is attached). My math-fu is a bit limited, and I'm having problems getting my head around it all; would appreciate any help you're willing to give.
I know what I need to do, and I also sort of know how to do it; it just all falls over with the implementation.
1. I need to get the orbiter's current loc relative to the centre point (llGetLocalPos)
2. I need to get the orbiter's current rotation (llGetRot)
3. I need to get the centre point's rotation (llGetRootRotation)
4. I need to rotate the desired rotation (Z axis initially, but should apply to any really) about the centre point's rotation (I can't figure out how to to do this)
5. I need to rotate the relative location using the new rotation from point 4 (I can't figure out how to do this)
6. I need to set the new location (llSetPos)
7. Initially the object will be a sphere, so relative rotation is irrelevant, but it would be nice to be able to adjust the orbiter's rotation to continue to face the same way relative to the central object
I'm running into all the usual problems; object vanishing off into the blue, weird jumps all over the place, rotating in some weird, but presumably calculable way, etc.. (I've read the thread about the bug in the linked object position calculation, but I'm not sure that it applies, or that I understand either it or the fix anyway :/)
I can get it working find about a stationary object with ZERO_ROTATION, but as soon as you move it everything goes haywire

On a completely separate note, I'm getting quite frustrated by some other aspects of LSL: e.g. I set a sound and adjust a texture animation in one routine; seemingly randomly, LSL will decide to undo one of the changes (e.g. you animate to a new texture and set a sound; the sound plays, the texture animates to the new picture... then it decides that it really liked the old picture and switches back to that. Or it might decide that it really likes the sound it's playing, and it stops the sound on command only to restart it again).
I've started to use timer events to reapply the changes I requested after about 0.5 secs, but it's really unpleasant to me to have to do this; am I missing something obvious, have I made some silly mistake, or is this something I just have to put up with?
thanks in advance,
Core