Bonjour,
je propose :
si l'owner touche, il a un premier llDialog avec 2 boutons : options et texture.
si il clic sur texture, il entre dans le circuit précèdent.
si il clic sur option, il a alors le choix entre Owner, group et all.
Si un non Owner touche, en fonction du choix ci-dessus, il obtient soit un message de restriction, soit le choix des textures.
un non Owner, ne voit pas "Option".
Ca me parait bien.
Si je me trompe pas, ca donne ce nouveau script de commande :
integer iSecuCode;
// 0 = Owner only
// 1 = Group
// 2 = All
string sTEXTURE = "Texture";
string sOPTION = "Option";
string sOWNER = "Owner only";
string sGROUP = "Group";
string sALL = "All";
////////////////////////////////////////
string sNEXT = ">>";
string sPREV = "<<";
string STOP = "STOP";
string sTEXTE = "\nChoix de la texture";
float fTIMEOUT = 30.0;
////////////////////////////////////////
string sPLANCHER = "plancher";
integer iEcoute;
list lTextures;
integer iIndexMenu;
integer iNbTexture;
key kOwner;
integer iCanal;
init() {
iSecuCode = 2;
kOwner = llGetOwner();
FaireList();
}
FaireList() {
integer i;
iNbTexture = llGetInventoryNumber(INVENTORY_TEXTURE);
lTextures = [STOP];
for(; i<iNbTexture; ++i) {
string nom = llGetInventoryName(INVENTORY_TEXTURE, i);
if (llStringLength(nom) < 24)
lTextures += [nom];
else llOwnerSay("La texture \"" + nom + "\"porte un nom trop long et ne sera pas prise en compte");
}
}
///
navigation(string browse, key id) {
// Nombre de boutons
integer n = llGetListLength(lTextures);
// Navigation simple pour deux pages
if(n < 23) {
if(iIndexMenu) iIndexMenu = 0;
else iIndexMenu = 11;}
// Navigation riche pour plus de deux pages
else {
if(browse == sNEXT) {
iIndexMenu += 10;
if(iIndexMenu >= n) iIndexMenu = 0;}
else {
iIndexMenu -= 10;
if(iIndexMenu < 0) iIndexMenu = n - n % 10;}
}
// Envoi du menu
Menu(id);
}
// -- Gestion menu --
Menu(key id) {
startEcoute(id); // Liste globale des boutons
list lBoutons = lTextures;
// Nombre total de boutons
integer n = llGetListLength(lTextures);
// Si plusieurs pages
if(n > 12) {
// Que 2 pages -> navigation simple
if(n < 23) {
// Deuxième page
if(iIndexMenu)
lBoutons = [sPREV] + llList2List(lTextures, iIndexMenu, -1);
// Première page
else
lBoutons = llList2List(lTextures, 0, 1) + [sNEXT] + llList2List(lTextures, 2, 10);}
// Plus de 2 pages -> navigation riche
else {
list l = [sPREV, llList2String(lTextures, iIndexMenu), sNEXT];
// Première page ou page intermédiaire
if(n - iIndexMenu > 10)
lBoutons = l + llList2List(lTextures, iIndexMenu + 1, iIndexMenu + 9);
// Dernière page
else {
if(iIndexMenu + 1 < n)
lBoutons = l + llList2List(lTextures, iIndexMenu + 1, -1);
else lBoutons = l;}
}
}
// Envoi du menu
llDialog(id, sTEXTE, lBoutons, iCanal);
}
MainMenu(key id) {
startEcoute(id);
llDialog(id, "Votre choix", [sTEXTURE, sOPTION], iCanal);
}
startEcoute(key id) {
llSetTimerEvent(fTIMEOUT);
iCanal = (integer)llFrand(-100000);
iEcoute = llListen(iCanal, "", id, "");
}
cancelMenu() {
llSetTimerEvent(0.0);
llListenRemove(iEcoute);
}
finMenu() {
llOwnerSay("trop tard. Menu desactivé");
cancelMenu();
}
///
SendTexture(string texture) {
key uuidtexture = llGetInventoryKey(texture);
llMessageLinked(LINK_SET, 47, sPLANCHER, uuidtexture);
}
ValidGroup() {
list l = llGetObjectDetails(llGetKey(), [OBJECT_GROUP]);
key group_maison = llList2Key(l,0);
if(group_maison != NULL_KEY) iSecuCode = 1;
else llSay(0, "Groupe non defini, réglage annulé");
}
default
{
state_entry()
{
init();
}
touch_start(integer total_number)
{
key user = llDetectedKey(0);
if (user == kOwner) MainMenu(kOwner);
else { // pour les autres que le Owner
if(!iSecuCode) {// 0 = Owner only
llSay(0, "Acces limité a l'Owner");
}
else if(iSecuCode == 1) { // 1 = Group
if(llSameGroup(user)) { // et group OK
Menu(user);
}
else llSay(0, "Acces limité au group"); // group nok
}
else if(iSecuCode == 2) Menu(user); //2 = All
}
}
changed(integer c)
{
if(c & CHANGED_INVENTORY) FaireList();
if(c & CHANGED_OWNER) kOwner = llGetOwner();
}
listen(integer channel, string name, key id, string message)
{
cancelMenu();
if(~llListFindList([sNEXT, sPREV], [message])) {
navigation(message, id);
}
else if(message == sOPTION) {
llDialog(id, "Réglage", [sOWNER, sGROUP, sALL], iCanal);
}
else if(message == sTEXTURE) {
Menu(kOwner);
}
else if (~llListFindList([sOWNER, sGROUP, sALL], [message])) {
integer index = llListFindList([sOWNER, sGROUP, sALL], [message]);
if (index == 1) ValidGroup();
else iSecuCode = index;
}
else {
SendTexture(message);
}
}
timer()
{
finMenu();
}
}
NB : j'ai fait le choix de laisser libre accès par défaut. Cf 1ere ligne de init()