Jump to content

Curtain Script mod - how to lock it to two axes instead of one


Miguelito Shilova
 Share

You are about to reply to a thread that has been inactive for 3686 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm using the curtain script found in the script library here as a basis for folding up a boat canopy.

The canopy is a mesh that has a ribbed quality to it, and when the script executes it folds up like an accordian.

The only issue is that when it folds, it folds to the center of the canopy. The script says with mesh you have to arrange to have the pivot point on one edge. I presume here it's the Y axis, given it's the axis that stays constant.

Here are the two states of the canopy ...

 canopy_closed_sm.jpg canopy_open_sm.jpg

What I'm looking for is to have it roll back to the stern edge of the canopy frame. In looking around at example functions, I suspect I could combine a llGetPosition function with llSetPosition and apply a vector to it within the same to cause it to shift back while it folds. Here's my modded script ...

 

// Define the large and small sizes of the prim here:-
// (if the prim is sliced or path cut, it will appear to be half size on the affected dimension)
vector  gScaleLarge = <5.0, 0.2, 5.4>;
vector  gScaleSmall = <0.5, 0.2, 5.4>;
 
integer gSteps  = 20;       // Number of steps in the shrink/expand process
float   gSwitch = 1.0;      // Action on first touch. +1.0 = shrink, -1.0 = expand

default
{
    state_entry()
    {
    llSetScale(gScaleLarge);
    
    }
 
    on_rez(integer x)
    {
    llResetScript();
    }
 
    touch_start(integer total_number)
    {
    vector ScaleStep = (gScaleLarge - gScaleSmall) / gSteps;  // Compute the scale augment per step
    vector wscale = llGetScale();
    gSwitch *= -1;       // Switch between stretch and contract
    integer i;
    for ( ; i < gSteps; ++i )
    {
        // It is more lag-friendly to incorporate a sleep per step
        // Rather than greatly increasing the number of steps
        llSleep(0.1);      
        llSetScale(wscale + ScaleStep * (float) i * gSwitch);
        llSetPos(llGetPos() + <0,5,0>); // here's where I'm calling for the shift
    }
    }
}

 The script compiles okay, but I don't see any shift - on any axes - despite what values I put into the vector. I only get a slight delay with the folding of the canopy (I suspect due to the built in 0.2 delay with llSetPos). I had supected some sort of detectable movement in one of the axes. Not sure what's missing.

I imagine this would be helpful for many builds. Not just boat canopies, but maybe even ones on buildings.

Thanks in advance!

Mig

 

Link to comment
Share on other sites

You might want to have a play with Zilla's Curtain Script, by Zilla Larsson.   Omei is right, of course, that cutting the prim to keep one edge stationary is generally preferable, but when you can't do that, it's good to know the original way:

//When touched the prim is retracted towards one end and when touched again stretched back out.////Prim moves/changes size along the local coordinate specified in the offset vector below.////To change the overall size, edit the prim when stretched out and reset the script when done. ////The script works both in unlinked and linked prims.//// Copyright © 2008 Zilla Larsson//    This program is free software: you can redistribute it and/or modify//    it under the terms of the GNU General Public License version 3, as //    published by the Free Software Foundation.////    This program is distributed in the hope that it will be useful,//    but WITHOUT ANY WARRANTY; without even the implied warranty of//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the//    GNU General Public License for more details.////   You should have received a copy of the GNU General Public License//    along with this program.  If not, see <http://www.gnu.org/licenses/>vector offset = <1,0,0>; //Prim moves/changes size along this local coordinatefloat hi_end_fixed = FALSE; //Which end of the prim should remain in place when size changes?                                      //The one with the higher (local) coordinate? float min = 0.15; //The minimum size of the prim relative to its maximum sizeinteger ns = 10; //Number of distinct steps for move/size changedefault {    state_entry() {        offset *= ((1.0 - min) / ns) * (offset * llGetScale());        hi_end_fixed -= 0.5;    }        touch_start(integer detected) {        integer i;        do  llSetPrimitiveParams([PRIM_SIZE, llGetScale() - offset,                PRIM_POSITION, llGetLocalPos() + ((hi_end_fixed * offset) * llGetLocalRot())]);        while ((++i) < ns);                   offset = - offset;    }}

 

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3686 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...