Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Multiple listen()-events possible

Tomfox Wiranata
Registered User
Join date: 20 Dec 2006
Posts: 80
01-01-2007 09:56
Hi Everybody!

When a resident touches my object a dialog opens with 12 button. I wrote a function for each single button. Via a listen() event i can control which button is pressed an open the regarding function.

but in between those function i also wanna listen to user inputs via chat. do i have to use the already existing listen() event? cause if i define a new listen() event in my functions i'll get an error.

CODE



integer i;
integer spieleBisher = 0;
integer maxSpiele;
integer channelChoosing = 1; // dialog channel
list NUMBER_OF_PLAYCARDS = ["10","15","20","7","8","9","4","5","6","1","2","3"]; // the main menu
list NUMBERS = ["1","2","3"];
string playername;





getNumbersForOne()
{
llListen(100, "", NULL_KEY, ""); // listen for numbers
maxSpiele = 0;


for(i=1; i<=6; i++)
{

llSay(0,"Please choose your " +(string) i+ ". Number");

listen(integer channel, string name, key id, string message) {
if (llListFindList(NUMBERS, [message]) != -1)
llSay(100,"U chose number "+ message);

} //listen


}//for



}//getNumbersForOne




default
{


state_entry()
{

llListen(50, "", NULL_KEY, ""); // listen for dialog answers (from multiple users)
}


touch_start(integer total_number)
{
string name = llDetectedName(0);
playername = name;

llSay(0,"Hello"+ (string) playername);
llDialog(llDetectedKey(0), "How many playcards would you like to buy?", NUMBER_OF_PLAYCARDS, 50); // present dialog on click


}


listen(integer channel, string name, key id, string message)
{


if (llListFindList(NUMBERS, [message]) != -1)
llSay(0,"Sie haben die Nummer " +message);




if (llListFindList(NUMBER_OF_PLAYCARDS, [message]) != -1) // verify dialog choice
{
llSay(50, name + " wants to buy '" + message + " playcard"); // output the answer
if (message == "1")
{
getNumbersForOne();
//integer ergebnis = getNumbers(1);
//llSay(0,(string) ergebnis);
}

} else
llSay(50, name + " picked invalid option '" + llToLower(message) + "'."); // not a valid dialog choice
}//listen






}//default



thx so much. i am driving nuts....
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
01-01-2007 10:41
This probably should have been posted in Scripting Tips.

In answer to your actual question, yes, you have to use just one listen event handler and use the channel and other parameters it gets to work out which listener activated.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
01-01-2007 13:36
*pokes the thread a few times till it moves to Script Tips*

EDIT: oops and moves back

If you want to respond to this thread please see:
/54/80/157957/1.html
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey