Jump to content

linked scripts not talking =(


nycbard
 Share

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

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

Recommended Posts

Hi, i made an on-ine statue indicator for staff boards. The staff board works correctly, displaying the staff member's profile image and their on-ine status.

My issue is that during a one of my (if..else) loops, I am not having communication. The ROOT prim/script should be sending a number (either a 1 or a 0) to a CHILD prim/script. When the message is recieved a texture is changed.

 

dataserver(key queryid, string data)
    {
        if ( data == "1" )
        {
            status = " is online";

            llSetText(name + status, <0,1,0>, 1.0);
            llMessageLinked(integer LINK_SET, integer 1, "", "");
        }
        else if (data == "0")
        {
            status = " is offline";

		llSetText(name + status, <1,0,0>, 1.0);
		llMessageLinked(integer LINK_SET, integer 0, "", "");
        }

 That is the code of the dataserver in the ROOT prim/script

default
{
    state_entry()
	{
		link_message(integer sender_number, integer number, string message, key id)
		{
			if ( sender_number == "1" ){
				fliptexture(AVAILABLE);
			}
			else if ( sender_number == "0"){
				fliptexture(UNAVAILABLE);
			}				
		}
    }
}

 This is my CHILD prim/script

I think my error is how i'm passing the info, but i can't seem to get it. All the help is greatly appreciated

Link to comment
Share on other sites

I don't like the syntax of your calls to llMessageLinked. I think you meant to say the following. The way you had it you were declaring LINK_SET to be an integer. (and 0 to be an integer). If this syntax works, it declares a new integer with the name of the LINK_SET defined constant, and new integers always start out with the value 0. (I don't have any idea what declaring 0 to be a new integer variable will do).

llMessageLinked(LINK_SET,0, "", "");
  • Like 1
Link to comment
Share on other sites

I'm very suprised this compiles but not that it fails to work as expected.

http://wiki.secondlife.com/wiki/LlMessageLinked

You need to include an INTEGER that is the link-number(s) addressed by the message and an INTEGER, STRING and KEY that are the parts of the message.

 

llMessageLinked(integer LINK_SET, integer 1, "", "");

 Is OK for the STRING and KEY (although technically keys and strings are different so it 'should' be NULL_KEY or similar) but for your two INTEGERS you are incorrectly and invalidly including the word 'integer'.  You only need the 'LINK_SET' and '1'/'0'

llMessageLinked(LINK_SET, 1, "", "");

Now you have several problems with how that message is received:

Firstly 'if(sender_number == "1")' is comparing the INTEGER 'sender_number' with the STRING (because it's in quotes) "1"

Don't worry too much about that because you're checking the wrong thing anyway ... sender_number is the link-number for the prim that sent the message, instead of what number was sent IN the message.  You need to check

if(number == 1) ... else if(number == 0)

  • Like 1
Link to comment
Share on other sites

Now that you have the llMessageLinked syntax figured out, get rid of it.  If all you are doing is changing a texture in the other prim, use llSetLinkTexture.  That lets you change the texture in the other prim directly and it gets rid of an unnecessary script in that prim too.

Link to comment
Share on other sites

I'm actually surprised no-one else caught that your child script has the link_message() event handler INSIDE your state_entry().  That won't work.

 

Your child script should be laid out like so:

 

default{    state_entry()    {    }    link_message(integer sender_number, integer number, string message, key id)    {	if ( number == 1 ){		fliptexture(AVAILABLE);	}	else if ( number == 0){		fliptexture(UNAVAILABLE);	}				    }}

 

Link to comment
Share on other sites

Since you know that the query will return either 0 or 1 as a string, you can do it with llSetLinkTexture very easily:

 

list textures=["uuid of offline texture","uuid of online texture"];

 and then, 

dataserver(key requested, string data)	{		if (requested == query){		llSetLinkTexture(2,llList2Key(textures,((integer)data)),ALL_SIDES);		}	}

 

Link to comment
Share on other sites

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...