Jump to content

Help with Link_Message in script


SusieQ Ragu
 Share

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

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

Recommended Posts

Can anyone help with this script?  I've combined a random sound script found in our inventory for sea gulls with another script used in an AVsitter project.  It all works fine until it inserted the Link_Message function which should send the code that will set different sound levels for predetermined conditions outside of the script.  I've tried placing the Link_message in several different locations with no success...I always get a syntex error.  Would appreciat any help:

//integer msglinknum = 222333; open for testing
integer sounds = 0; // number of sounds in inventory
integer random;
string sound; // sound name
integer n; // loop counter variable
list soundnames;
//string msg; open for testing
LoadSounds()
{
//    msg = "1"; open for testing
    soundnames = [];
    sounds = llGetInventoryNumber( INVENTORY_SOUND );
    for ( n=0; n < sounds; ++n )
    {
        soundnames += llGetInventoryName( INVENTORY_SOUND, n );
    }   
}

default
{
    state_entry()
   {
   
        LoadSounds();
        llSetTimerEvent( 1.0 );
    }


    timer()
   {
        random = (integer) llFrand ( sounds );
        sound = llList2String( soundnames, random );
   
        for (n = 0; n < 5; n++) // Where 10 is the number of times to repeat.
{
    link_message(integer sender, integer num, string msg, key id){
     if(num==222333){
       
 
 
        if(msg=="1"){
           llTriggerSound(sound, .75);
        }
           else if(msg=="2"){
           llTriggerSound(sound, .50);
        }   
         else if(msg=="3"){
           llTriggerSound(sound, .25);
        }

             else if(msg=="MOOR"){
           llTriggerSound(sound, 1.0);
        } 
                     else if(msg=="OFF"){
            llStopSound( );
           
    }     
   
    }
        llSetTimerEvent( 10.0 + (llFrand(5.0)) );
    }
   
    changed (integer change)
    {
        if (change & CHANGED_INVENTORY)
        {
            LoadSounds();
        }
    }
}

   

Link to comment
Share on other sites

The problem is that link_message is not a function.  It is an event that receives a message that was generated by the llMessageLinked function in a different script.   Take a look >>> http://wiki.secondlife.com/wiki/LlMessageLinked

You are getting a severe syntax message because you are trying to put a link_message event inside your timer event --- a no-no.  You can send each of those captialized code words in separate llMessageLinked statements if you like, and then let the other script receive and act on them in its link_message event.

Link to comment
Share on other sites

I think this might be what you were trying to accomplish;

float volume = 1.0;default {    state_entry() {        llSetTimerEvent( .1 );    }    timer() {        integer random = (integer)llFrand(llGetInventoryNumber(INVENTORY_SOUND));        integer n;        do {           llTriggerSound(llGetInventoryName(INVENTORY_SOUND, random), volume);        } while (++n < 5);  // Where 5 is the number of times to repeat.                llSetTimerEvent( 10.0 + (llFrand(5.0)) );    }            link_message(integer sender, integer num, string msg, key id) {        if(num == 222333){            llSetTimerEvent( .1 );            if(msg=="1"){               volume = .75;            }            else if(msg=="2"){               volume = .50;            }               else if(msg=="3"){               volume = .25;            }            else if(msg=="MOOR"){               volume = 1.0;            }             else if(msg=="OFF"){                llSetTimerEvent( .0 );            }          }    }}

 

Link to comment
Share on other sites

  • 2 weeks later...
You are about to reply to a thread that has been inactive for 3511 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...