Difference between revisions of "LlGetEnergy/ja"
Jump to navigation
Jump to search
m (Undo revision 306262 by Shinnosuke Darkstone (Talk)) |
|||
(3 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{LSL_Function | {{LSL_Function | ||
|func_id=149|func_sleep=0.0|func_energy=10.0 | |func_id=149|func_sleep=0.0|func_energy=10.0 | ||
|func=llGetEnergy | |func=llGetEnergy | ||
|func_footnote | |func_footnote | ||
|func_desc | |func_desc=オブジェクトのエネルギー量を最大量を基準としたパーセンテージ表記で返します。 | ||
|spec | |spec | ||
|caveats | |caveats | ||
|constants | |constants | ||
|examples | |examples=<source lang="lsl2"> | ||
// このスクリプトではほとんどの物理オブジェクトのエネルギー使用を確認します。 | |||
// Last version: 07 October 2009 by Gianni Lupindo | |||
vector homePos; | |||
integer timerCount = 0; | |||
integer testCount = 0; | |||
string space = " "; | |||
// 10m 以上移動する | |||
moveTo(vector origin, vector destination) { | |||
float dist = llVecDist(origin, destination); | |||
integer passes = llCeil( llLog(dist/10.0) / llLog(2.0) ); | |||
integer i; | |||
list params = [PRIM_POSITION, destination]; | |||
for (i=0; i<passes; i++) { | |||
params = (params=[]) + params + params; | |||
} | |||
// ここで、実際にプリムを動かす | |||
llSetPrimitiveParams(params); | |||
} | |||
returnHome() | |||
{ | |||
llSetTimerEvent(0); | |||
llSetStatus(STATUS_PHYSICS, FALSE); | |||
llSleep(0.2); | |||
moveTo(llGetPos(),homePos); | |||
llSetRot(ZERO_ROTATION); | |||
} | |||
default | |||
{ | |||
state_entry() { | |||
homePos = llGetPos(); | |||
llOwnerSay("Mass is "+(string)llGetMass()); | |||
} | |||
on_rez(integer _n) { | |||
llResetScript(); | |||
} | |||
touch_start(integer n) { | |||
space = " "; | |||
do { | |||
llSleep(0.5); | |||
} while (llGetEnergy() < 0.998); | |||
llSetPos( llGetPos()+<0,0,5>); | |||
llSetStatus(STATUS_PHYSICS,TRUE); | |||
llSetTimerEvent(1.0); | |||
vector impulse = <0,0,5>*llGetMass(); | |||
if (testCount == 0) { | |||
llOwnerSay("ApplyImpulse (test 0)"); | |||
llApplyImpulse( impulse, TRUE ); | |||
} else if (testCount == 1) { | |||
llOwnerSay("ApplyRotImpulse (test 1)"); | |||
llApplyRotationalImpulse( impulse, TRUE); | |||
} else if (testCount == 2) { | |||
llOwnerSay("PushObject (test 2)"); | |||
llPushObject(llGetKey(), impulse, ZERO_VECTOR, TRUE); | |||
} else if (testCount == 3) { | |||
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); | |||
llOwnerSay("Force (test 3)"); | |||
llSetForce( impulse, TRUE ); | |||
} else if (testCount == 4) { | |||
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); | |||
llOwnerSay("Torque (test 4)"); | |||
llSetTorque( impulse, TRUE ); | |||
} else if (testCount == 5) { | |||
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); | |||
llOwnerSay("Force and Torque (test 5)"); | |||
llSetForceAndTorque( impulse, impulse, TRUE ); | |||
} else if (testCount == 6) { | |||
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE ); | |||
llOwnerSay("MoveToTarget (test 6)"); | |||
llMoveToTarget( impulse, 0.4 ); | |||
} else if (testCount == 7) { | |||
llStopMoveToTarget ( ); | |||
llOwnerSay("RotLookAt (test 7)"); | |||
llRotLookAt( llEuler2Rot(impulse*DEG_TO_RAD), 0.4, 0.4 ); | |||
} else if (testCount == 8) { | |||
llStopLookAt ( ); | |||
llOwnerSay("LookAt (test 8)"); | |||
llLookAt( impulse, 0.4, 0.4 ); | |||
} else if (testCount == 9) { | |||
llStopLookAt ( ); | |||
llOwnerSay("Hover Height (test 9)"); | |||
llSetHoverHeight( 5.0, TRUE, 0.5); | |||
} else if (testCount == 10) { | |||
llSetHoverHeight( 0, TRUE, 0.5); | |||
llOwnerSay("Ground Repel (test 10)"); | |||
llGroundRepel( 5, TRUE, 0.5); | |||
} else if (testCount == 11) { | |||
llGroundRepel( 0, TRUE, 0.5); | |||
llOwnerSay("Buoyancy (test 11)"); | |||
llSetBuoyancy( 0.997 ); | |||
} else { | |||
llSetBuoyancy( 0.0 ); | |||
llOwnerSay("Done"); | |||
} | |||
timerCount = 0; | |||
if (testCount != 12) { | |||
llOwnerSay((string)timerCount+". Energy: "+space+(string)llGetEnergy()); | |||
testCount++; | |||
} | |||
else { | |||
testCount = 0; | |||
returnHome(); | |||
} | |||
} | |||
timer() { | |||
timerCount++; | |||
if (timerCount >= 10) space = ""; | |||
llOwnerSay((string)timerCount+". Energy: "+space+(string)llGetEnergy()); | |||
if (timerCount>=10) { | |||
returnHome(); | |||
} | |||
} | |||
collision(integer n) { | |||
llOwnerSay("*. Energy: "+space+(string)llGetEnergy()+" (collision)"); | |||
} | |||
} | |||
</source> | |||
|helpers | |helpers | ||
|also_functions | |also_functions |
Latest revision as of 13:37, 25 February 2016
LSL ポータル | 関数 | イベント | 型 | 演算子 | 定数 | 実行制御 | スクリプトライブラリ | カテゴリ別スクリプトライブラリ | チュートリアル |
Summary
Function: llGetEnergy( );149 | Function ID |
0.0 | Forced Delay |
10.0 | Energy |
オブジェクトのエネルギー量を最大量を基準としたパーセンテージ表記で返します。
Caveats
Examples
// このスクリプトではほとんどの物理オブジェクトのエネルギー使用を確認します。
// Last version: 07 October 2009 by Gianni Lupindo
vector homePos;
integer timerCount = 0;
integer testCount = 0;
string space = " ";
// 10m 以上移動する
moveTo(vector origin, vector destination) {
float dist = llVecDist(origin, destination);
integer passes = llCeil( llLog(dist/10.0) / llLog(2.0) );
integer i;
list params = [PRIM_POSITION, destination];
for (i=0; i<passes; i++) {
params = (params=[]) + params + params;
}
// ここで、実際にプリムを動かす
llSetPrimitiveParams(params);
}
returnHome()
{
llSetTimerEvent(0);
llSetStatus(STATUS_PHYSICS, FALSE);
llSleep(0.2);
moveTo(llGetPos(),homePos);
llSetRot(ZERO_ROTATION);
}
default
{
state_entry() {
homePos = llGetPos();
llOwnerSay("Mass is "+(string)llGetMass());
}
on_rez(integer _n) {
llResetScript();
}
touch_start(integer n) {
space = " ";
do {
llSleep(0.5);
} while (llGetEnergy() < 0.998);
llSetPos( llGetPos()+<0,0,5>);
llSetStatus(STATUS_PHYSICS,TRUE);
llSetTimerEvent(1.0);
vector impulse = <0,0,5>*llGetMass();
if (testCount == 0) {
llOwnerSay("ApplyImpulse (test 0)");
llApplyImpulse( impulse, TRUE );
} else if (testCount == 1) {
llOwnerSay("ApplyRotImpulse (test 1)");
llApplyRotationalImpulse( impulse, TRUE);
} else if (testCount == 2) {
llOwnerSay("PushObject (test 2)");
llPushObject(llGetKey(), impulse, ZERO_VECTOR, TRUE);
} else if (testCount == 3) {
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE );
llOwnerSay("Force (test 3)");
llSetForce( impulse, TRUE );
} else if (testCount == 4) {
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE );
llOwnerSay("Torque (test 4)");
llSetTorque( impulse, TRUE );
} else if (testCount == 5) {
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE );
llOwnerSay("Force and Torque (test 5)");
llSetForceAndTorque( impulse, impulse, TRUE );
} else if (testCount == 6) {
llSetForceAndTorque( ZERO_VECTOR, ZERO_VECTOR, TRUE );
llOwnerSay("MoveToTarget (test 6)");
llMoveToTarget( impulse, 0.4 );
} else if (testCount == 7) {
llStopMoveToTarget ( );
llOwnerSay("RotLookAt (test 7)");
llRotLookAt( llEuler2Rot(impulse*DEG_TO_RAD), 0.4, 0.4 );
} else if (testCount == 8) {
llStopLookAt ( );
llOwnerSay("LookAt (test 8)");
llLookAt( impulse, 0.4, 0.4 );
} else if (testCount == 9) {
llStopLookAt ( );
llOwnerSay("Hover Height (test 9)");
llSetHoverHeight( 5.0, TRUE, 0.5);
} else if (testCount == 10) {
llSetHoverHeight( 0, TRUE, 0.5);
llOwnerSay("Ground Repel (test 10)");
llGroundRepel( 5, TRUE, 0.5);
} else if (testCount == 11) {
llGroundRepel( 0, TRUE, 0.5);
llOwnerSay("Buoyancy (test 11)");
llSetBuoyancy( 0.997 );
} else {
llSetBuoyancy( 0.0 );
llOwnerSay("Done");
}
timerCount = 0;
if (testCount != 12) {
llOwnerSay((string)timerCount+". Energy: "+space+(string)llGetEnergy());
testCount++;
}
else {
testCount = 0;
returnHome();
}
}
timer() {
timerCount++;
if (timerCount >= 10) space = "";
llOwnerSay((string)timerCount+". Energy: "+space+(string)llGetEnergy());
if (timerCount>=10) {
returnHome();
}
}
collision(integer n) {
llOwnerSay("*. Energy: "+space+(string)llGetEnergy()+" (collision)");
}
}