Jump to content

how do i Listen two channel message then add them


nae8ean
 Share

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

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

Recommended Posts

how do i Listen two channel message then add them  example on channel 1 message is 1 on channel 2 message is `1 also

i want to add both channel message using llSay something like this llSay( 0, message+message ); but it only read channel 1 can't read channel 2 :(

any idea a simple addition on deiffrent channel ?

Link to comment
Share on other sites

I don't quite understand what you are asking, but let me try a very simple example anyway ...

 

integer gChan1 = -12345;integer gChan2 = -67890;string gMess1;string gMess2;default{    state_entry()    {        llListen(gChan1,"","","");        llListen(gChan2,"","","");    }    listen (integer channel, string name, key id, string message)    {        if (channel == gChan1)        {            gMess1 = message;        }        else if (channel == gChan2)        {            gMess2 = message;        }        if (gMess1 != "" && gMess2 != "")        {            llSay(0,gMess1 + " " + gMess2);            gMess1 = "";            gMess2 = "";        }    }}

The scripting isn't hard, once you figure out what you want to do and can explain it clearly to yourself.

  • Like 1
Link to comment
Share on other sites

wow thank you thats what i need i change a little bit to your work that 

llSay(0,gMess1 + " " + gMess2); //result if both channel send 1 is 1 1 it should be 2 to do that i make string and integer to add them up

i have another question if sender is from getobjectdetail from two channel and add them up like what we did on 2 channel message difference is it came from object details any idea?

Link to comment
Share on other sites


nae8ean wrote:

[ .... ] 

i have another question if sender is from getobjectdetail from two channel and add them up like what we did on 2 channel message difference is it came from object details any idea?

I don't understand the question.

Link to comment
Share on other sites

Round off to the nearest tens?  I wasn't expecting that question. :smileyvery-happy:

I won't ask why you want to do that.

 

float Smaller = Original_number / 10.0;integer Rounded = llRound(Smaller);integer Final_number = Rounded * 10;

 

  • Like 1
Link to comment
Share on other sites

integer gChan1 = -12345;integer gChan2 = -67890;string gMess1;string gMess2;default{state_entry(){llListen(gChan1,"","","");llListen(gChan2,"","","");}listen (integer channel, string name, key id, string message){if (channel == gChan1){gMess1 = message;}else if (channel == gChan2){gMess2 = message;}if (gMess1 != "" && gMess2 != ""){string strch1 = gMess1;string strch2 = gMess2;integer ich1 = strch1;integer ich2 = strch2;Original_number = (ich1+ich2);float Smaller = Original_number / 10.0;integer Rounded = llRound(Smaller);integer Final_number = Rounded * 10;llSay(0,Final_number);gMess1 = "";gMess2 = "";}}}

 

What do u think is the problem here to make it round off to nearest tens? all bold letters i added and modify .

Link to comment
Share on other sites

I should not be writing your script for you.  That is your job.  So far, however, the only parts of this script that work correctly are the parts that I wrote while answering your questions. So, let's see if you can figure out this part yourself:

string strch1 = gMess1;string strch2 = gMess2;integer ich1 = strch1;integer ich2 = strch2;Original_number = (ich1+ich2);

Why are you creating new variables called strch1 and strch2?

How can an integer like ich1 or ich2 be the same as a string variable? How do you convert a string to an integer?

What type of variable is Original_number?

Finally, how are you going to use llSay to tell you the value of Final_number?

Hint >>> Try reading http://wiki.secondlife.com/wiki/Typecast

  • Like 1
Link to comment
Share on other sites

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