Need curtain script open & close on touch

Creating scripts
Post Reply
User avatar
elin egoyan
Posts: 10
Joined: Fri Feb 06, 2015 4:06 pm
Location: The Netherlands
Has thanked: 6 times
Been thanked: 21 times

Need curtain script open & close on touch

Post by elin egoyan » Tue Aug 28, 2018 7:53 pm

I am in desperate need for a curtain script that can open and close on touch. I have the script from the script library ( see below) but that does not work in Kitely. Soooo,... anybody :?: :?: :?:

Code: Select all

vector offset = <1,0,0>; //Prim moves/changes size along this local coordinate
float 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.4; //The minimum size of the prim relative to its maximum size
integer ns = 39; //Number of distinct steps for move/size change
string motion_sound = "";     // These can be set to "" to disable the sounds.

default 
{
touch_start(integer total_number)
{

llMessageLinked(LINK_SET, 0, "Touched.", NULL_KEY);

}
state_entry() {
offset *= ((1.0 - min) / ns) * (offset * llGetScale());
hi_end_fixed -= 0.5;
}

link_message(integer sender_num, integer num, string str, key id)
{
    if (motion_sound != "")
        llTriggerSound(motion_sound, 1.0);
integer i;
do llSetPrimitiveParams([PRIM_SIZE, llGetScale() - offset,
PRIM_POSITION, llGetLocalPos() + ((hi_end_fixed * offset) * llGetLocalRot())]);
while ((++i) < ns); 
offset = - offset;
}
} 
These users thanked the author elin egoyan for the post (total 2):
Ilan TochnerDahlea Milena
Graham Mills
Posts: 966
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 567 times
Been thanked: 723 times

Re: Need curtain script open & close on touch

Post by Graham Mills » Wed Aug 29, 2018 8:21 pm

Zilla's curtain script may work for you.

Code: Select all

//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 coordinate
float 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 size
integer ns = 10; //Number of distinct steps for move/size change

default {    
    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;    
    }   
}
These users thanked the author Graham Mills for the post (total 2):
Dahlea Milenaelin egoyan
User avatar
Dahlea Milena
Posts: 5
Joined: Sun Aug 26, 2018 7:43 pm
Has thanked: 29 times
Been thanked: 14 times

Re: Need curtain script open & close on touch

Post by Dahlea Milena » Wed Aug 29, 2018 10:24 pm

How about using a sliding door script? I've seen that in kitely, and used it for curtains in SL also? it only works for sliding a curtain to one side & back, and not sure of the delay settings; or up & down, like blinds or shades. Not a perfect option. Good luck!
elin egoyan wrote:
Tue Aug 28, 2018 7:53 pm
I am in desperate need for a curtain script that can open and close on touch. I have the script from the script library ( see below) but that does not work in Kitely. Soooo,... anybody :?: :?: :?:

Code: Select all

vector offset = <1,0,0>; //Prim moves/changes size along this local coordinate
float 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.4; //The minimum size of the prim relative to its maximum size
integer ns = 39; //Number of distinct steps for move/size change
string motion_sound = "";     // These can be set to "" to disable the sounds.

default 
{
touch_start(integer total_number)
{

llMessageLinked(LINK_SET, 0, "Touched.", NULL_KEY);

}
state_entry() {
offset *= ((1.0 - min) / ns) * (offset * llGetScale());
hi_end_fixed -= 0.5;
}

link_message(integer sender_num, integer num, string str, key id)
{
    if (motion_sound != "")
        llTriggerSound(motion_sound, 1.0);
integer i;
do llSetPrimitiveParams([PRIM_SIZE, llGetScale() - offset,
PRIM_POSITION, llGetLocalPos() + ((hi_end_fixed * offset) * llGetLocalRot())]);
while ((++i) < ns); 
offset = - offset;
}
} 
These users thanked the author Dahlea Milena for the post (total 2):
Graham Millselin egoyan
WeWhoServed welcomes our Military & Veterans; the coffee's always hot, & you're always welcome!

[url]grid.kitely.com:8002:WeWhoServed[/url]

Dahlea Milena
Army/USAF
Panama/Gulf War/Somalia
Image
User avatar
elin egoyan
Posts: 10
Joined: Fri Feb 06, 2015 4:06 pm
Location: The Netherlands
Has thanked: 6 times
Been thanked: 21 times

Re: Need curtain script open & close on touch

Post by elin egoyan » Thu Aug 30, 2018 7:17 am

TY Graham:) However Zilla's script is the same as I have pasted in my post. And TY Dahlea. It is worth to try that out :D. However... tatatataaaa I have bought on Kitely market the sculpted curtainset from DATS. They deliver a curtainscript in that package that works perfectly. It is exportable so if anybody needs a script for curtains, then you know were to find it :)
These users thanked the author elin egoyan for the post:
Dahlea Milena
Graham Mills
Posts: 966
Joined: Sun Dec 23, 2012 2:26 pm
Has thanked: 567 times
Been thanked: 723 times

Re: Need curtain script open & close on touch

Post by Graham Mills » Thu Aug 30, 2018 9:59 am

Apologies -- it is a little different (no llMessageLinked) but yes the core is the same. However, for me it seems to work OK if I define "working" as meaning a prim expands or contracts in one dimension from or towards a static edge. Anyway, glad you sorted out your problem.
These users thanked the author Graham Mills for the post:
elin egoyan
Post Reply