Page 1 of 1
Need curtain script open & close on touch
Posted: Tue Aug 28, 2018 7:53 pm
by elin egoyan
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;
}
}
Re: Need curtain script open & close on touch
Posted: Wed Aug 29, 2018 8:21 pm
by Graham Mills
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;
}
}
Re: Need curtain script open & close on touch
Posted: Wed Aug 29, 2018 10:24 pm
by Dahlea Milena
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;
}
}
Re: Need curtain script open & close on touch
Posted: Thu Aug 30, 2018 7:17 am
by elin egoyan
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
. 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
Re: Need curtain script open & close on touch
Posted: Thu Aug 30, 2018 9:59 am
by Graham Mills
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.
Re: Need curtain script open & close on touch
Posted: Fri Oct 02, 2020 2:12 am
by Krull Kitty
Code: Select all
integer up;
vector startSize;
float endSize = 5.0; //In meters, how long the prim will end up being along it's Z axis.
float rate = 0.1; //In meters, how much it stretches every roughly 0.5 seconds.
curtainTransition()
{
if (up)
{
startSize = llGetScale();
float i;
for (i = startSize.z; i < endSize; i += rate)
{
vector scale = llGetScale();
vector pos = llGetLocalPos();
llSetScale(<scale.x, scale.y, scale.z + rate>);
llSetPos(<pos.x, pos.y, pos.z - (rate / 2)>);
}
up = FALSE;
}
else if (!up)
{
float i;
for (i = endSize; i > startSize.z; i -= rate)
{
vector scale = llGetScale();
vector pos = llGetLocalPos();
llSetScale(<scale.x, scale.y, scale.z - rate>);
llSetPos(<pos.x, pos.y, pos.z + (rate / 2)>);
}
up = TRUE;
}
}
default
{
state_entry()
{
up = FALSE;
startSize = llGetScale();
//llListen(55555, "", NULL_KEY, "curtain"); //Uncomment this if you're using the listen event for activation.
//llListen(55555, "", llGetOwner(), "curtain"); //Uncomment this instead if you only want it to listen to the owner.
}
on_rez(integer start_param)
{
up = TRUE;
startSize = llGetScale();
}
///Below this line are three means of activation. You might want to delete the ones you're not using.
touch_start(integer total_number) //Use this event to make the curtian activate when touched.
{
//if (llDetectedKey(0) != llGetOwner()) return; //Uncomment this line to make owner-only.
curtainTransition();
}
link_message(integer sender_num, integer num, string str, key id)
{
if (str == "curtain") curtainTransition(); //Activates the curtains when this prim receives a link message containing
//link_message "curtain" as the string. To make link_message owner only, that will have to be specified in the script sending the
}
listen(integer channel, string name, key id, string message)
{
if (message == "curtain") curtainTransition(); //Activates the curtains when it hears "curtain" on channel 55555.
//(Make sure to uncomment the llListen() line in state_entry() if you're going to use this.)
}
}