Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Filtering Link_messages

Lyndzay Meili
Registered User
Join date: 2 Sep 2007
Posts: 28
08-24-2008 11:37
Hi there,

I'm using messagelinked to pass dialog choices between scripts in the same prim and when I was passing one string it was fine, now I need to pass two different strings that replace different strings and I am having some problem understanding how to filter the responses

Menu script:
php

<snip>
send_anim(string anim)
{
llMessageLinked(LINK_THIS,1,(string)anim,NULL_KEY);
}

send_ammo(string ammo)
{
llMessageLinked(LINK_THIS,2,(string)ammo,NULL_KEY);
}

<snip>
(from one dialog page)

if(msg=="Huge";)
{
llOwnerSay(name + " changed the pose to ' " + msg + " '.";);
send_anim ("100m";);
state main_menu;
}


<snip>
(from another dialog page)

if(msg=="Waffles";)
{
llOwnerSay("Yummy waffles....nom, nom, nom!";);
send_ammo ("Waffles";);
state main_menu;
}
else if(msg=="Toast";)
{
llOwnerSay("Get you flaming toast here!";);
send_ammo ("Toast";);
state main_menu;
}
/php
Then in the receiving script. This is how I had it when I was just changing one string
php
link_message(integer sender_num,integer num, string str, key id)
{
gAnim=((string)str);
arm();
}



/php

The second message would contain

{
gBulletName=((string)str);

}

I'm not sure how to filter the sent messages so it will keep info and not reset the other each time you call up the dialog box. ( I set the pose in one click then when I go to change the ammo it resets the pose to the one I set in globals as default. This didn't happen when I had just one linked message, I could detach and reattach and it would keep the menu chosen pose)

I don't think an if statement works best since I need the options of both inputs since one controls the animation and one controls the ammo.


I hope I made that as clear as I could :) any help is greatly appreciated.

Thx
Lyndz~
_____________________
"Be who you are and say what you feel, because those who matter don't mind, and those that mind, don't matter."
—Dr. Seuss
Ron Khondji
Entirely unlike.
Join date: 6 Jan 2007
Posts: 224
08-24-2008 12:23
Why not make use of the key part of llMessageLinked.
Jahar Aabye
Registered User
Join date: 14 Mar 2007
Posts: 58
08-24-2008 12:56
There are three variables in llMessageLinked():

an INTEGER
a STRING
and a KEY

Another way to look at it is that this function allows you to pass three different pieces of information. The way your system is set up, you are only passing a single piece of information in each linked message.

I'm not going to give you step-by-step instructions, trust me, it's much better for you in the long run that you figure this out yourself. However, I will give you two hints:

An integer can often be thought of as a switch, if (num == 1){do(something)}

A string can be implicitly cast to a key, which in English means that you can really use a second string in this function without even having to cast it to a key. However, note that the link_message event *will* receive it as a key, and thus it *will* need to be re-cast in that event when received.
Lightwave Valkyrie
Registered User
Join date: 30 Jan 2004
Posts: 666
08-24-2008 21:31
in your receiving script

php
link_message(integer sender_num,integer num, string str, key id)
{
if (num ==1)
}
gAnim=(str);
arm();
}
if (num ==2)
{
gBulletName=(str);

}
else
{//something else in num so do here}
}
/php
_____________________
L$ is the root of all evil
videos work! thanks SL :)