optimal viewing of a planetarium dome.
The following script will work some of the time to move the camera when the avatar sits,
but many times leaves the camera at the default.
Is this A: a bug, or B: What am I doing wrong?
Here is the script. Though echo-checks indicate a proper flow and execution of
the code, it still many times has no effect on the camera, or sets the camera to
the wrong position.
Many thanks -Jackson
CODE
// this code runs without errors, Flows properly, but half the time the avatar
// sits down camera does not set
key avid;
default
{
state_entry()
{
llSitTarget(<-.5,0,0>,<0,0,0,1>); // Sits avatar in upright position
// llSitTarget must be here for llAvatarOnSitTarget to return a key
llSay(0, "Entered Default State");
}//state_entry
touch_start(integer total_number)
{
llSay(0, "Sit here!");
}
changed(integer change)
{
llSay(0, "Changed");
if(change & CHANGED_LINK){ // makes sure that this is a changed link call
llSay(0, "Changed Link");
avid = llAvatarOnSitTarget(); // is an avatar sitting on the target?
llSay(0, "Check Key");
if(avid != NULL_KEY) {
llSay(0, "Requesting Permissions");
llRequestPermissions(avid, PERMISSION_CONTROL_CAMERA);
}
else {
llSay(0, "Null Key");
}
} // if changed Link
} //changed
run_time_permissions(integer p)
{
if(PERMISSION_TRIGGER_ANIMATION & p) {
llSay(0, "ANIMATION Permission Set");
llStartAnimation("nyanya");
}
if(PERMISSION_CONTROL_CAMERA & p) {
llSay(0, "Camera Permission Set");
llClearCameraParams();
llSetCameraParams([
CAMERA_ACTIVE, 1, // 1 is active, 0 is inactive
CAMERA_POSITION, <200.630,204.104,20.664> // region-relative position
]);
llSay(0, "Camera Set");
}// PERMISSION_CONTROL_CAMERA
}//runtime permissions
} // default