rotation closerot = <0.00000, 0.00000, 0.00000, 1.00000>; //「Z軸に沿って90度回転を示すrotation」 rotation openrot = <0.00000, 0.00000 , 0.70711, 0.70711>; //式にするならllEuler2Rot(<0,0,PI_BY_TWO>) //またはllEuler2Rot(<0,0,90>*DEG_TO_RAD) rotation tempopenrot = <0.00000, 0.00000 , 0.70711, 0.70711>; integer nowmode = 0; initRot() //回転角度を更新する { rotation nowrot = llGetRot(); closerot = nowrot; openrot = nowrot * tempopenrot; } changeMode(key id) //開閉のオン/オフを切り替える { if (id == llGetOwner()) { if (nowmode == 0) { nowmode = 1; llOwnerSay("sensor:on"); //オーナーが調整した向きにパラメーターを更新する initRot(); } else { nowmode = 0; llSetRot(closerot); llOwnerSay("sensor:off"); } } } default { state_entry() { nowmode = 0; llSetStatus(STATUS_PHANTOM , FALSE); llSensorRemove(); initRot(); } touch_start(integer num) { changeMode(llDetectedKey(0)); if(nowmode==1) { state sensoron; } } on_rez(integer num) { llResetScript(); } } state sensoron { state_entry() { llSensorRepeat("", NULL_KEY, AGENT, 5, PI , 0.5); } sensor(integer totalnum) { llSetRot(openrot); llSetStatus(STATUS_PHANTOM , TRUE); } no_sensor() { llSetRot(closerot); llSetStatus(STATUS_PHANTOM , FALSE); } touch_start(integer num) { changeMode(llDetectedKey(0)); if(nowmode==0) { state default; } } }