|
Merci de ta réponse et de ton aide MenthalOh ;-)
Oui donc a première vue je ne suis pas sur la bonne piste , j'ai donc tenté ta proposition bon on va dire que j'ai une légère amélioration la , au moins le tiroir ne cherche plus a s'ouvrir deux fois si je sélectionne une catégorie déjà sélectionné mais malgré tout il se referme ....bon , après il ne communique plus avec chaque tiroirs mince .....
voila ou j'en suis arrivé :
key GRID_TEX = "87dfd082-f83b-673b-e86b-5fa2d64bedf8";
string active_texture; integer tex_total; integer page_total; integer current_page = 1; integer display_total; integer active; integer preview1; integer preview2; list displays;
LOAD_DISPLAYS(list data) { displays = []; integer i; display_total = llGetListLength(data); for(i=0; i<display_total; i++) { displays += (integer)llList2String(data, i); } }
list GET_LINK_NAMES() { list names = [""]; integer i; integer len = llGetNumberOfPrims(); for(i=1;i<=len;i++) { names += [llGetLinkName(i)]; } return names; }
GET_PREVIEWS() { list links = GET_LINK_NAMES(); displays = []; integer done; integer i = 1; preview1 = llListFindList(links, ["PREVIEW1"]); preview2 = llListFindList(links, ["PREVIEW2"]); }
LOAD_TEXTURES() { tex_total = llGetInventoryNumber(INVENTORY_TEXTURE); if(tex_total == 0) return; page_total = (integer)llCeil((float)tex_total / display_total); }
SET_INDICATOR(vector color) { llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_COLOR, ALL_SIDES, color, 1.0, PRIM_COLOR, 0, <1,1,1>, 1.0]); }
LOAD_PAGE() { integer i; integer offset = (current_page-1) * display_total; integer link; key texture; for(i=0;i<display_total;i++) { link = llList2Integer(displays, i); texture = GRID_TEX; if((i+offset+1) <= tex_total) { texture = llGetInventoryKey(llGetInventoryName(INVENTORY_TEXTURE, i+offset)); } llSetLinkPrimitiveParamsFast(link, [PRIM_TEXTURE, 0, texture, <1,1,0>, <0,0,0>, 0]); //llSetLinkPrimitiveParamsFast(link, [PRIM_TEXT, (string)(i+offset+1), <1,1,1>, 1.0]); } string text = "Displaying " + (string)(((current_page-1) * display_total)+1) + "-"; if((current_page * display_total) > tex_total) text += (string)tex_total; else text += (string)(current_page * display_total); text += " of " + (string)tex_total + " textures"; llSetLinkPrimitiveParamsFast(LINK_ROOT, [PRIM_TEXT, text, <1,1,1>, 1.0]); llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_TEXT, llGetObjectDesc(), <1,1,1>, 1.0]); }
SET_PREVIEW(integer index) { integer offset = (current_page-1) * display_total; key texture = GRID_TEX; if((index+offset+1) <= tex_total) { active_texture = llGetInventoryName(INVENTORY_TEXTURE, index+offset); texture = llGetInventoryKey(active_texture); } if(preview1 == 0 || preview2 == 0) { GET_PREVIEWS(); } llSetLinkPrimitiveParamsFast(preview1, [PRIM_TEXTURE, 0, texture, <1,1,0>, <0,0,0>, 0]); llSetLinkPrimitiveParamsFast(preview2, [PRIM_TEXTURE, 0, texture, <3,3,0>, <0,0,0>, 0]); }
default { state_entry() { llSetTimerEvent(1); GET_PREVIEWS(); } link_message(integer link, integer num, string query, key data) { if(link == LINK_ROOT) { if(query == "SEND DISPLAY DATA") { llSetTimerEvent(0); LOAD_DISPLAYS(llCSV2List(data)); state loading; } } } timer() { llSetTimerEvent(0); llMessageLinked(LINK_ROOT, 0, "REQUEST DISPLAY DATA", ""); } }
state loading { state_entry() { LOAD_TEXTURES(); if(tex_total == 0) SET_INDICATOR(<1,0,0>); else { state ready; } } link_message(integer link, integer num, string query, key data) { if(link == LINK_ROOT) { if(query == "SEND DISPLAY DATA") { LOAD_DISPLAYS(llCSV2List(data)); return; } if(query == "SET ACTIVE") { llOwnerSay("No textures in this category"); } } } changed(integer change) { if(change & CHANGED_INVENTORY) { LOAD_TEXTURES(); if(tex_total != 0) state ready; } } }
state ready { state_entry() { string desc = llList2String(llGetLinkPrimitiveParams(LINK_ROOT, [PRIM_DESC]), 0); if((integer)desc == llGetLinkNumber()) { active = TRUE; llMessageLinked(LINK_ALL_OTHERS, 0, "SET ACTIVE", ""); current_page = 1; LOAD_PAGE(); SET_PREVIEW(0); } else { SET_INDICATOR(<1,1,0>); } } link_message(integer link, integer num, string query, key data) { if(link == LINK_ROOT) { if(query == "SEND DISPLAY DATA") { LOAD_DISPLAYS(llCSV2List(data)); return; } if(query == "RESET") { llResetScript(); return; } if(query == "SEND PREVIEW DATA") { list previews = llCSV2List(data); preview1 = (integer)llList2String(previews, 0); preview2 = (integer)llList2String(previews, 1); return; } if(query == "SET PREVIEW") { SET_PREVIEW(num); return; } if(query == "GIVE TEXTURE") { llGiveInventory(data, active_texture); return; } } if(query == "SET ACTIVE") { if(link == LINK_ROOT) { if(active==FALSE) { llOwnerSay("tirroir 1, je suis le tiroir selectionné , je m'ouvre" ); llSetPos(llGetLocalPos()+<0.5,-0.5,0>); SET_INDICATOR(<0,1,0>); //vert active = TRUE; current_page = 1; LOAD_PAGE(); SET_PREVIEW(0); llMessageLinked(LINK_ALL_OTHERS, 0, "SET ACTIVE", ""); } else { if(active==TRUE) { //tirroir fermé llOwnerSay("tiroir1, tu as changé de catégorie , je me ferme" ); llSetPos(llGetLocalPos()+<-0.5,0.5,0>); SET_INDICATOR(<0.009909,0.062843,0.990091>); //bleu active = FALSE; } } }
return; } if(query == "BUTTON") { if(data == "FIRST") current_page = 1; else if(data == "PREV") current_page--; else if(data == "NEXT") current_page++; else if(data == "LAST") current_page = page_total; if(current_page <= 0) current_page = page_total; if(current_page > page_total) current_page = 1; LOAD_PAGE(); } } changed(integer change) { if(change & CHANGED_INVENTORY) { LOAD_TEXTURES(); if(active == TRUE) { if(tex_total == 0) state loading; else { LOAD_PAGE(); } } } else if(change & CHANGED_LINK) { GET_PREVIEWS(); } } }
et plus précisément j'ai modifié cette partie :
if(query == "SET ACTIVE") { if(link == LINK_ROOT) { if(active==FALSE) { llOwnerSay("tirroir 1, je suis le tiroir selectionné , je m'ouvre" ); llSetPos(llGetLocalPos()+<0.5,-0.5,0>); SET_INDICATOR(<0,1,0>); //vert active = TRUE; current_page = 1; LOAD_PAGE(); SET_PREVIEW(0); llMessageLinked(LINK_ALL_OTHERS, 0, "SET ACTIVE", ""); } else { if(active==TRUE) { //tirroir fermé llOwnerSay("tiroir1, tu as changé de catégorie , je me ferme" ); llSetPos(llGetLocalPos()+<-0.5,0.5,0>); SET_INDICATOR(<0.009909,0.062843,0.990091>); //bleu active = FALSE; } } }
|