Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Unintended script communication

WindyWeather Vanalten
Registered User
Join date: 27 Nov 2006
Posts: 53
01-14-2007 21:58
Here's one for the Ghosts department...

So I'm building a house. Eventually to be linked using Rez-Fauz, so I want it linked up in a few number of large chunks.

So there are doors in the house, so I use the Ultimate Door script, and modify it to work when linked in a collection, or not. Just change to llSetLocalRot. Anyway, Doors work fine when not linked and usually when linked. Except this funny things started happening...

When opening one door, others started closing. But only when linked in a collection. And only when there are certain numbers of doors in a collection. And it only causes doors to close, not to open. I've reported this as a bug, with the entire first floor of my house as an attached object... Have fun...

After some more testing, I found that unlinking a door from one floor or another, and the problem goes away. Unlinked door works fine, and all rest in the object work fine. But if I link that door to the other floor, then they all start failing on that floor... Something about the number of doors on a floor I guess...

Rest of objects in house are scriptless and these doors do not communicate with each other, at least they do not make calls that you would think would communicate.

Here's the script as I am using it.
CODE

// deluxe door script by Ezhar Fairlight
// features: one prim, no building skills required, automatic closing, workaround for rotation drift,
// doesn't mess up when moved, adjustable direction (inwards/outwards) and sound volume, HHGG quotes!
// updated for SL 1.4

// just rez a cube primitive and put this script inside - it will shape and texture itself into a door

// ********** SETTINGS HERE ************
float TIMER = 30.0; // automatically close the door after this many seconds,
// set to 0 to disable automatic closing

integer DIRECTION = 1; // direction door opens in. Either 1 (outwards) or -1 (inwards);

float VOLUME = 0.8; // sound volume, 1.0 loudest, 0.0 to disable sound
// ********** END OF SETTINGS **********


key SOUND_OPEN = "cb340647-9680-dd5e-49c0-86edfa01b3ac";
key SOUND_CLOSE = "e7ff1054-003d-d134-66be-207573f2b535";

vector gPos; // door position (objects move a tiny amount
// away from their position each time they are rotated,
// thus we need to workaround this by resetting
// the position after rotating)

door(integer open) {
if (open) {
llTriggerSound(SOUND_OPEN, VOLUME);
llSetLocalRot(llEuler2Rot(<-DIRECTION * PI_BY_TWO, 0, 0>) * llGetLocalRot());
} else { // close
llSetLocalRot(llEuler2Rot(<DIRECTION * PI_BY_TWO, 0, 0>) * llGetLocalRot());
llTriggerSound(SOUND_CLOSE, VOLUME);
}
}


default { // first time startup
state_entry() {
if (llGetTexture(0) == "89556747-24cb-43ed-920b-47caed15465f") { // is default texture, set it up
llSetPos(llGetPos() + <0, 0, 3.325 / 2 - 0.25>);
llSetPrimitiveParams([PRIM_TYPE, PRIM_TYPE_BOX, <0.375, 0.875, 0>, 0.0, 0.0, <1, 1, 0>, <0, 0, 0>,
PRIM_SIZE, <0.2, 4, 3.325>,
PRIM_TEXTURE, 0, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <2.000000, 0.060000, 0.000000>, <0.500015, 0.469985, 0.000000>, 1.570840,
PRIM_TEXTURE, 1, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <-2.000000, 1.000000, 0.000000>, <0.500015, 0.000000, 0.000000>, 0.000000,
PRIM_TEXTURE, 2, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <0.100000, 1.000000, 0.000000>, <0.599994, 0.000000, 0.000000>, 0.000000,
PRIM_TEXTURE, 3, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <2.000000, 1.000000, 0.000000>, <0.500015, 0.000000, 0.000000>, 0.000000,
PRIM_TEXTURE, 4, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <2.000000, 0.080000, 0.000000>, <0.500015, 0.550005, 0.000000>, 1.570840,
PRIM_TEXTURE, 5, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <0.100000, 1.000000, 0.000000>, <0.449995, 0.000000, 0.000000>, 0.000000,
PRIM_TEXTURE, 6, "086c7e6b-bdd6-7388-f146-f3d1b353ed15", <0.100000, 1.000000, 0.000000>, <0.449995, 0.000000, 0.000000>, 0.000000]
);
llSetObjectName("Door Deluxe");
llSay(0, "Thank you for making a simple door very happy.");
}
gPos = llGetPos(); // remember where we're supposed to be
door(TRUE);
state closed;
}
}

state closed { // door is closed
on_rez(integer start_param) {
gPos = llGetPos();
}

state_entry() {
door(FALSE);
}

touch_start(integer total_number) {
state open;
}

moving_end() { // done moving me around, store new position
gPos = llGetPos();
}
}

state open { // door is open
on_rez(integer start_param) {
gPos = llGetPos();
state closed;
}

state_entry() {
llSetTimerEvent(TIMER);
llSetPos(gPos); // rotation drift workaround
door(TRUE);
}

touch_start(integer num) {
state closed;
}

timer() { // auto-close
state closed;
}

moving_start() { // close when being moved
state closed;
}

state_exit() {
llSetTimerEvent(0);
}
}
Lex Neva
wears dorky glasses
Join date: 27 Nov 2004
Posts: 1,361
01-15-2007 11:37
Hmm, that is kinda freaky. My only thought is that maybe somehow the llSetLocalRot() call is triggering a little bit of movement, which is in turn triggering some of the rest of the doors' moving_start() events. People have noticed that setting rotation causes movement sometimes...
WindyWeather Vanalten
Registered User
Join date: 27 Nov 2006
Posts: 53
aaaalllllllllllllllllllllrrrrrriiiiigggggghhhhhhtt ttttt........
01-15-2007 15:11
Ok... Thanks Lex.. That appears to be it.... I've developed a workaround that works 99.99 percent of the time. I did get one false trigger after a pile of pushes, but wanted to keep the times short rather than lengthening them further. The .5 sec close did work. Moved the door in the middle of a long drag. But the door position can be changed successfully and it still works, so all is well. So the fixed script state open portion now looks like this:

CODE


integer weAreJerked = FALSE; // workaround for we are being jerked when another door closes.

state open { // door is open
on_rez(integer start_param) {
gPos = llGetPos();
state closed;
}

state_entry() {
llSetTimerEvent(TIMER);
llSetPos(gPos); // rotation drift workaround
door(TRUE);
}

touch_start(integer num) {
state closed;
}

timer() { // auto-close
// if we are moving only on a jerk then ignore the event and do not close door
// and set the timer again while we move to close the door on a real move.
if ( weAreJerked )
{
weAreJerked = FALSE;
llSetTimerEvent( .5 );
}
else
{ // we are really being moved or we just timed out
state closed;
}
}

// Opening one door in linked object with several doors causes others
// to slam. We need to get around a little jerk on rest of doors caused
// by opening a door.
moving_start() { // close when being moved
weAreJerked = TRUE;
llSetTimerEvent( .1 );
//state closed;
}

// get around that quick little jerk caused if we are in a linked object
moving_end() {
weAreJerked = FALSE;
llSetTimerEvent(TIMER);
}

state_exit() {
llSetTimerEvent(0);
}
}