Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

touch_start event

Tony21 Jonesford
Registered User
Join date: 17 Sep 2007
Posts: 16
09-19-2007 01:22
Hi

I did a script which give landmarks to others users.
When the first user touch my object, a llDialog show a menu (each item of this menu are contain into a notecard named "menu).

The user select an item of this menu.
So an other menu is open (each item of this second menu are into a notecard with the same name of the first item selected in the firt menu).

When the user select an item of the menu 2, a get a landmark with the name of the selected item.

My question is :

With the script below, if a second user touch my object whereas the first user is in the second llDialog. What's happen?

I'm new in scripting, I don't understand when touch_start event finish.

integer channel = 1001;
list malist = [];

string noteCardName = "menu";
key cle;
integer line = 0;
key user;
string entete;

default
{

state_entry()
{
//permet d'écouter sur le cannal 1000
llListen(channel,"", "","";);


}

touch_start(integer total_number)
{
malist = [];
line = 0;
noteCardName = "menu";
entete = "Choose a category";
user = llDetectedKey(0);
//récupère la notecard
cle = llGetNotecardLine(noteCardName,line);


}

//écoute du cannal
listen(integer chan, string name, key id, string mes)
{
if(noteCardName != "menu";)
{

llSay(0,"you chose : " + mes);

//donne l'objet
llGiveInventory(id,mes);
}
else
{


noteCardName = mes;

malist = [];
line = 0;

//récupère la notecard
cle = llGetNotecardLine(noteCardName,line);
}



}

dataserver(key query_id, string data)
{
if(query_id == cle)
{
//si on est pas a la fin de la note card
if(data != EOF)
{

malist += data;

line++;
cle = llGetNotecardLine(noteCardName,line);
}
else
{
if(noteCardName != "menu";)
{
entete = "Choose a lanmark in " + noteCardName;
}
//fait apparaitre une boite de dialogue
llDialog(user,entete,
malist,channel);
}

}
}

}

thanks
Lyn Mimistrobell
(waiting)
Join date: 11 Jan 2007
Posts: 179
09-19-2007 02:22
I don't think that will be a problem since the listen event gets the key for the avatar that selected something from the menu.

In the future... please use english variables and comments. Not just in the forum, but ever :) I'm Dutch but I always use English and it's great for when you give or sell a script full perm :)
Tony21 Jonesford
Registered User
Join date: 17 Sep 2007
Posts: 16
09-19-2007 02:54
but all llDialog are open with llDetectedKey(0)

touch_start event finish when this script enter in the dataserver event or when an user received a landmark?

I think, I don't understand touch_start event.

When the first user touch the object, touch_start event is raise.

But when a second user touch the object? touch_start event is raise too?
Lyn Mimistrobell
(waiting)
Join date: 11 Jan 2007
Posts: 179
09-19-2007 04:17
Oh I'm sorry... I guess I should read all the code instead of just bits of it...

Yes, touch_start is triggered for every AV touching it, even while reading a notecard. Not sure what would be the best approach in this case...

Depending on the number of notecards and entries, I'd prolly read in all the notecards at state_entry. Then if a user touches it, I can show the user that dialog. The listen event gets the id of the AV that clicked a dialog button, so you can use that again to give the landmark or load the next dialog.
Tony21 Jonesford
Registered User
Join date: 17 Sep 2007
Posts: 16
09-19-2007 05:11
but the number of notecards is dynamic.

If I read all notecard in state_entry, I must insert the content of every notecards in different List.


Can I insert List in List?

If Yes. How can I get the item(list) at index x of the list container?

thanks
Tony21 Jonesford
Registered User
Join date: 17 Sep 2007
Posts: 16
09-19-2007 13:32
I saw that it's not possible to insert List in List

so I did my script like below

integer

channel = 1001;
list myList = [];
string noteCardMenu = "menu" ;
key cle;
integer numLine;
string currentNoteCardRead = "";
list menuList = [];
list tempList = [];
list categorieList = [];

integer numMenu;
integer tailleMenu;


list l = [];

default
{


state_entry()
{

//listen cannal 1000
llListen(channel,"", "","";);

numLine = 0;

currentNoteCardRead = noteCardMenu;

cle = llGetNotecardLine(noteCardMenu,0) ;


}

touch_start(integer total_number)
{
//show the menu
llDialog(llDetectedKey( 0),"Choose an option", menuList, channel) ;

}


//listen cannal
listen(integer chan, string name, key id, string mes)
{



integer index = llListFindList( menuList, [mes] );

//it's a categorie
if ( index != -1 )
{
l = [];
integer i;
for(i=0; i< llGetListLength(categorieList);i++)
{
//if is correspond to a subcategorie
if(mes == llList2String(categorieList,i))
{
i++;
l += llList2String(categorieList,i);
}
else
{
i++;
}
}
llDialog(id,"Choose a landmark", l, channel) ;

}
else
{
//give landmark
llSay(0,"you chose : " + mes);

llGiveInventory(id,mes);

}

}

changed(integer change)
{
if(change & CHANGED_INVENTORY)
{
llResetScript();

}
}


dataserver(key query_id, string data)
{

if(query_id == cle )
{

//if this is not the end of the notecard
if(data != EOF)
{

//if read notecard menu
if(currentNoteCardRead == "menu";)
{
menuList += data;
//llSay(0,"categorie : " + data);

}
else
{
tempList += currentNoteCardRead;
tempList += data;
//llSay(0,currentNoteCardRead + " " + data);
}



numLine++;

//get the next line of currentNoteCard read
cle = llGetNotecardLine(currentNoteCardRead,numLine);


}
else
{

//if read notecard menu
if(currentNoteCardRead == "menu";)
{
numMenu = 0;
tailleMenu = llGetListLength(menuList);

currentNoteCardRead = llList2String(menuList,numMenu);
numLine = 0;
tempList = [];

cle = llGetNotecardLine(currentNoteCardRead,numLine);



}
else //add tempList to categorieList
{

//llSay(0,"add to list : " + currentNoteCardRead);

categorieList = llListInsertList(categorieList,tempList,llGetListLength(categorieList));

//llSay(0,"taille liste global " + (string)llGetListLength(categorieList));

numMenu++;
if(numMenu < tailleMenu)
{
currentNoteCardRead = llList2String(menuList,numMenu);
numLine = 0;
tempList = [];

cle = llGetNotecardLine(currentNoteCardRead,numLine);
}



}

}


}

}
}