解説
定数: integer PRIM_MATERIAL = 2;
integerの定数PRIM_MATERIALは2の値をもちます。
プリム素材を設定します。素材は質量には作用しませんが、抵抗、弾み(弾力)そして衝突音に作用します。33°の木の傾斜で、例のスクリプトは以下の結果を下回って発生します。
傾斜を流下した最大速度と距離の表の詳細
| 型
| 速度 (m/s)
| 距離 (m)
|
| 石
| 0.453181
| 0.361655
|
| 鉄
| 5.475444
| 10.211180
|
| ガラス
| 6.483150
| 11.678304
|
| 木
| 2.154549
| 9.433724
|
| 皮
| 0.351543
| 0.188043
|
| プラスチック
| 4.502428
| 9.590952
|
| ゴム
| 0.374964
| 0.187106
|
例
// © 2008 by Karzita Zabaleta
// Author of Scripting Your World, Wiley, October 2008.
list gMaterialTypes = [
"STONE",
"METAL",
"GLASS",
"WOOD",
"FLESH",
"PLASTIC",
"RUBBER"
];
vector gHomePosition;
rotation gHomeRotation;
integer gWaitCount = 0;
float gMaxVelMag;
integer gPrimMaterial;
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;
}
// actually move the prim, now
llSetPrimitiveParams(params);
}
returnHome()
{
llSetStatus(STATUS_PHYSICS, FALSE);
moveTo(llGetPos(),gHomePosition);
llSetTimerEvent(0);
llSetRot(gHomeRotation);
}
calculate_velocity()
{
float velMag = llVecMag(llGetVel());
if (velMag > gMaxVelMag) {
gMaxVelMag = velMag;
}
}
default
{
state_entry() {
gHomePosition = llGetPos();
gHomeRotation = llGetRot();
}
on_rez(integer _n) {
llResetScript();
}
touch_start(integer n) {
gMaxVelMag = 0;
llSetPrimitiveParams([PRIM_MATERIAL, gPrimMaterial]);
llSetStatus(STATUS_PHYSICS,TRUE);
llSetTimerEvent(0.1);
llResetTime();
gWaitCount=0;
gPrimMaterial++;
if (gPrimMaterial == 7 ) gPrimMaterial = 0;
}
timer() {
calculate_velocity();
gWaitCount++;
if (gWaitCount > 100) { // 10 seconds
string type = llList2String( gMaterialTypes, gPrimMaterial-1 );
llOwnerSay(type+" reached maximum velocity of "+(string)gMaxVelMag+
" and traveled "+(string)llVecDist(llGetPos(), gHomePosition)+" meters.");
returnHome();
}
}
}