Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Little help please touch to open script

Nisa Maverick
Registered User
Join date: 3 Jun 2007
Posts: 224
12-16-2009 01:44
I have been trying to get a simple touch to open script to work.
I would like this script to work on touch to open and touch to close, no automatic closing.
I have managed to get some of it right by deleting some of the script and got rid I think of the collision too.

I am a little stuck now as I cannot get it to work when linked to one more prim as like a greetings card opens. I have a message script to put into to it. but how do I get this script to work with a linked prim please.

all suggestions most welcome and appreciated.

// Swinging door LSL script #1
// Handles the touch event.
// Handles the collision event.
// Handles closing the door automatically via a timer event.
// Triggers sounds when the door opens or closes.

// Parameters you might want to change

float delay = 0.0; // time to wait before automatically closing door
// set to 0.0 to not automatically close
float direction = 1.0; // set to 1.0 or -1.0 to control direction the door swings
float volume = 0.0; // 0.0 is off, 1.0 is loudest

// Variables you will most likely leave the same



// Processing for the script when it first starts up

default {
// What we do when we first enter this state

state_entry() {
state open; // Move to the open state
}
}

// Processing for the script when it is in the closed state

state closed {
// What we do when we first enter this state

state_entry() {
// Trigger the sound of the door closing
llSetRot(llEuler2Rot(<0, 0, direction * PI_BY_TWO>;) * llGetRot());

}

// What we do when the door is clicked (”touched”) with the mouse

touch_start(integer total_number) {
state open; // Move to the open state
}





// What to do when the timer goes off

timer()
{
llSetTimerEvent(0.0); // Set the timer to 0.0 to turn it off
}
}

// Processing for the script when it is in the open state

state open {
// What we do when we first enter this state

state_entry() {
// Trigger the sound of the door opening
llSetRot(llEuler2Rot(<0, 0, -direction * PI_BY_TWO>;) * llGetRot());

llSetTimerEvent(delay); // Set the timer to automatically close it
}

// What do do when pulling the door from Inventory if it was saved while open

on_rez(integer start_param) {
state closed;
}

// What we do when the door is clicked (”touched”) with the mouse

touch_start(integer total_number) {
state closed; // Move to the closed state
}

// What to do when something hits the door

collision_start(integer total_number)
{
// Do nothing, the door is already open
}

// What to do when the timer goes off

timer()
{
llSetTimerEvent(0.0); // Set the timer to 0.0 to turn it off
state closed; // Move to the closed state
}
}

Also its a bit fast opening
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
12-16-2009 02:24
I use this little script in the interiour doors in my home.

CODE

integer open;

flip(float angle)
{
rotation rot = llGetLocalRot();
rotation delta = llEuler2Rot(<0, angle, 0> * DEG_TO_RAD);
llSetLocalRot(delta * rot);
}

default
{
touch_start(integer num)
{
if (open) flip(-100);
else flip(100);
open = !open;
}
}


I think that's enough for what you want.
Nisa Maverick
Registered User
Join date: 3 Jun 2007
Posts: 224
12-16-2009 05:29
Thanks for that little script Ron, but it cannot get that script to open a door it flips up and down but not open sideways on a cut prim of 0.375 and 0.875

I tried rotating the prim the other way but it still seems to rotate in the centre somehow.
Nisa Maverick
Registered User
Join date: 3 Jun 2007
Posts: 224
12-16-2009 06:24
I have remodified my script a bit now, but I still do not know how I can get it to work with another linked prim any ideas appreciated.

float direction = 1.0;

default {

state_entry() {
state open;
}
}

state closed {
state_entry() {

llSetRot(llEuler2Rot(<0, 0, direction * PI_BY_TWO>;) * llGetRot());

}
touch_start(integer total_number) {
state open;
}
}

state open {


state_entry() {
llSetRot(llEuler2Rot(<0, 0, -direction * PI_BY_TWO>;) * llGetRot());

}

}
Raver Bellow
Registered User
Join date: 22 Oct 2005
Posts: 13
Try this
12-16-2009 06:53
/54/c1/102699/1.html

This is a great door script. And can be linked. By Timeless Prototype
Nisa Maverick
Registered User
Join date: 3 Jun 2007
Posts: 224
12-16-2009 07:00
after some long changing and some very kind help I have got the script I want its here

float direction = 1.0;

default {

state_entry() {
state open;
}
}

state closed {
state_entry() {

llSetLocalRot(llEuler2Rot(<0, 0, direction * PI/2>;) * llGetLocalRot());

}
touch_start(integer total_number) {
state open;
}
}

state open {


state_entry() {
llSetLocalRot(llEuler2Rot(<0, 0, -direction * PI/2>;) * llGetLocalRot());

}
touch_start(integer total_number) {
state closed;
}

}
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
12-16-2009 10:03
From: Raver Bellow
/54/c1/102699/1.html

This is a great door script. And can be linked. By Timeless Prototype

gah no! otdated and over coded.

a simpler door is

CODE

//-- 90 degrees around z axis, use - 90 to reverse direction
vector vDegSwing = <0, 0, 90>;
rotation vRotSwing;

default{
state_entry(){
vRotSwing = llEuler2Rot( vDegSwing * DEG_TO_RAD ); // convert to rotation
}

touch_start( integer vIntNull ){
vRotSwing = ZERO_ROTATION / vRotSwing; // reverses rot direction
llSetLocalRot( vRotSwing * llGetLocalRot() );
//-- the next line could replace the two above
// llSetLocalRot( (vRotSwing = ZERO_ROTATION / vRotSwing) * llGetLocalRot() );
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -