Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Door script with changable speed?

Milo Bukowski
Lag-induced oversteer
Join date: 23 Dec 2003
Posts: 305
10-26-2004 05:32
I'm looking for a simple door script that I can make open slowly. I'm building a drawbridge for an island, and although it's only a short water way passage, I don't want to block tall sailboats. I'm trying to get it to open slowly like it's a big, heavy piece of metal, but all the doors I have swing open immediately. The other requirement is auto-close after x seconds, which several already have. I'd prefer a hinged door rather than sliding, but if I can find a sliding door that works I'd use it.

The only thing I could find that has anything to do with the door speed might be the llEuler2Rot() function, but I don't know trig or whatever it takes to understand it. Any snippets a scripting newb such as myself would understand? Or better yet, a whole script?

Thanks
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
10-26-2004 12:50
To resolve the issue of the additional HINGE thing, you might also consider rotating the horizontal axis so that the road does not lift, rather the center stays put, and the two ends rotate to become parallel with the water, and two boats can pass either side of the center at the same time. It's no drawbridge, more like a turnstyle, but might be an interesting thing. How wide is the body of water you are spanning? Maybe not practical if not real wide. If about 30m or 20m then maybe??? :D
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
10-26-2004 18:38
If you want to keep your drawbridge non-physical:

You can build a loop into your script that rotates the bridge 1-degree every 100th of a second. Of course, change the speed by changing the fraction of second. You could do this simply by using llSetRot() and llSleep(). If the drawbridge rotates 45-degrees, then the loop would execute 44 times, adding the current instance integer to the previous llSetRot(). Once the bridge is open, use llSleep() again to delay however long the bridge remains open. Then, reverse the loop to rotate the bridge down again.

Of course, the above method may not produce a smooth rotation.... another option is to use the physical functions. In my experience, that requires experimentation to get it right. I've found physical rotations very challenging due to the need for Euler conversion. If you haven't already, check out the rotations page at Bad Geometry.

As for the hinge, that's the easy part. Just create a prim at the hinge point... even make it look like a hinge. Make it the root prim in the link group, and place the script there.
Pete Fats
Geek
Join date: 18 Apr 2003
Posts: 648
10-26-2004 20:33
CODE

integer i;
rotation rot;
rotation delta;
for (i = 0; i < 16; i++) //make this larger to increase the ammount of 'steps' to open
{
rot = llGetRot();
delta = llEuler2Rot(<0,0,PI/32>); //this must be p/max i * 2 to make a quarter turn. If i counts to 32, this would become 64.
rot = delta * rot;
llSetRot(rot);
llSleep(0.25); //slow everything down a bit. You might want to play with taking this out and increasing the for loop instead.
}


This should work (though writting off the top of my head). Just add it into a touch event. As a side note, I kept it rotating along the Z axis, so you will have to rotate the prim to get it to swing in the correct direction.
_____________________
Milo Bukowski
Lag-induced oversteer
Join date: 23 Dec 2003
Posts: 305
10-27-2004 11:22
Thanks all! I'll give it a shot tonight.