// If door is locked, the name of the avatar who locked it. // If door is not locked, the empty string (""). string gLockedBy = ""; // This number must match the channel number of the lock // and unlock objects you want to use. If multiple doors // have the same channel, then a single lock can lock all of // them at once. integer gLockChannel = 243; default { state_entry() { llSay(0, "Door 1.0"); llListen(gLockChannel, "", NULL_KEY, ""); state closed; } } state closed { listen(integer channel, string name, key id, string message) { if (channel == gLockChannel) { if (message == "") { gLockedBy = ""; //llTriggerSound("door unlock", 10.0); llSay(0, "unlocked"); } else { gLockedBy = message; //llTriggerSound("door lock", 10.0); llSay(0, "locked"); } } } touch_start(integer total_number) { string name = llDetectedName(0); if (name == gLockedBy || gLockedBy == "") { rotation rot = llGetRot(); rotation delta = llEuler2Rot(); rot = delta * rot; llSetRot(rot); llSleep(0.25); rot = delta * rot; llSetRot(rot); state open; } else { } } } state open { touch_start(integer num) { rotation rot = llGetRot(); rotation delta = llEuler2Rot(<-PI/16,0,0>); rot = delta * rot; llSetRot(rot); llSleep(0.25); rot = delta * rot; llSetRot(rot); state closed; } }