Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Stupid Door! :)

Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
03-18-2007 17:22
Ok.. you're not going to believe this, but I am obviously missing something small and stupid.

I took this directly from the wiki and modified it for where my door is going to be. For whatever reason, the door will swing one way and that's it. Never to swing again. You can edit the object, rotate it back, and it will swing again - only once. In one direction and stop.

If I revert to the same position as the original example (z = 0, s = 1 / z = 0.70107, s=70107) it allworks perfect. What the???

Here it is...

CODE


default
{
touch_start(integer total_number)

{
rotation rot = llGetLocalRot();

if (rot.z == 0.350207)
{
rot.z = 0.936672;
rot.s = 0.414693;
}
else
{
rot.z = 0.350207;
rot.s = 0.909961;
}
llSetLocalRot(rot);
}
}
}



Suggestions please.... (sorry about the code not coming out color coded.. not sure about that one... just did a cut and paste like usual)

Thanks in advance..
Hap
Element Smirnov
Registered User
Join date: 13 Oct 2006
Posts: 108
03-18-2007 17:35
heres some door scripts: /54/22/24116/1.html
Orlie Omegamu
Registered User
Join date: 12 Mar 2006
Posts: 16
Re: Stupid Door
03-18-2007 17:36
You might try changing this:

if (rot.z == 0.350207)

to this:

if (rot.z < 0.5)


Floats may or may not give you an exact match.
Ed Gobo
ed44's alt
Join date: 20 Jun 2006
Posts: 220
03-18-2007 17:40
You can see a fully featured lined door script that does not need the door to be cut at:
http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryTimelessLinkedDoor

However, to get back to your script, let me make some points:

The script assumes two fixed locations, and they are in "rotation" format. These rotations are made up out of 4 floats and they have to match exactly to meet that first statement. It only takes a tiny amount of drift and that first if condition will never ever be true.


CODE
if (rot.z == 0.350207)


it would be better to compare the difference to a very small number and to say something like:

CODE
if (llFAbs (rot.z - 0.350207) < .01)


That will hopefully get that script working at least.
Haplo Voss
Registered User
Join date: 18 Nov 2006
Posts: 137
Thanks!
03-18-2007 19:25
Thanks a mint... Works perfectly now. I didn't even think about a floating point variable being a problem since the original script writer had them plugged in there. Upon thinking about it.. I never thought to look that the if / else statements never had to deal with anything other than whole numbers when it came down to it in the original script LOL.

Thanks again and now I will add some sounds and such.