Difference between revisions of "User:Daemonika Nightfire/Scripts/DS Single AO-Sit"

From Second Life Wiki
Jump to navigation Jump to search
Line 1: Line 1:
==*DS* Single AO-Sit==
==*DS* Single AO-Sit==
This Posescript treats your avatar as a Prim.
This Posescript treats your avatar as a Prim.
This is in the situation, the avatar position and rotation, to supervise in any direction when the avatar sits on it.
This posescript handle your Avatar like a prim and its possible to change the position and rotation in any direction while the avatar sit on it.
It is not necessary for an animation together with the script in the desired object basket.
It is not necessary to have an animation together with the script in the desired object
move through the capabilities of the avatar can also be used together with the own AO.
move through the capabilities of the avatar can also be used together with the own AO.
The set-sit position will be stored in the script and does not always reset.
The set-sit position will be stored in the script and does not always reset.
To save the standard seating position you must disable the llOwnerSay with you in the listener, The corresponding values can spend and on the "rotation saverot", "vector savepos" transferred.
To save the standard seating position you must disable the llOwnerSay with you in the listener, The corresponding values can spend and on the "rotation saverot", "vector savepos" transferred.
  Sorry for the bad english, its Google.(my english is not good enough)
  Thanks "Holger Gilruth" for your Help with the english translation.
Perhaps someone might make a correct translation
 
feel free.
==Important!==
==Important!==
The Posescript must in the Rootprim of the Object.
The Posescript must in the Rootprim of the Object.

Revision as of 11:22, 2 September 2010

*DS* Single AO-Sit

This Posescript treats your avatar as a Prim. This posescript handle your Avatar like a prim and its possible to change the position and rotation in any direction while the avatar sit on it. It is not necessary to have an animation together with the script in the desired object move through the capabilities of the avatar can also be used together with the own AO. The set-sit position will be stored in the script and does not always reset. To save the standard seating position you must disable the llOwnerSay with you in the listener, The corresponding values can spend and on the "rotation saverot", "vector savepos" transferred.

Thanks "Holger Gilruth" for your Help with the english translation.

Important!

The Posescript must in the Rootprim of the Object.

Script Time!

The Script is the Script Time around 0002-0005 ms. <lsl> /*/|/ 2010-09-01 15:25:38 lsl2 script

   ╔════════════════════════════════−−−­­­­­­→
   ║ *DS* Single AO-Sit by Daemonika Nightfire
   ╚═══════════════════−−−­­­→
   Dieses Posescript behandelt deinen Avatar wie einen Prim und ist dazu in der lage,
   die Avatarposition und Rotation in alle richtungen zu veraendern waerend der Avatar drauf sitzt.
   Es ist nicht zwingend notwendig eine Animation zusammen mit dem Script in das gewuenschte Object zu legen.
   Durch die verschiebe-moeglichkeit des Avatars kann es auch gemeinsam mit der eigenen AO genutzt werden.
   Die eingestellte Sit-Position wird im Script gespeichert und muss nicht jedesmal neu gesetzt werden.
   Zum speichern der Standart Sitzposition muss du dir mit den deaktivieren llOwnerSay im listener,
   die entsprechenen Werte ausgeben lassen und auf die "rotation saverot", "vector savepos" uebertragen.
   
   Wichtig!
   Das Posescript muss im Rootprim des Objects liegen.
   
   Script Time!
   Die Scriptzeit des Scripts liegt bei etwa 0.002 bis 0.005 ms.
   
  • /

key avatar; string anim; integer inventory = FALSE; integer sitting = FALSE;

vector msgpos = <0.0,0.0,0.43>; // setzt zugleich die Standart Position fuer den "llSitTarget". vector msgrot = <00,00,00>; // setzt zugleich die Standart Rotation fuer den "llSitTarget".

rotation saverot = ZERO_ROTATION; // muss evtl. an "vector msgrot" angeglichen werden. vector savepos = <0.00000, 0.00000, 0.84999>; // gleicht die diferenz zwischen "llSitTarget" und "llSetLinkPrimitiveParamsFast" aus.

integer llPos = FALSE; // Diese beiden Luemmel sind noetig, weil der listener es lieber mag Position & Rotation getrennt voneinander einzustellen. integer llRot = FALSE;

integer menu_handler; integer menu_channel; menu(key user,string title,list buttons) // diese Funktion ermoeglich x-beliebig viele Dialog-Varianten State-uebergreifend in einem script. {

   llListenRemove(menu_handler); // entfehrnt sofort den vorherigen Listener
   menu_channel = (integer)(llFrand(999999.0) * -1); // Dynamischer Channel von -999999.0 bis 999999.0
   menu_handler = llListen(menu_channel,"","",""); // startet einen neuen Listener mit neuem Channel
   llDialog(user,title,buttons,menu_channel);
   llSetTimerEvent(30); // setzt die Zeit in Secunden, wie lange der Listener aktiv ist

}

default {

   state_entry()
   {
       if(llGetInventoryNumber(INVENTORY_ANIMATION) > 0) // checkt das Objectinventar nach Animationen
       {
           anim = llGetInventoryName(INVENTORY_ANIMATION, 0);
           inventory = TRUE; // setzt einen Wahrheitsstatus wenn eine Animation gefunden wurde
       }
       llSitTarget(msgpos,llEuler2Rot(msgrot*DEG_TO_RAD));
       llOwnerSay((string)llGetFreeMemory() + " KiB free memory."); // reine Neugier, [07:04]  *DS* Single AO-Sit: 52314 KiB free memory.
   }
   touch_start(integer num_detected) 
   {
       if(llDetectedKey(0) == avatar && sitting) // durch diesen Status kann das Menue nur vom drauf sitzenden Avatar aufgerufen werden
       {
           menu(avatar,"\nSet your Position & Rotation.\nThe buttons x,y,z use Global orientation.\nThe other, from the perspective of the Avatar.",
           ["back","down","for","left","up","right","-x","-y","-z","+x","+y","+z"]);
       }
   }
   listen(integer channel,string name,key id,string msg) 
   {
       if(channel == menu_channel && sitting)
       {
           integer i;
           for(i = 0; i <= llGetNumberOfPrims(); i++)
           {
               if(llGetLinkName(i) == llKey2Name(avatar)) // findet im Linkset den Avatar als zusaetzlichen Prim
               {
                   list pos = llGetLinkPrimitiveParams(i,[PRIM_POSITION,PRIM_ROTATION]);
                   vector newpos = llList2Vector(pos, 0);
                   rotation newrot = llList2Rot(pos, 1);
                   
                   if(msg == "up")   {llPos = TRUE; msgpos = <0,0,0.05>;}
                   if(msg == "down") {llPos = TRUE; msgpos = <0,0,-0.05>;}
                   if(msg == "left") {llPos = TRUE; msgpos = <0,0.05,0>;}
                   if(msg == "right"){llPos = TRUE; msgpos = <0,-0.05,0>;}
                   if(msg == "for")  {llPos = TRUE; msgpos = <0.05,0,0>;}
                   if(msg == "back") {llPos = TRUE; msgpos = <-0.05,0,0>;}
                   
                   if(msg == "+z")   {llRot = TRUE; msgrot = <0,0,5>;}
                   if(msg == "-z")   {llRot = TRUE; msgrot = <0,0,-5>;}
                   if(msg == "+y")   {llRot = TRUE; msgrot = <0,5,0>;}
                   if(msg == "-y")   {llRot = TRUE; msgrot = <0,-5,0>;}
                   if(msg == "+x")   {llRot = TRUE; msgrot = <5,0,0>;}
                   if(msg == "-x")   {llRot = TRUE; msgrot = <-5,0,0>;}
                   
                   if(llRot)
                   {
                       newrot = (newrot / llEuler2Rot(msgrot * DEG_TO_RAD)) / (llGetRootRotation() * llGetLocalRot()); // sehr boese
                       saverot = newrot;
                       llRot = FALSE;
                       
                       // dieses "llOwnerSay" ist hilfreich beim einstellen der Globalen Werte, kann anschliessend deaktiviert werden
                       //llOwnerSay("Avatar Rotation " + (string)saverot);
                   }
                   if(llPos)
                   {
                       newpos = (newpos - llGetRootPosition()) / llGetRootRotation() + msgpos; // nicht ganz so boese
                       savepos = newpos;
                       llPos = FALSE;
                       
                       // dieses "llOwnerSay" ist hilfreich beim einstellen der Globalen Werte, kann anschliessend deaktiviert werden
                       //llOwnerSay("Avatar Position " + (string)savepos);
                   }
                   llSetLinkPrimitiveParamsFast(i,[PRIM_POSITION,savepos,PRIM_ROTATION,saverot]); // bewegt den zusaetzlichen Prim
               }
           }
           menu(id,"\nSet your Position & Rotation.\nThe buttons x,y,z use Global orientation.\nThe other, from the perspective of the Avatar.",
           ["back","down","for","left","up","right","-x","-y","-z","+x","+y","+z"]);
       }
   }
   changed(integer change)
   {
       if(change & CHANGED_LINK)
       {
           avatar = llAvatarOnSitTarget();
           if (llKey2Name(avatar) != "")
           {
               integer av;
               for(av = 0; av <= llGetNumberOfPrims(); av++)
               {
                   if(llGetLinkName(av) == llKey2Name(avatar)) // findet im Linkset den Avatar als zusaetzlichen Prim
                   {
                       llSetLinkPrimitiveParamsFast(av,[PRIM_POSITION,savepos,PRIM_ROTATION,saverot]); // bewegt den zusaetzlichen Prim
                       if(inventory) // Abfrage des Wahrheitsstatus nach forhandener Animation
                       {
                           llRequestPermissions(avatar, PERMISSION_TRIGGER_ANIMATION); // wird erst bei forhandener Animation ausgefuehrt 
                       }
                       llInstantMessage(avatar,"Touch me to adjust your sit-position.");
                   }
               }
               sitting = TRUE;
           }
           else
           {
               if((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && sitting && llKey2Name(avatar) != "")
               {
                   if(inventory) // Abfrage des Wahrheitsstatus nach forhandener Animation
                   {
                       llStopAnimation(anim); // wird erst bei forhandener Animation ausgefuehrt 
                   }
               }
               sitting = FALSE;
           }
       }
       if(change & CHANGED_OWNER + CHANGED_INVENTORY)
       {
           llResetScript();
       }
   }
   run_time_permissions(integer perm) // wird erst bei forhandener Animation ausgefuehrt 
   {
       if(perm & PERMISSION_TRIGGER_ANIMATION)
       {
           llStopAnimation("sit_generic");
           llStopAnimation("sit");
           llStartAnimation(anim);
       }
   }
   timer()
   {
       llSetTimerEvent(0);
       llListenRemove(menu_handler);
   }
   on_rez(integer start_param)
   {
       llResetScript();
   }

} </lsl>