OSSL Script Library/OSSL Poseball: Difference between revisions
From OpenSimulator
Jump to navigationJump to search
imported>Fritigern Created page with "A poseball script, using OSSL functions The code contains a lot of comments, explaining what does what, and why it is there. <source lang="lsl"> // OSSL Poseball // By Fritiger..." |
imported>Fritigern m Heh, forgot to set alpha on the poseball. :-))) |
||
| Line 42: | Line 42: | ||
user = llAvatarOnSitTarget(); | user = llAvatarOnSitTarget(); | ||
if(user == NULL_KEY) used = FALSE; // Make sure that there's really someone sitting on the poseball | 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!) | osAvatarStopAnimation(user, "sit"); // Stop the default sit animation (IMPORTANT!) | ||
osAvatarPlayAnimation(user, anim); // And start the animation that we want started. | osAvatarPlayAnimation(user, anim); // And start the animation that we want started. | ||
} else { | } else { | ||
used = FALSE; | used = FALSE; | ||
llSetAlpha(1.0,ALL_SIDES); // Make the poseball visible again when user stands up | |||
osAvatarStopAnimation(user, anim); //Stop the animation when the 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. | user = NULL_KEY; // Probably redundant, but we want to make sure that the value for ''user'' is empty. | ||
Revision as of 11:10, 18 March 2012
A poseball script, using OSSL functions
The code contains a lot of comments, explaining what does what, and why it is there.
// OSSL Poseball
// By Fritigern Gothly
// Written on March 18th, 2012
// Additional contributors:
// <add your name here if you made any improvements to this script>
vector target = <0.0, 0.0, 1.0>; // Change these values to position your avatar.
// =============================
// DO NOT CHANGE BELOW THIS LINE
// =============================
string anim; // Will be used for the animation name.
integer used; // Used as a flag to determine what the script should do.
key user; // This will hold the key of the user that uses the poseball
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....
llOwnerSay("Found animation ''"+anim+"''"); // Confirm that there is an animation in the inventory
}
}
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(1.0,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();
}
}
}