Jump to content

scripting question


Pedlar Decosta
 Share

You are about to reply to a thread that has been inactive for 2214 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I have a script which I was tweaking. I had a simple "if(x==y){do something}" code in the script. In this case x did equal y, however it wasn't working. To double check if x = y I added some feedback llOwnerSay(x and y);  Suprisingly not only did x = y but the script worked. Perplexed I added forward slashes to make the ownersay a comment and when I did the script still worked. So I tested the script in 4 other objects and each time the script only worked when the comment was added. I am hoping someone can explain why this is so. 

if(x == y)

{   //llOwnerSay(x and y);

do something;  }

Thanks in advance

Confused.

Link to comment
Share on other sites

if it's a simple conditional check of...

if(x == y)

{

    llOwnerSay((string)x+" and "+(string)y);

    userMethod(); 

}

then the formatting seems okay, you remembered your ; 's on the ends and have braced it being more than one function call.

I'd check the formatting of your original, unedited script, make sure they all end;, and make sure the function calls fall within a {braced block} to avoid any lines being skipped if using in-line conditionals such as if(!x)doStuff();

 

adding a function call on its own shouldn't be effecting anything other than the time it takes to run through the blocks executing them.

 

if no syntax errors, and you compile fine, I have to wonder if maybe a call is "out of scope" from your {}'s, and being skipped as an in-line (which can only contain 1 call).

Edited by Ipecac Burnham
State was the wrong word, Scope is the rascal..
  • Like 1
Link to comment
Share on other sites

thanks for your reply ipecac. Apologies for the late reply, I have been away. Yes, I have checked the formating, run it on lslEditor etc. Although I will check again. The curious thing is that the only thing different is an added comment, which as far as I know, should be ignored. If I work it out I will explain it here. Cheers :)

Link to comment
Share on other sites

First the if ( x == y ) should work - do you have other if statements above? It could be a side-effect to previous if statements not handled correct.

And how do you check, if it works if there is nothing within the if the statement?  if ( x == y){}  This make no sense as it does as it should - nothing!

 

  • Like 1
Link to comment
Share on other sites

On 3/18/2018 at 12:43 AM, Pedlar Decosta said:

I have a script which I was tweaking. I had a simple "if(x==y){do something}" code in the script. In this case x did equal y, however it wasn't working. To double check if x = y I added some feedback llOwnerSay(x and y);  Suprisingly not only did x = y but the script worked. Perplexed I added forward slashes to make the ownersay a comment and when I did the script still worked. So I tested the script in 4 other objects and each time the script only worked when the comment was added. I am hoping someone can explain why this is so. 

if(x == y)

{   //llOwnerSay(x and y);

do something;  }

Thanks in advance

Confused.

Make sure you don’t have a semicolon after the If like this, not sure if LSL gives a warning or not:

if (x==y);  // don’t put a semicolon here!

{ dostuff; }

  • Like 2
Link to comment
Share on other sites

Okay so I have run into this issue several times and it seems to be a bug of some kind. The only annoying problem is its not reproducible enough to locate it as it happens fairly sporadically. I can not offer you any understanding of why it happens but I can re assure you that my code was correct on each occasion, I had another coder friend confirm that all was okay even though I knew it was, and the section of code or script would only run once the llOwnerSay was added. Im glad you posted this I thought I was going mad xD. I have experienced it quite a few times over the last 5 years or so. But never before.

  • Like 1
Link to comment
Share on other sites

Without being able to see the code, it's simply a guessing game about what may be causing it.

The only explanation I can think of that explains the little we know about the details of the problem is that there's some sort of race condition that prevents the script from executing the command to "do something else" (whatever that something else may be).    The slight delay caused by executing the llOwnerSay ensures that whatever it is that needs to complete, gets time to complete.

Try substituting llSleep(0.1) for the llOwnerSay and see what happens.

Certainly, in general, I find that very brief sleeps (no more than 0.2 seconds generally) will often fix mysterious script issues like this.    That's what llSleep is for, as far as I am concerned -- delaying things slightly to give other things a chance to complete.  

It would be interesting to know what x and y are, that are being compared, but that probably isn't what's causing it.

Edited by Innula Zenovka
  • Like 2
Link to comment
Share on other sites

  • 3 weeks later...

Hi Innula. X and y were just 2 elements in a list. They had been parsed (from an object description). I had tried  using a sleep as well but it didn't help. I believe it was being caused by an unknown formatting error in the preceding script and out of frustration I rewrote much of it and coded the event differently. I thought I had kept at least one original so that I could go back and examine it if for my own interest and to share those findings on this thread. However I can't find it now, so I can't show you more of the script unfortunately. The purpose of the script was to manipulate and control the parameters of a prim.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2214 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...