Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

curtain script

CarloDM Demme
Registered User
Join date: 15 Jun 2007
Posts: 44
06-24-2008 02:19
I put the curtain script in 2 prims to have two pieces of tent, one that opens to the right and one that opens to the left

but if i link together, the tent does not work well so I thought that certainly i need a script outside inserted in third prim (the main one) that starts the two scripts simultaneously.

can anyone help me to find the solution to my problem?

thank you
Varun Blitz
Registered User
Join date: 22 May 2008
Posts: 62
06-24-2008 02:30
it shud work even in linked state, just make sure u use local positions rather than llgetpos. it will fetch the position of the parent prim.
Varun Blitz
Registered User
Join date: 22 May 2008
Posts: 62
06-24-2008 02:41
From: Varun Blitz
it shud work even in linked state, just make sure u use local positions rather than llgetpos. it will fetch the position of the parent prim.


u can try that both the curtains are listening on the same channel for message from main, and behave differently on receiving the message.
CarloDM Demme
Registered User
Join date: 15 Jun 2007
Posts: 44
06-24-2008 06:42
this is my script

CODE


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.2; //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;
}
}



how have i change it to start 2 prims togheter?
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
06-24-2008 12:04
From: CarloDM Demme
I put the curtain script in 2 prims to have two pieces of tent, one that opens to the right and one that opens to the left

but if i link together, the tent does not work well so I thought that certainly i need a script outside inserted in third prim (the main one) that starts the two scripts simultaneously.

can anyone help me to find the solution to my problem?

thank you


Link Messages would be the way to do it.

Simply replace
CODE

touch_start(integer detected)


with
CODE

link_message(integer sender_num, integer num, string str, key id)


in the two curtain scripts and, in the third prim, put
CODE

default
{
touch_start(integer total_number)
{

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

}
}
CarloDM Demme
Registered User
Join date: 15 Jun 2007
Posts: 44
06-24-2008 22:57
oh thank you very much Innula, my curtain is perfect now ;)
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
06-27-2008 13:48
this looks great, it looks like it could easily be used for sliding doors too. instead of actual sliding doors, it "shrinks" the door, so if the space you're using doesn't easily hide the doors after being opened (if needed)
Felicity Heaney
Registered User
Join date: 1 Dec 2005
Posts: 8
07-11-2008 18:11
For the life of me I cannot ge this to work
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
07-15-2008 17:10
From: Felicity Heaney
For the life of me I cannot ge this to work

works fine for me, what's wrong felicity?
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
07-15-2008 23:25
the above method works if you want to be able to touch the tent anywhere to open the curtains. if you want to only be able to touch the curtains to open them, and no where else, use this below script in the curtain(s) you want to open, no need for a seperate script to send the link message because sending it to the link set includes itself. it's the same as the 2 above, just combined:

From: someone

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.2; //The minimum size of the prim relative to its maximum size
integer ns = 5; //Number of distinct steps for move/size change


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)
{
integer i;
do llSetPrimitiveParams([PRIM_SIZE, llGetScale() - offset,
PRIM_POSITION, llGetLocalPos() + ((hi_end_fixed * offset) * llGetLocalRot())]);
while ((++i) < ns);
offset = - offset;
}
}
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
08-03-2008 10:45
meh, i had an idea to use that for flexi curtains, but, it doesn't flow well, i guess the prim turns stiff again for like half a second at each scale change, so the curtain seems to "flick" between each step. or maybe it's just my viewer?