NPC_Sensor_PoseBall_Annim
NPC_Sensor_PoseBall_Annim
integer _debug = FALSE; // print in chats what is happening.
float range = 3.0; // mètres
float interval = 1.0; // secondes
string anim;
integer used;
key user;
vector target = <0.0, 0.0, 1.0>;
integer StartStop = FALSE;
key npc_scene;
key npc_avatar;
key npc_avatarb;
Scenographie_ON()
{
if (StartStop == FALSE)
{
StartStop = TRUE;
// llSay(0,"Le spectacle commence !!!");
npc_scene = osNpcCreate("","", llGetPos() + <-2,2,12> , "NPC-Scene1");
npc_avatar = osNpcCreate("","", llGetPos() + <-2,2,12> ,"apparence1");
// npc_avatarb = osNpcCreate("","", llGetPos() + <-2,-2,2>,"apparence1");
osNpcSit( npc_avatar , llGetKey(), OS_NPC_SIT_NOW);
osAvatarPlayAnimation(npc_avatar,"anim1a");
// osAvatarPlayAnimation(npc_avatarb,"anim1a");
}
}
default
{
state_entry()
{
llSitTarget(target, ZERO_ROTATION);
anim = llGetInventoryName(INVENTORY_ANIMATION,0); // Get the first animation in the prim's inventory.
if(anim == "") // If no animation was found...
{
state error; // Go and wait until the inventory has changed.
} else { // Otherwise....
if (_debug ) llOwnerSay("Found animation ''"+anim+"''"); // Confirm that there is an animation in the inventory
}
llSensorRepeat("", "", AGENT, range, TWO_PI, interval); // active le scanner.
// recherché des avatars dans toutes les directions
}
sensor (integer numberDetected)
{
if (_debug )llOwnerSay( "Scene en cours, avatar present");
if (StartStop == FALSE)
{
Scenographie_ON();
}
}
no_sensor()
{
if (_debug )llOwnerSay( "avatar NON present");
osNpcRemove(npc_scene);
osNpcRemove(npc_avatar);
// osNpcRemove(npc_avatarb);
StartStop = FALSE;
}
changed(integer change)
{
if (change & CHANGED_LINK) // Triggered when someone sits on the4 poseball. When you sit, you really link to the ball.
{
if(!used)
{
used = TRUE;
user = llAvatarOnSitTarget();
if(user == NULL_KEY) used = FALSE; // Make sure that there's really someone sitting on the poseball
// llSetAlpha(0.0,ALL_SIDES); // Hide the poseball when sat upon
osAvatarStopAnimation(user, "sit"); // Stop the default sit animation (IMPORTANT!)
osAvatarPlayAnimation(user, anim); // And start the animation that we want started.
} else {
used = FALSE;
// llSetAlpha(0.5,ALL_SIDES); // Make the poseball visible again when user stands up
osAvatarStopAnimation(user, anim); //Stop the animation when the user stands up.
user = NULL_KEY; // Probably redundant, but we want to make sure that the value for ''user'' is empty.
}
}
if(change & CHANGED_INVENTORY)
{
llResetScript(); // Reset the script if the inventopry has changed.
}
}
}
state error
{
state_entry()
{
llOwnerSay("This poseball contains no animations. Please add one.");
}
changed(integer change)
{
if(change & CHANGED_INVENTORY)
{
llOwnerSay("Change detected. Initializing");
llResetScript();
}
}
}
mettre une notecard
mettre une notecard "apparence" contenant l'avatar et la scene (objet porter)