integer doorSteps = 4; integer reversed = FALSE; rotateDoor(integer Open) { rotation rot = llGetRot(); rotation delta; integer x; if (reversed) {Open = !Open;}; if (Open) { delta = llEuler2Rot(<0, 0, PI/(doorSteps * 2)>); } else { delta = llEuler2Rot(<0, 0, -PI/(doorSteps * 2)>); } for (x = 0; x < doorSteps; x++) { rot = delta * rot; llSetRot(rot); llSleep(0.03125/doorSteps); } } default { state_entry() { state closed; } } state closed { touch_start(integer total_number) { llTriggerSound("dooropen", 0.5); rotateDoor(TRUE); state open; } } state open { touch_start(integer num) { rotateDoor(FALSE); llTriggerSound("doorslam", 0.5); state closed; } }
Need to write a LSL script and don't know how to script? I know I hate trying to get my head around LSLS when I an in a time crunch. So why not give Flash Scratch a try! Its a great tool for learning and scoding your own scripts for Second Life without having to pay someone to do it and without a crash course in LSL
A Huge thanks to John Bennet of ATLAS Institute at University of Colorado and Eric Rosenbaum at MIT for writing Scratch for SL to begin with.