Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

auto close feature wont stop working

maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
06-27-2009 15:30
this script had an auto close set but i had thought i managed to take it out, seems i was wrong and it is still rotating back to its previous position after a few seconds. and i was going to try to make it follow chat commands but all my attempts end in syntax errors :(
here is the script if anyone can help.

i had to put spaces on either side of the < and > in the openRot line of the script because it was causeing a 404 error when posting


float openingTime=2.0; // in seconds
float openingAngle=45.0; // in degrees
float autocloseTime=5.0; // in seconds

float omega=0.0;

vector axis;
rotation closedRot;
rotation openRot;

integer swinging;
integer open;

openDoor(integer yes)
{
vector useAxis=axis;
open=yes;

if(!yes)
useAxis=-axis;

llSetTimerEvent(openingTime);
llTargetOmega(useAxis,omega,1.0);
}

default
{
state_entry()
{
swinging=FALSE;
open=FALSE;
omega=TWO_PI/360*openingAngle/openingTime;
llTargetOmega(ZERO_VECTOR,1.0,1.0);
}

touch_start(integer dummy)
{
if(!swinging)
{
if(!open)
{
axis=llRot2Fwd(llGetLocalRot());
closedRot=llGetLocalRot();
openRot=llEuler2Rot( < openingAngle,0.0,0.0 > *DEG_TO_RAD)*closedRot;
}
swinging=TRUE;
openDoor(!open);
}
}

timer()
{
if(swinging)
{
swinging=FALSE;
llTargetOmega(axis,0.0,0.0);
if(open)
{
llSetLocalRot(openRot);
llSetTimerEvent(autocloseTime);
}
else
{
llSetLocalRot(closedRot);
llSetTimerEvent(0.0);
}
}
else
{
llSetTimerEvent(0.0);
openDoor(!open);
swinging=TRUE;
}
}
}
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
06-27-2009 18:09
you could try setting autoclose time to 0 or removing the line that sets the timer with it, but from the looks of it that'll interfere with with the touch logic if it's open.

you might be able to get away with (open = !open) in the touch event, at a quick guess, but if not it needs to be reworked to skip some code in the open door function, or reverse the direction of omega when the door is closing....
_____________________
|
| . "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...
| -
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-01-2009 14:31
hadn't gotten around to it, original is a bit messy, here's the updated version.

CODE

float gFltTim = 2;
float gFltAng = 90;

float gRadSpn;
rotation gRotAng;


default{
state_entry(){
gRadSpn = gFltAng * DEG_TO_RAD / gFltTim;
gRotAng = llEuler2Rot( < 0.0, 0.0, gFltAng * DEG_TO_RAD > );
}

touch_start( integer vInt ){
llTargetOmega( (< 0.0, 0.0, 1.0 > * llGetLocalRot()), (gRadSpn *= -1), 1.0 );
llSleep( gFltTim );
llTargetOmega( ZERO_VECTOR, 0.0, 0.0 );
llSetLocalRot( (gRotAng = (ZERO_ROTATION / gRotAng)) * llGetLocalRot() );
}
}


(and yes sleep seems to work just fine at this time scale)
_____________________
|
| . "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...
| -
maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
07-02-2009 06:58
thank you Void, sorry for pooping up the forum with a second post :)
maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
07-02-2009 07:37
thats a nice smooth rotation, but i can not seem to turn it into a listen in stead of a touch start, plus the rotation is at a differant angle and when i try to change it it pops back in the wrong place when it finished the rotation.
:(
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
07-02-2009 10:19
looking at the origingal I noticed it assumes a cut on the z axis instead of the y or x (not as good for doors) you can change that by changing your cut or by rotating on a different axes using

gRotAng = llEuler2Rot( < gFltAng * DEG_TO_RAD, 0.0, 0.0 > );

or

gRotAng = llEuler2Rot( < 0.0, gFltAng * DEG_TO_RAD, 0.0 > );

as for puting it in a listen just change the event handler from a touch to

listen( integer vIntChannel, string vStrSpeaker, key vKeySpeaker, string vStrMessage ){

and drop a llListen state entry.

you may want some filterering so enclose the code that was in the touch event in an if, to do that...

references
https://wiki.secondlife.com/wiki/LlListen
https://wiki.secondlife.com/wiki/If
_____________________
|
| . "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...
| -
maihem Sinister
Registered User
Join date: 7 Oct 2008
Posts: 29
07-02-2009 14:31
thanks again Void i will tinker with that when i get home from work tonight :)