Rez a box, place this script inside of it:
default
{
state_entry()
{
llSay(0, "Hello, Avatar!");
}
touch_start(integer total_number)
{
list env = llGetEnvironment(llGetPos(),[SKY_LIGHT,SKY_SUN,SKY_MOON]);
vector spDir = llGetSunDirection();
vector rpDir = llGetRegionSunDirection();
vector envDir = llList2Vector(env,0);
quaternion rot;
rot = llRotBetween(llRot2Up(ZERO_ROTATION),envDir);
//rot = llAxisAngle2Rot(<0,1,0>,90
DEG_TO_RAD)
llGetSunRotation();
llSetRot(rot);
llSay(0, "sunDir: " + (string)spDir + "\nenvDir: " + (string)envDir + "\nrpSunDir: " + (string)rpDir);
}
}
Click the box.
Observe that the prim will rotate towards the celestial body, however it does not point directly towards the body, with varying error levels.