Difference between revisions of "LlGetEnergy/fr"
Jump to navigation
Jump to search
Gally Young (talk | contribs) m (Localized to french) |
m (Resynched with English) |
||
Line 8: | Line 8: | ||
|caveats | |caveats | ||
|constants | |constants | ||
|examples | |examples= | ||
<lsl> | |||
// Ce script teste la consommation d'énergie de la plupart des fonctions physiques | |||
// 18 mars 2008, par Karzita Zabaleta | |||
vector posDepart; | |||
integer compteTimer = 0; | |||
integer compteTests = 0; | |||
// Déplacement sur plus de 10m | |||
moveTo(vector origine, vector destination) | |||
{ | |||
float dist = llVecDist(origine, destination); | |||
integer iterations = llCeil( llLog(dist/10.0) / llLog(2.0) ); | |||
integer i; | |||
list params = [ PRIM_POSITION, destination ]; | |||
for (i = 0; i < iterations; i++) | |||
params = (params=[]) + params + params; | |||
// Déplace la prim effectivement, à présent | |||
llSetPrimitiveParams(params); | |||
} | |||
reviensAuDepart() | |||
{ | |||
llSetStatus(STATUS_PHYSICS, FALSE); | |||
llSleep(0.2); | |||
moveTo(llGetPos(), posDepart); | |||
llSetTimerEvent(0); | |||
llSetRot(ZERO_ROTATION); | |||
} | |||
default | |||
{ | |||
state_entry() | |||
{ | |||
posDepart = llGetPos(); | |||
llOwnerSay("Masse égale à " + (string) llGetMass()); | |||
} | |||
on_rez(integer _n) | |||
{ | |||
llResetScript(); | |||
} | |||
touch_start(integer n) | |||
{ | |||
do llSleep(0.5); while (llGetEnergy() < 0.998); | |||
llSetPos( llGetPos() + 0,0,5>); | |||
llSetStatus(STATUS_PHYSICS, TRUE); | |||
llSetTimerEvent(1.0); | |||
vector impulsion = <0,0,5> * llGetMass(); | |||
if (compteTests == 0) | |||
{ | |||
llOwnerSay("ApplyImpulse"); | |||
llApplyImpulse( impulsion, TRUE ); | |||
} | |||
else if (compteTests == 1) | |||
{ | |||
llOwnerSay("ApplyRotImpulse"); | |||
llApplyRotationalImpulse( impulsion, TRUE); | |||
} | |||
else if (compteTests == 2) | |||
{ | |||
llOwnerSay("PushObject"); | |||
llPushObject(llGetKey(), impulsion, ZERO_VECTOR, TRUE); | |||
} | |||
else if (compteTests == 3) | |||
{ | |||
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); | |||
llOwnerSay("Force"); | |||
llSetForce( impulsion, TRUE ); | |||
} | |||
else if (compteTests == 4) | |||
{ | |||
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); | |||
llOwnerSay("Torque"); | |||
llSetTorque( impulsion, TRUE ); | |||
} | |||
else if (compteTests == 5) | |||
{ | |||
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); | |||
llOwnerSay("ForceAndTorque"); | |||
llSetForceAndTorque( impulsion, impulsion, TRUE ); | |||
} | |||
else if (compteTests == 6) | |||
{ | |||
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); | |||
llOwnerSay("MoveToTarget"); | |||
llMoveToTarget( impulsion, 0.4 ); | |||
} | |||
else if (compteTests == 7) | |||
{ | |||
llStopMoveToTarget ( ); | |||
llOwnerSay("RotLookAt"); | |||
llRotLookAt( llEuler2Rot(impulsion * DEG_TO_RAD), 0.4, 0.4 ); | |||
} | |||
else if (compteTests == 8) | |||
{ | |||
llStopLookAt ( ); | |||
llOwnerSay("LookAt"); | |||
llLookAt( impulsion, 0.4, 0.4 ); | |||
} | |||
else if (compteTests == 9) | |||
{ | |||
llStopLookAt ( ); | |||
llOwnerSay("HoverHeight"); | |||
llSetHoverHeight( 5.0, TRUE, 0.5); | |||
} | |||
else if (compteTests == 10) | |||
{ | |||
llSetHoverHeight( 0, TRUE, 0.5); | |||
llOwnerSay("GroundRepel"); | |||
llGroundRepel( 5, TRUE, 0.5); | |||
} | |||
else if (compteTests == 11) | |||
{ | |||
llGroundRepel( 0, TRUE, 0.5); | |||
llOwnerSay("Buoyancy"); | |||
llSetBuoyancy( 0.997 ); | |||
} | |||
else | |||
{ | |||
llSetBuoyancy( 0.0 ); | |||
llOwnerSay("Fini"); | |||
testCount=(-1); | |||
} | |||
llOwnerSay((string) compteTimer + ". energie :" + (string) llGetEnergy()); | |||
compteTimer = 0; | |||
compteTests++; | |||
} | |||
timer() | |||
{ | |||
llOwnerSay((string) compteTimer + ". energie :" + (string) llGetEnergy()); | |||
compteTimer++; | |||
if (compteTimer > 10) | |||
reviensDepart(); | |||
} | |||
collision(integer _n) | |||
{ | |||
llOwnerSay((string) compteTimer + ". energie :" + (string) llGetEnergy()); | |||
reviensDepart(); | |||
} | |||
} | |||
</lsl> | |||
|helpers | |helpers | ||
|also_functions | |also_functions |
Revision as of 07:46, 27 July 2008
LSL Portail Francophone | LSL Portail Anglophone | Fonctions | Évènements | Types | Operateurs | Constantes | Contrôle d'exécution | Bibliothèque | Tutoriels |
Description
Fonction: float llGetEnergy( );149 | N° de fonction |
0.0 | Delais |
10.0 | Energie |
Renvoie un float correspondant à la quantité d'énergie contenue actuellement par l'objet et exprimé en % du maximum.
Exemples
<lsl> // Ce script teste la consommation d'énergie de la plupart des fonctions physiques // 18 mars 2008, par Karzita Zabaleta
vector posDepart; integer compteTimer = 0; integer compteTests = 0;
// Déplacement sur plus de 10m moveTo(vector origine, vector destination) {
float dist = llVecDist(origine, destination); integer iterations = llCeil( llLog(dist/10.0) / llLog(2.0) ); integer i; list params = [ PRIM_POSITION, destination ];
for (i = 0; i < iterations; i++) params = (params=[]) + params + params;
// Déplace la prim effectivement, à présent llSetPrimitiveParams(params);
}
reviensAuDepart() {
llSetStatus(STATUS_PHYSICS, FALSE); llSleep(0.2); moveTo(llGetPos(), posDepart); llSetTimerEvent(0); llSetRot(ZERO_ROTATION);
}
default {
state_entry() { posDepart = llGetPos(); llOwnerSay("Masse égale à " + (string) llGetMass()); }
on_rez(integer _n) { llResetScript(); }
touch_start(integer n) { do llSleep(0.5); while (llGetEnergy() < 0.998); llSetPos( llGetPos() + 0,0,5>); llSetStatus(STATUS_PHYSICS, TRUE); llSetTimerEvent(1.0);
vector impulsion = <0,0,5> * llGetMass();
if (compteTests == 0) { llOwnerSay("ApplyImpulse"); llApplyImpulse( impulsion, TRUE ); } else if (compteTests == 1) { llOwnerSay("ApplyRotImpulse"); llApplyRotationalImpulse( impulsion, TRUE); } else if (compteTests == 2) { llOwnerSay("PushObject"); llPushObject(llGetKey(), impulsion, ZERO_VECTOR, TRUE); } else if (compteTests == 3) { llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); llOwnerSay("Force"); llSetForce( impulsion, TRUE ); } else if (compteTests == 4) { llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); llOwnerSay("Torque"); llSetTorque( impulsion, TRUE ); } else if (compteTests == 5) { llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); llOwnerSay("ForceAndTorque"); llSetForceAndTorque( impulsion, impulsion, TRUE ); } else if (compteTests == 6) { llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); llOwnerSay("MoveToTarget"); llMoveToTarget( impulsion, 0.4 ); } else if (compteTests == 7) { llStopMoveToTarget ( ); llOwnerSay("RotLookAt"); llRotLookAt( llEuler2Rot(impulsion * DEG_TO_RAD), 0.4, 0.4 ); } else if (compteTests == 8) { llStopLookAt ( ); llOwnerSay("LookAt"); llLookAt( impulsion, 0.4, 0.4 ); } else if (compteTests == 9) { llStopLookAt ( ); llOwnerSay("HoverHeight"); llSetHoverHeight( 5.0, TRUE, 0.5); } else if (compteTests == 10) { llSetHoverHeight( 0, TRUE, 0.5); llOwnerSay("GroundRepel"); llGroundRepel( 5, TRUE, 0.5); } else if (compteTests == 11) { llGroundRepel( 0, TRUE, 0.5); llOwnerSay("Buoyancy"); llSetBuoyancy( 0.997 ); } else { llSetBuoyancy( 0.0 ); llOwnerSay("Fini"); testCount=(-1); } llOwnerSay((string) compteTimer + ". energie :" + (string) llGetEnergy()); compteTimer = 0; compteTests++; }
timer() { llOwnerSay((string) compteTimer + ". energie :" + (string) llGetEnergy()); compteTimer++; if (compteTimer > 10) reviensDepart(); }
collision(integer _n) { llOwnerSay((string) compteTimer + ". energie :" + (string) llGetEnergy()); reviensDepart(); }
} </lsl>
Vous cherchez encore des informations ? Peut-être cette page du LSLwiki pourra vous renseigner.