ou automate...
Ce script amusera les grands enfants que nous sommes et étonnera les débutants.
Le principe est simple.
- Sur un clic enregistrement des positions et rotations de avatar ( Owner ).
- Quand les enregistrements sont effectués on déplace l'objet sur les même positions (et rotations).
- Clic pour refaire les déplacements.
Une vidéo montrant le principe
Le script à insérer dans un box classique.
// Glocal Variables //
list Pos_Rot;
integer Max;
float Rate = .2; // not so bad...
vector Origin_Pos;
integer Secure_Heap = 50000; // ** Warning ** dont be t < 1000 (protect heap collision)//
// Global Function //
Move()
{ // move across the land with the pos & rot recorded before
integer i;
vector pos;
rotation rot;
llSetText ( "Yeahhhhh!!!!!!!!!!",<0.0,1.0,0.0>,1 );
llSetStatus(STATUS_PHYSICS, TRUE); // set the object physical
for ( i = 0; i < llGetListLength(Pos_Rot); i = i +2 )
{ // move to pos and do the rotate
pos = (vector)llList2String(Pos_Rot,i);
rot = (rotation)llList2String(Pos_Rot,i+1);
llMoveToTarget(pos,0.5);
llRotLookAt( rot , 0.2, 2 );
llSleep (Rate); // same that the recording but can be different too
}
llSetStatus(STATUS_PHYSICS, FALSE); // remove the status physical
llSetRot( ZERO_ROTATION); // remove the last rotation
llSetPos ( Origin_Pos); // go the origin position
llSetText ( "It was funny!",<0.0,1.0,0.0>,1 );
}
Init(){ // Set the settings before all...
llSetRot( ZERO_ROTATION);
Origin_Pos = llGetPos(); // save the pos before moving
llSetText ( " Click on me ... and move across the land ",<0.0,1.0,0.0>,1 ); // show the recording
}
// end declarations //
// Main program //
default
{
on_rez(integer Param)
{
Init();
}
state_entry()
{
Init(); // for the startup after compiler
}
touch_start(integer total_number)
{
if (Max)
Move(); // // If already recorded then Move!!
else
llSensorRepeat( "", llGetOwner(), ( AGENT ), 96, PI, Rate); // if not start start recording
}
sensor(integer num_detected)
{
Pos_Rot += [llDetectedPos( 0), llDetectedRot( 0)]; // record pos & rot
integer nb_record = llGetListLength( Pos_Rot ); // get the number of records
if ( (integer) llGetFreeMemory() < Secure_Heap ) // set the minimum of memory possible (don't set below 1000!)
{
llSensorRemove(); // stop
Move(); // and move!!
}
else
llSetText ( (string) nb_record + " positions recorded ",<0.0,1.0,0.0>,1 ); // show the recording
}
}
La taille du script est limité en MONO à 64 Ko. L'enregistrement des positions et rotations n'est pas infini...
Pour protéger le script la mémoire restante du script au fur et à mesure des enregistrement est calculée par
llGetMemoryFree();
Si cette valeur < Secure_Heap on stoppe l'enregistrement.
J'ai mis 50000 ce qui est beaucoup mais simplement que je ne voulais pas attendre une éternité devant mon écran! 5000 = 220 records
Set Secure_Heap à la valeur qui vous convient mais pas < 1000 ( + 1500 records).
Rate est échantillonnage (1 / (mouvement / seconde)) ici .2 ( 5 images/seconde) vous pouvez allez plus vite ou moins vite.