Change font size
It is currently Sat Dec 15, 2018 2:21 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 2   [ 11 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: Slow iris door script wanted.
PostPosted: Mon Jun 13, 2011 11:31 am 
Furious Typer

Joined: Tue Oct 28, 2008 4:53 pm
Posts: 166
I've looked everywhere and I can't find one, and even tried modding the iris script that I have, but failed.

Has anyone got a slow opening/closing iris door script?


Top
 Profile  
 
 Post subject: Re: Slow iris door script wanted.
PostPosted: Mon Jun 13, 2011 4:50 pm 
Furious Typer

Joined: Tue Mar 15, 2011 7:04 pm
Posts: 89
You might try posting the script you have and letting people look at it ..Maybe they can see something that can be modified to help you.


Top
 Profile  
 
 Post subject: Re: Slow iris door script wanted.
PostPosted: Tue Jun 14, 2011 2:26 am 
Furious Typer

Joined: Tue Oct 28, 2008 4:53 pm
Posts: 166
This is the script I've trying to mod to create a slow opening/closing iris door by either touch or collision and with settable, auto close and adjustable speed:-
{L_CODE}:
integer g_OpenNow;                 // True (1) if iris is 'open' now

default
{
    on_rez(integer param)
    {
        llResetScript();
    }
   
    state_entry()
    {
        if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
        {
            state WaitToClose;
        }
        else // Prim is in a closed (or undefined state), so calculate new 'open' size
        {
            g_OpenNow = FALSE;
            state WaitToOpen;
        }
    }
}
     
state WaitToClose // Iris is Open, and waiting to close
{
    touch_start(integer total_number)
    {
         llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.5, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
        g_OpenNow = FALSE;
        state WaitToOpen;
    }
}

state WaitToOpen // Iris is closed, and waiting to open
{
    touch_start(integer total_number)
    {
         llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, 0.05, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
        g_OpenNow = TRUE;
        state WaitToClose;
    }
}

It may have to be completely re-written because of it using states.
I tried using a for loop but I couldn't figure out the math to use in the loop, it's simple using VBasic, EG to open iris:-
{L_CODE}:
for a=0.5 to 0.06 step -0.01
for dl = 1 to 10000
<code goes here>
next dl, a

But not so simple in LSL.


Top
 Profile  
 
 Post subject: Re: Slow iris door script wanted.
PostPosted: Tue Jun 14, 2011 5:39 am 
OSG Elite
User avatar

Joined: Sat Jun 14, 2008 12:28 am
Posts: 384
Location: Australia
Hi Marlon,

this is my version of "slowing down" the actions of your script.
The bones of it is taking the hole parameter of the torus and replacing it with a variable float "hole" and graduating the value of hole slowly thru the use of a "While" loop.
This code seems to behave the same without the llSleep because of the lag time involved, it wont move any faster (in my simulator) but it can be slowed down by increasing the llSleep time. To change the speed, play with the llSleep value and the value of 0.05 in these parts [hole=hole-0.05;] and [hole=hole+0.05;]
{L_CODE}:
integer g_OpenNow;                 // True (1) if iris is 'open' now
float hole;
default
{
    on_rez(integer param)
    {
        llResetScript();
    }
   
    state_entry()
    {
        if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
        {
            hole = 0.05;// fix iris open
            state WaitToClose;
        }
        else // Prim is in a closed (or undefined state), so calculate new 'open' size
        {
            hole=0.5;// fix iris closed
            g_OpenNow = FALSE;
            state WaitToOpen;
        }
    }
}
     
state WaitToClose // Iris is Open, and waiting to close
{
    touch_start(integer total_number)
    {
        while (hole<0.55)
        {
         llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, hole, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
        hole=hole+0.05;
        llSleep( 0.01);
        }
        g_OpenNow = FALSE;
        state WaitToOpen;
    }
}

state WaitToOpen // Iris is closed, and waiting to open
{
    touch_start(integer total_number)
    {
       
        while (hole>0.05)
        {
         llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TORUS, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, hole, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
        hole=hole-0.05;
        llSleep( 0.01);
        }
        g_OpenNow = TRUE;
        state WaitToClose;
    }
}


what you were trying to do in VB looks like this in LSL
{L_CODE}:
float a = 0.5;
while (a > 0.05)// keep doing whats inside {} until "a" reaches 0.05
{
<do stuff with "a" here;>
a = a - 0.05; //increment "a" with each itteration
llSleep(0.1);//script sleeps for 0.1 second
}// now retest the "while" condition to see if its been met, if so move on, if not loop again

This may not be the best or most efficient way of doing this but it is the way I would do it, no warranty or responsibility accepted if it causes your iris to tear away from the fabric of your universe and take on a life of its own and eat up all your cookies.
mmmmcookies.


Top
 Profile  
 
 Post subject: Re: Slow iris door script wanted.
PostPosted: Tue Jun 14, 2011 7:40 am 
Furious Typer

Joined: Tue Oct 28, 2008 4:53 pm
Posts: 166
Thanks Cam, for the mod.

After analyzing LSL 'for loops', and playing a bit with the script, I managed to get a medium to slow opening/closing iris, the problem now is, I know the script can be shortened by eliminating 1 of the states, and combining the open/close lines in 2 events, a touch and a collision, using a boolean bit as a switch,,,, IE, if (!IrisOpen) OpenIris; or, if (IrisOpen) CloseIris; and using user functions for open and closing of the iris, being called by the if condition.

So far I have this script using for loops, but still uses 2 states and 2 touch events.
{L_CODE}:
integer g_OpenNow;                 // True (1) if iris is 'open' now

default
{
    on_rez(integer param)
    {
        llResetScript();
    }
   
    state_entry()
    {
        if (g_OpenNow == TRUE) // Prim is in open state, so calculate new 'closed' size
        {
            state WaitToClose;
        }
        else // Prim is in a closed (or undefined state), so calculate new 'open' size
        {
            g_OpenNow = FALSE;
            state WaitToOpen;
        }
    }
}
     
state WaitToClose // Iris is Open, and waiting to close
{
    touch_start(integer total_number)
    {
        float IrisClose = 0.05;
        integer a;
        for (a=0; a < 6; a++)
        {
         llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TUBE, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, IrisClose, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
          IrisClose = IrisClose + 0.10;
        }
        g_OpenNow = FALSE;
        state WaitToOpen;
    }
}

state WaitToOpen // Iris is closed, and waiting to open
{
    touch_start(integer total_number)
    {
        float IrisOpen = 0.5;
        integer a;
        for (a=0; a < 6; a++)
        {
         llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_TUBE, 0, <0.0, 1.0, 0.0>, 0.0, <0.0, 0.0, 0.0>, <1.0, IrisOpen, 0.0>, <0.0, 0.0, 0.0>, <0.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 1.0, 0.0, 0.0]);
          IrisOpen = IrisOpen - 0.10;
        }   
        g_OpenNow = TRUE;
        state WaitToClose;
    }
}


Top
 Profile  
 
 Post subject: Re: Slow iris door script wanted.
PostPosted: Sat Jun 18, 2011 5:20 pm 

Joined: Wed Jun 15, 2011 3:00 pm
Posts: 5
I did my iris door with the following, it's speed seems about the same as yours. (Tho I used a box instead of a tube) You're welcome to butcher it for your use, it's a single-state setup.

{L_CODE}:
integer gChannel = 14;
integer listen1;
float hollow = 0;
integer open;

door_open()
{
    if (open < 9)
    {
        if (open == 8)
        {
            hollow = 0.949;
            open = 9;
            door_open();   
        }
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 16, <0.0, 1.0, 0.0>, hollow, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
        hollow += 0.2;
        open += 2;
        door_open();
    }
    else if (open >= 9)
    {
        return;
    }
}

door_close()
{
    if (open >= 0)
    {
        llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, 16, <0.0, 1.0, 0.0>, hollow, <0.0, 0.0, 0.0>, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>]);
        hollow -= 0.2;
        open -= 2;
        door_close();
    }
    else if (open < 0)
    {
        return;
    }
}


default
{
    state_entry()
    {
        llListenRemove(listen1);
        listen1 = llListen(gChannel, "", "", "");       
    }
   
    listen(integer channel, string name, key id, string message)
    {
        if (message == "open")
        {
            open = 0;
            door_open();
        }
       
        else if (message == "close")
        {
            open = 8;
            hollow = 0.8;
            door_close();
        }
    }
}


In the interest of completeness this is for the "touch plate" opener so I could avoid using a sensor. (Don't link them btw, heh)

{L_CODE}:
integer gChannel = 14;
list avatars;
default
{
    state_entry()
    {
        llSetAlpha(0.0, ALL_SIDES);
        llVolumeDetect(TRUE);
    }
    on_rez(integer param)
    {
        llResetScript();
    }
    collision_start(integer num_detected)
    {
        integer k;
        for(k=0; k < num_detected; k++) if(llGetAgentSize(llDetectedKey(0)) != <0,0,0>)     avatars += [llDetectedKey(0)];
        llSay(gChannel, "open");
    }
    collision_end(integer num_detected)
    {
        integer k;
        for(k=0; k < num_detected; k++)
        {
            integer i = llListFindList(avatars, [llDetectedKey(0)]);
            if(i != -1)
            {
                avatars = llDeleteSubList(avatars, i, i);
            }
        }
       
        if(avatars == []) 
        {
            llSay(gChannel, "close");   
        }
    }
}


Last edited by Lasivian Leandros on Sun Jun 19, 2011 3:11 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Slow iris door script wanted.
PostPosted: Sat Jun 18, 2011 10:42 pm 
Furious Typer

Joined: Tue Oct 28, 2008 4:53 pm
Posts: 166
I noticed in the "touch plate" script, a link message event, but no reference to the messages "door off", "door on" in either script, I presume it's used to enable(unlock)/disable(lock) the door.


Top
 Profile  
 
 Post subject: Re: Slow iris door script wanted.
PostPosted: Sun Jun 19, 2011 3:14 am 

Joined: Wed Jun 15, 2011 3:00 pm
Posts: 5
Oops. Leftover old code :)

You ended up getting me totally sidetracked today, I made a "real" iris door. Takes a good 5 seconds to open.

{L_IMAGE}

(That's the SL version, I couldn't make it nearly as nice as the OS version) You're welcome to a copy if you want. (It's at my region in OSGrid, fittingly named "Lasivian". heh)


Top
 Profile  
 
 Post subject: Re: Slow iris door script wanted.
PostPosted: Sun Jun 19, 2011 8:01 am 
Furious Typer

Joined: Tue Oct 28, 2008 4:53 pm
Posts: 166
Thanks for the offer.

Nice iris door, really good for 26 prims, I tried it on your region, but it's not copyable, if you make it copyable, I would have to cluster take a copy,,, IE, highlight the entire build, then use viewer menu 'Tools -> Take Copy' because the way it works, it can not be linked.

I noticed there are individual linked parts, where the cube for the root prim in each linkset is the iris actuator.

I also noticed, if any of the blades are clicked, the last blade is slow to close/open, but if the button is clicked, then all blades open/close smoothly.


Top
 Profile  
 
 Post subject: Re: Slow iris door script wanted.
PostPosted: Mon Jun 20, 2011 3:15 pm 

Joined: Wed Jun 15, 2011 3:00 pm
Posts: 5
Marlon Wulluf {L_WROTE}:
Thanks for the offer.

Nice iris door, really good for 26 prims, I tried it on your region, but it's not copyable, if you make it copyable, I would have to cluster take a copy,,, IE, highlight the entire build, then use viewer menu 'Tools -> Take Copy' because the way it works, it can not be linked.

I noticed there are individual linked parts, where the cube for the root prim in each linkset is the iris actuator.

I also noticed, if any of the blades are clicked, the last blade is slow to close/open, but if the button is clicked, then all blades open/close smoothly.


It's copyable now.

And yeah, I haven't figured out how to make it easily clickable to open/close yet, what it really needs to do is send a message when clicked and let the button handle the activations.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 11 posts ]
Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net