Jump to content

Question about channels...


IsabellaRose Fallen
 Share

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

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

Recommended Posts

I do believe that channel settings are my problem, I just don't know how to fix it...

The script I have (a sippy cup menu) works beautifully -- the person who clicks on the cup chooses a drink, and it posts a short message in local chat ('so-and-so has filled so-and-so's cup with yummy milk', for example). The problem is that if anyone ELSE nearby is holding ANOTHER cup with the same script inside, it will also change THEIR drink, with the same message. Since I'm wanting to release a new line of cups where the 'liquid' inside is actually visible and will change depending on the drink, I would really like to figure out this problem...like I said, I'm fairly certain it's something to do with channels? Here is the script in question, for reference:

integer channel;

string FirstName( string name )
{
    list name_part = llParseString2List( name, [" "], [] );
    return llList2String( name_part, 0 );
}

integer listen_handle; 

default
{
    state_entry()
    {
        channel = 65536 + (integer)llFrand( 10000000 );
        listen_handle = llListen(channel,"",NULL_KEY,"");  
    }
    
    touch_start(integer total_number)
    {
        string my_name = llKey2Name( llGetOwner() );
        string my_first_name = FirstName( my_name );
        llDialog(llDetectedKey(0),"What would you like to fill "+ my_first_name +"'s cup with? There is:"
       ,["Grape Juice","Apple Juice","Orange Juice","Lemonade","Milk", "Choc Milk","Soda","Ask Mommy","Ask Daddy"],channel);
        
    }
        
    listen(integer channel,string name, key id, string msg)
    {
        string my_name = llKey2Name( llGetOwner() );
        string my_first_name = FirstName( my_name );
        string toucher_name = name;
        string toucher_first_name = FirstName( toucher_name );
        
        string old_object_name = llGetObjectName();
        llSetObjectName( toucher_first_name );            
        
        if (msg=="Apple Juice"){ llSay(0, "/me goes to fill "+my_first_name+"'s sippy cup with apple juice. "+my_first_name+" looks excited and thanks you. ");} 
        if (msg=="Grape Juice"){ llSay(0, "/me pulls off the top and pours in some grape juice for "+my_first_name+". Once finished they place the lid back on and smile ");} 
        if (msg=="Orange Juice"){ llSay(0, "/me gets fresh orange juice for "+my_first_name+". "+my_first_name+" thanks you. ");} 
        if (msg=="Lemonade"){ llSay(0, "/me nods and fills "+my_first_name+"'s cup up to the brim with lemonade. Then asks, 'Do you want anything more?' ");} 
if (msg=="Soda"){ llSay(0, "/me takes "+my_first_name+"'s cup and fills it with soda. "+my_first_name+"'s smiles in gratitude. ");} 
if (msg=="Milk"){ llSay(0, "/me filles "+my_first_name+"'s with just the right amount of milk. "+my_first_name+" takes a sip and thanks you with a sweet smile. ");} 
if (msg=="Choc Milk"){ llSay(0, "/me mixes up some chocolate milk and fills "+my_first_name+"'s cup...yummy! ");}
if (msg=="Ask Mommy"){ llSay(0, ""+my_first_name+" holds up their sippy cup, asking Mommy if she would please fill it up with something yummy! ");}
if (msg=="Ask Daddy"){ llSay(0, ""+my_first_name+" holds up their sippy cup, asking Daddy if he would please fill it up with something yummy! ");}
        
        llSetObjectName( old_object_name );
    }
}

I'll be making quite a few simple little additions with the new line that I have coming out, and I can handle them on my own. But that one little issue is probably the most important, in my opinion, and I'd REALLY appreciate any help with figuring it out! Thank you all in advance =)

Link to comment
Share on other sites

You need to capture the "cup" UUID "object key. You could just paste and copy it into the script above for now, the cup transmits it UUID and what to idk add milk then the main script transmits but only the the matching UUID will do what ever.

cup fill me up "object key", main transmits message, all cups with diferent uuid ignore the message.

Link to comment
Share on other sites

You're actually doing it correctly.  The channel is assigned a random integer value when the script resets, so you should never have two instances of the same cup listening to each other.  Each one should be sending and receiving dialog chat on its own private channel.  If you do have crosstalk problems, the only reason that occurs to me is that you are drag/copying the cups and never resetting the script of the new copy.  That shouldn't be possible, but it is.

You can approach this in several ways. You could move the stuff that is now in the state_entry event into the touch_start event instead, so that the channel is redefined every time someone touches the cup.  If you do that, you'll want to start the event with a line that says llListenRemove(listen_handle), so that you don't leave previous channels open.

Another possibility, unless you expect one owner to have several cups, is to force the script to reset if the cup changes ownership.  Use a changed event and look for if (change & CHANGED_OWNER).

Of course, you could also simply put the llResetScript() statement into an on_rez event and then force the owner to rez a new copy by destroying any previously rezzed one if the owner leaves the region.  ( Try using a test like if (llGetAgentSize(llGetOwner()) == ZERO_VECTOR) {llDie();} )

So many possibilities .....

  • Like 1
Link to comment
Share on other sites


Rolig Loon wrote:

If you do have crosstalk problems, the only reason that occurs to me is that you are drag/copying the cups and never resetting the script of the new copy.  That shouldn't be possible, but it is.

In fact, it would never have occurred to me that it could happen -- I could have had the very same bug -- so now I'm curious: Do we have any idea of the circumstances under which a copy can be made without scripts being reset?

 

Link to comment
Share on other sites

I wish I did.  I have never had it happen to me, but I have had this conversation with a couple of other scripters in the past who swear that they have had a drag/copy fail to reset. I remember looking for a JIRA once but not finding anything.  A script is supposed to reset when a new copy is created.

  • Like 1
Link to comment
Share on other sites

That is not strictly true, it is always best to do a manual reset on copied scripts. Sometimes even working on a script in world and finding one has added an error, removing the error compile it still will not work ever after doing a reset. End up having to do a copy and paste as a new script.

Link to comment
Share on other sites


steph Arnott wrote:

That is not strictly true, it is always best to do a manual reset on copied scripts. [ .... ]

That's probably a good precaution, if only to be sure that you have copied it correctly, but you're describing a somewhat different situation than the one that Qie and I are concerned about.  We are talking about what happens when you hold down the Shift key and drag to copy an object that has a script in it.  The script is supposed to reset in the new, copied object.  It has always worked that way for me, and Qie is saying the same thing.  I have talked with one or two scripters in the past, however, who say that they have had a script fail to reset.  I consider that unlikely, but stranger things have happened in Second Life so I can't swear that it is impossible.

Link to comment
Share on other sites

Yes i know, problem is if the original was heavily worked on it seems to also have  bits in it that cause the copy to not function as a clean script. I have no idea why, but i have had the problem as well, as soon as thet finished script is copy and pasted as a new script the intermitant or reset problems do not happen. Its as if info is still there but you can not see it.

Link to comment
Share on other sites

Sometimes, Rolig, when I've copied an object, I have forgotten which I still have selected. The original or the copy. Do you suppose these other scripters you remember, forgot that they had the original still selected and that the original is what moves when you shift copy? The copy might have still reset.

Link to comment
Share on other sites

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