Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Weird Script Problems

Borat Kungler
Registered User
Join date: 13 Apr 2007
Posts: 33
07-19-2007 15:49
Hi,

I am having really weird issues with my scripts atm. It may be something i'm missing but I have gone over it and over it and don't see anything obvious - but I'm no LSL god!

I have a really basic script like:

CODE


key target;
integer g_Attached;

setParticles()
{
llParticleSystem(........);
}

endParticles()
{
llParticleSystem([]);
}

default
{
state_entry()
{
target = llGetKey();
}

on_rez(integer start_param)
{
}

attach(key attached)
{
if (attached != NULL_KEY)
{
g_Attached = TRUE;
}
else
{
g_Attached = FALSE;
}
}

changed(integer change)
{
if (change & CHANGED_TELEPORT)
{
if (g_Attached == TRUE)
{
setParticles();
}
}
}
}



Now the script works fine when I teleport - the particle effect fires as it should. However, it ALSO fires when I right click on the object if it's rezzed on the ground to edit it. - Why?? There is only one place where this is told to fire and it should only fire if 'change & CHANGE_TELEPORT right?

The other problem is this - I am *trying* to introduce a listen function which I have done hundreds of times before. Because I am using llGetOwner() I am using llResetScript(). The problem however is that as soon as llResetScript is put anywhere in the script, it simply stops listening completely.

As soon as llResetScript is taken out, it starts listening again. I was putting llResetScript in the on_rez (this failed) and i also tried putting in the attach function (this also failed).

Am I just dumb and missing something really obvious or is there a problem?

Any help will be really appreciated because I'm tearing my hair out now! Thanks in advance :)
Darien Caldwell
Registered User
Join date: 12 Oct 2006
Posts: 3,127
07-19-2007 16:19
I have seen the particle fire on touch issue with a lot of items. Two that come to mind are a popular Avatar Cannon and a sports car. It's something that began happening a couple client releases ago, and I'm still not clear if it's a bug or a feature.


As for the listen, resetting a script removes all listens, so just place your llListen() command someplace where it would be executed on script reset. state_entry() is ideal for this.
_____________________
RobbyRacoon Olmstead
Red warrior is hungry!
Join date: 20 Sep 2006
Posts: 1,821
07-19-2007 16:23
From: Borat Kungler
Hi,

I am having really weird issues with my scripts atm. It may be something i'm missing but I have gone over it and over it and don't see anything obvious - but I'm no LSL god!

I have a really basic script like:

CODE


key target;
integer g_Attached;

setParticles()
{
llParticleSystem(........);
}

endParticles()
{
llParticleSystem([]);
}

default
{
state_entry()
{
target = llGetKey();
}

on_rez(integer start_param)
{
}

attach(key attached)
{
if (attached != NULL_KEY)
{
g_Attached = TRUE;
}
else
{
g_Attached = FALSE;
}
}

changed(integer change)
{
if (change & CHANGED_TELEPORT)
{
if (g_Attached == TRUE)
{
setParticles();
}
}
}
}



Now the script works fine when I teleport - the particle effect fires as it should. However, it ALSO fires when I right click on the object if it's rezzed on the ground to edit it. - Why?? There is only one place where this is told to fire and it should only fire if 'change & CHANGE_TELEPORT right?

If you never call endParticles(), then the particles stay set as a prim property. Any time your client gets a prim update, you will see the particles. You will get a prim update when editing the prim, teleporting, or even going out of range and coming back.

Calling endParticles() (in this example) or llParticleSystem( [] ) will resolve this issue for you.

From: Borat Kungler
The other problem is this - I am *trying* to introduce a listen function which I have done hundreds of times before. Because I am using llGetOwner() I am using llResetScript(). The problem however is that as soon as llResetScript is put anywhere in the script, it simply stops listening completely.

As soon as llResetScript is taken out, it starts listening again. I was putting llResetScript in the on_rez (this failed) and i also tried putting in the attach function (this also failed).

Am I just dumb and missing something really obvious or is there a problem?

Any help will be really appreciated because I'm tearing my hair out now! Thanks in advance :)


I don't see anywhere in this script where you are starting the listen, so I cannot give specific advice, but using llResetScript always works for me in my objects that use listens. I will typically put the call to llListen() in the state_entry event, though.
_____________________