Jump to content

Getting scripting errors - help!


Caspian Dionysus
 Share

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

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

Recommended Posts

I'm writing a script that will send message based on keys. Everything on the script is good, except I keep getting syntax errors on the else if statement. Before I added that part into the script it worked fine. Any idea what I'm doing wrong?

 

list message = [
" message"];

list TrinMessage = [
" test message."];

list PoohMessage = [
" test msg."];

integer messageNumber;
integer TrinMessageNumber;
integer PoohMessageNumber;

string Trin = "removed keys for privacy"; 
string Pooh = "removed keys for privacy";
 default
 {
     touch_start(integer num_detected)
     {
         integer x;
        key     detectedKey;
        
        for (x = 0; x < num_detected; x += 1)
        {
            detectedKey = llDetectedKey(x);
        if (detectedKey == Trin)
            {
            TrinMessageNumber = (integer)llFrand((float)llGetListLength(TrinMessage));
            llSay(0, llGetDisplayName(llDetectedKey(0)) + llList2String(TrinMessage,TrinMessageNumber)); 
            }
       
            detectedKey = llDetectedKey(x);
      else if (detectedKey == Pooh)
            { 
            PoohMessageNumber = (integer)llFrand((float)llGetListLength(PoohMessage));
            llSay(0, llGetDisplayName(llDetectedKey(0)) + llList2String(PoohMessage,PoohMessageNumber));
            }
                
        else
            {  
            messageNumber = (integer)llFrand((float)llGetListLength(message));
            llSay(0, llGetDisplayName(llDetectedKey(0)) + llList2String(message,messageNumber));
            }
            
        }
         
     }
 }
 

Edited by Caspian Dionysus
removed keys
Link to comment
Share on other sites

7 minutes ago, KT Kingsley said:

I think you're getting the error because the line detectedKey = llDetectedKey(x); is between the closing bracket of the if section and the start of the else if section.

If I remove it from there, it tells me the detected key in the else if statement isn't defined. When I added it, that error went away and it gave a syntax error. 

Edit:

Crap now it worked. geez...thank you for making me try that again. It works now. 

Edited by Caspian Dionysus
Link to comment
Share on other sites

1 minute ago, KT Kingsley said:

I think it's telling you that the variable Trin is undefined in this section of script. Presumably it does get defined somewhere in the full script?

For whatever reason it didn't give me that error again when I removed it. lol  so your suggestion worked. Thank you!

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 634 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...