// Mirror script
// by Aine Caoimhe (c. LACM) July 2015
// Provided under Creative Commons Attribution-Non-Commercial-ShareAlike 4.0 International license.
// Please be sure you read and adhere to the terms of this license: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
// When an avatar sits on an object containing this script the avi will be cloned to an NPC who will also sit
// Paired aniamtions supplied in the object will be played, making it appear as though the NPC is the mirrored user
// If the sitter touches the mirror it will advance to the next pose (if there are more to play)
// when the sitter stands, the NPC is removed
// (Note: if sitter changes appearance during use the NPC will not change to copy that change...it will continue to appear as intiailly rezzed)
//
// Place this script in the ROOT prim which can either be the mirror object itself or ain invisible prim placed at that location.
// It is assumed that the root prim's XZ-plane is the axis to be mirrored
//
// Add animations to the contents of the root prim in pairs where each pair consists of:
// - an animation for the sitter to play
// - an animation that mirrors this, that has the IDENTICAL NAME with " mirror" (including the leading space) added after it
// example: "sit 1" and "sit 1 mirror"
// DO NOT have a main sitter pose end with the word mirror because it would be interpretted as being a mirror pose and ignored
//
// ***** IF YOU ADD OR REMOVE ANIMATIONS YOU WILL NEED TO RESET THE SCRIPT TO PICK UP THE CHANGES!!! *****
//
// The sitter's pose position is determined by the base sitPos and sitRot settings (see user settings section below) UNLESS you
// overide these for an animation by placing new values in the DESCRIPTION field of the main pose in the format:
// <sitpose>::<sit rot> <--- note the double colon separator between position and rotation
// example: <0.0, 1.0, 0.0>::<0.0, 0.0, 0.0, 1.0>
// at which point the sitter will be moved to that sit target posision instead
//
// In all cases, the clone (mirror NPC) will be positioned exactly 180 rotated around the root prim's LOCAL Z axis
// If you have already rotated the mirror pose animation on axis when creating the mirror and do not need it subequently rotated
// when the clone NPC plays it, set the user variable mirrorRot to FALSE, otherwise leave it TRUE (this applies to all animations played
// so you can't use a mixture of both, sorry)
//
// USER SETTINGS
// use something like the Magic Sit Kit to set the value of these two
integer sayPoseName=TRUE; // TURE = owner will be told the name of the pose each time one is activated, FALSE = mirror will be silent
integer userName=FALSE; // TRUE = NPC will have the sitter's name, FALSE = NPC will have empty name
vector sitPos=<0.0, 1.0, 0.0>; // base sit target position to set for the main sitter relative to the mirror - NPC clone will mirror this position on the opposite side of the mirror
rotation sitRot=<0.0, 0.0, 0.0, 1.0>; // base sit target rotation to set for the main sitter relative to the mirror - NPC clone will mirror this on the opposite side of the mirror
integer mirrorRot=TRUE; // FALSE = the mirror animations you are supplying are already rotated on root; TRUE = they need to be rotated by the script
string baseAn="*****base__stand priority 1"; // name of a base priority 1 animation to use for underlying synch (no mirror pose of it is needed)
//
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// DO NOT CHANGE ANYTHING BELOW HERE UNLESS YOU KNOW WHAT YOU'RE DOING
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
list poses;
list mirrors;
integer anIndex;
key user;
key npc;
integer linkNpc;
integer linkUser;