Who Is Online

1
Online

Tuesday, 26 September 2017 05:41

Barn Door Script

Barn Door Script
===========
Follow these steps to install...

1. Rez the "Door Axis" prim, size, and position along the "hinge-side" of the door.
2. Link the Door to the "Door Axis" by holding down the SHIFT key, select the door, and then finally select the "Door Axis" (Order of selection is important, the axis must be selected last).  
3. Select LINK from the Tools menu to link the two prims together.
4. Drag the two sounds and the "Door Script" onto the door.
5. Touch the door to have it open and touch again to have it close.  If you need to reverse the direction, move the door back to it's original position (by editing or by touching), open the "Door Script", and modify the "reversed" variable.

 

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;
    }
}

 

Flash Scratch to SL - Your Scripting Tool

Script ImageNeed 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.

Read more: Flash Scratch to SL - Your Scripting Tool