Original Author: Whidou Bienstock
Create Date: 08-01-2008
Category: Animation
Description:
Magic Sit System is the new easy way to configure sit targets on your chairs, beds, cars, rocks, walls, ...
No need for maths or calculation scripts. This is the free and lag-less alternative to the charmless pose balls.
Download Script Here:
Magic Sti Script
// This script is licensed under GPL license version 2 // // In short: feel free to redistribute and modify it, as long as // any copies of it can be redistributed and modified as well. // // The official text of the licence is available at // http://www.gnu.org/licences/gpl.html // // (c) The owner of Avatar Whidou Bienstock, 2008 integer CHANNEL = 48; // Channel of communication with the object string NAME = "Magic Sit Cube - 1.2"; // Name of the Magic Sit Cube integer listen_num; // Start the first animation stored in the object, if any startAnimation() { if (llGetInventoryNumber(INVENTORY_ANIMATION)) // If there is at least one animation in the inventory { integer perm = llGetPermissions(); if (perm & PERMISSION_TRIGGER_ANIMATION) // and if we can animate the avatar { string name = llGetInventoryName(INVENTORY_ANIMATION, 0); llStopAnimation("sit"); // stop the default animation llStartAnimation(name); // and start the new one } else // else ask the permission llRequestPermissions(llGetOwner(), PERMISSION_TRIGGER_ANIMATION); } } // Stop the first animation stored in the object, if any stopAnimation() { if (llGetInventoryNumber(INVENTORY_ANIMATION)) // If there is at least one animation in the inventory { integer perm = llGetPermissions(); if (perm & PERMISSION_TRIGGER_ANIMATION) // and if we can animate the avatar { string name = llGetInventoryName(INVENTORY_ANIMATION, 0); llStopAnimation(name); // stop the animation } } } // Set the sit target sitPose(string message) { list msg = llParseString2List(message, [ "|" ], []); // Split the data vector avPos = (vector) llList2String(msg, 0); // Avatar's position rotation avRot = (rotation) llList2String(msg, 1); // Avatar's rotation rotation rot = avRot / llGetRot(); // Difference between the 2 rotations vector pos = // Sit target offset (avPos - llGetPos()) / llGetRot() - <0, 0, 0.4>; llSitTarget(pos, rot); // Sitpose the objet (the purpose of the whole thing) llOwnerSay("Object sitposed. I used the following instruction: llSitTarget(" + (string) pos + ", " + (string) rot + ");"); llSetClickAction(CLICK_ACTION_SIT); // Make it easy to sit for new residents llOwnerSay("Sit target set. Your object is ready."); // Warn the owner } default { state_entry() { listen_num = llListen(CHANNEL, NAME, NULL_KEY, ""); // Listen to the cube llOwnerSay("Magic Sit Script ready"); // Inform the owner } listen(integer channel, string name, key id, string message) { if (llGetOwnerKey(id) == llGetOwner()) // Check that the cube has the same owner as the object { if (message == "*") // If the owner sits on the cube { startAnimation(); // then possibly animate his/her avatar } else // else if the owner unsits from the cube { llListenRemove(listen_num); // then remove the listen sitPose(message); // calculate the sit target stopAnimation(); // possibly stop the animation llRemoveInventory(llGetScriptName()); // and destroy this script } } } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) // If the permission is granted { string name = llGetInventoryName(INVENTORY_ANIMATION, 0); llStopAnimation("sit"); // stop the default animation llStartAnimation(name); // and start the new one } } }
Magic Anim Acript
// This script is licensed under GPL license version 2 // // In short: feel free to redistribute and modify it, as long as // any copies of it can be redistributed and modified as well. // // The official text of the licence is available at // http://www.gnu.org/licences/gpl.html // // (c) The owner of Avatar Whidou Bienstock, 2008 startAnimation() { string name = llGetInventoryName(INVENTORY_ANIMATION, 0); llStopAnimation("sit"); // Stop the default animation llStartAnimation(name); // and start the new one } stopAnimation() { string name = llGetInventoryName(INVENTORY_ANIMATION, 0); llStopAnimation(name); // Stop the animation } default { changed(integer change) { if (change & CHANGED_LINK) { if (llGetInventoryNumber(INVENTORY_ANIMATION)) // If there is at least one animation in the inventory { key who = llAvatarOnSitTarget(); integer perm = llGetPermissions(); if (who) // If someone sits down, animate the avatar { if ( (perm & PERMISSION_TRIGGER_ANIMATION) && (who == llGetPermissionsKey()) ) startAnimation(); else llRequestPermissions(who, PERMISSION_TRIGGER_ANIMATION); } else // If the person stands up and was playing the animation, stop the animation { if (perm & PERMISSION_TRIGGER_ANIMATION) stopAnimation(); } } } } run_time_permissions(integer perm) { if (perm & PERMISSION_TRIGGER_ANIMATION) // If the permission is granted, start the animation startAnimation(); } }
Have Questions? Need help? Leave a note for Kitsune Lassiter in Second Life
Additional Notes & Instructions(If any):
###############################################################
# #
# Magic Sit System v1.1 #
# #
# Open Source Sit Target Editor #
# GPL v2.0 License #
# Keep it full perms #
# #
###############################################################
I. Presentation
Magic Sit System is the new easy way to configure sit targets on your chairs, beds, cars, rocks, walls, ...
No need for maths or calculation scripts. This is the free and lag-less alternative to the charmless pose balls.
II. Why you should not use pose balls
If you just want to allow residents to sit on your object, each new pose ball adds an
unnecessary script to the simulator and therefore generates lag.
Each pose ball adds a new prim to your object, diminishing your allowed
prims count and generating lag.
Poseballs are not natural to use, they are a convention.
Poseballs are not aesthetical.
III. How to use the Magic Kit
1) Put the script named "Magic Sit Script" into the object you want to configure
2) Rez the "Magic Sit Cube"
3) Sit on the cube (left click is enough)
4) Right-click on the cube and select "Edit" in the pizza menu that appears
5) Move and rotate the cube until your avatar is in the desired position
6) Un-sit
To test the result, just sit on your object (left click should be enough).
At the end, the script named "Magic Sit Script" is automatically removed
from your object. You can remove the cube as well, or use it to set the
sit target of another object.
IV. Support for multiple sit targets
If you want several sit positions on your object (bank, couch...), repeat the above
sequence for the same number of prims in the object, using the "Edit linked parts"
checkbox.
V. Support for custom animations
Just drop your animation into the object before you start the above sequence.
When you have finished setting the sit target, you can leave the animation
in the object and add a script to play that animation when someone sits on your
object, for example, the "Magic Anim Script" included in this kit.
There's no support for multiple animations at this time.
VI. Legal Mentions
This sit posing kit is licensed under GPL license version 2
In short: feel free to redistribute and modify it, as long as any copies of it
can be redistributed and modified as well.
The official text of the license is available at
http://www.gnu.org/licences/gpl.html
(c) The owner of Avatar Whidou Bienstock, 2008