Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Math Error or What.....?

Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-06-2009 15:08
i'm making this texture hud/organizer ,whatever you want to call it, that takes advantage of the new llDetectedTouchFace function.... i got it all working except, i can't figure out the next/back buttons. it's not changing the texture index that it needs to start with

here's the main script

From: someone

list faces = [3,7,4,6,1];
list links;
integer link = 0;
integer face = 0;
integer FACES;
integer start = 0;
integer end;
integer textnum;
integer texture = 0;
init()
{
links = [];
integer tot = llGetNumberOfPrims();
integer i;
for(i = tot;i > 0; --i)
{
if(llGetLinkName(i) == "Panel#1";)
{
links = links+;
llSetLinkTexture(i,TEXTURE_BLANK,ALL_SIDES);
llSetLinkAlpha(i,0.0,ALL_SIDES);
}
}
for(i = tot;i > 0; --i)
{
if(llGetLinkName(i) == "Panel#2";)
{
links = links+;
llSetLinkTexture(i,TEXTURE_BLANK,ALL_SIDES);
llSetLinkAlpha(i,0.0,ALL_SIDES);
}
}
for(i = tot;i > 0; --i)
{
if(llGetLinkName(i) == "Panel#3";)
{
links = links+;
llSetLinkTexture(i,TEXTURE_BLANK,ALL_SIDES);
llSetLinkAlpha(i,0.0,ALL_SIDES);
}
}
for(i = tot;i > 0; --i)
{
if(llGetLinkName(i) == "Panel#4";)
{
links = links+;
llSetLinkTexture(i,TEXTURE_BLANK,ALL_SIDES);
llSetLinkAlpha(i,0.0,ALL_SIDES);
}
}
for(i = tot;i > 0; --i)
{
if(llGetLinkName(i) == "Panel#5";)
{
links = links+;
llSetLinkTexture(i,TEXTURE_BLANK,ALL_SIDES);
llSetLinkAlpha(i,0.0,ALL_SIDES);
}
}
for(i = tot;i > 0; --i)
{
if(llGetLinkName(i) == "Panel#6";)
{
links = links+;
llSetLinkTexture(i,TEXTURE_BLANK,ALL_SIDES);
llSetLinkAlpha(i,0.0,ALL_SIDES);
}
}
for(i = tot;i > 0; --i)
{
if(llGetLinkName(i) == "Panel#7";)
{
links = links+;
llSetLinkTexture(i,TEXTURE_BLANK,ALL_SIDES);
llSetLinkAlpha(i,0.0,ALL_SIDES);
}
}
for(i = tot;i > 0; --i)
{
if(llGetLinkName(i) == "Panel#8";)
{
links = links+;
llSetLinkTexture(i,TEXTURE_BLANK,ALL_SIDES);
llSetLinkAlpha(i,0.0,ALL_SIDES);
}
}
for(i = tot;i > 0; --i)
{
if(llGetLinkName(i) == "Panel#9";)
{
links = links+;
llSetLinkTexture(i,TEXTURE_BLANK,ALL_SIDES);
llSetLinkAlpha(i,0.0,ALL_SIDES);
}
}
for(i = tot;i > 0; --i)
{
if(llGetLinkName(i) == "Panel#10";)
{
links = links+;
llSetLinkTexture(i,TEXTURE_BLANK,ALL_SIDES);
llSetLinkAlpha(i,0.0,ALL_SIDES);
}
}
FACES = llGetListLength(links)*llGetListLength(faces);
textnum = llGetInventoryNumber(INVENTORY_TEXTURE);
if(textnum <= FACES){ end = textnum+1;}
else {end = FACES+1;}
llOwnerSay("there are " + (string)llGetListLength(links) + " panels";);
llOwnerSay((string)FACES + " faces available ";);
llOwnerSay("Touch Me To Activate";);
}
textureit()
{
integer i;
for (i = start; i < end; i++){
if(face == 5)
{
face = 0;
link++;
}
string name = llGetInventoryName(INVENTORY_TEXTURE,texture);
integer facenum = llList2Integer(faces,face);
integer linknum = llList2Integer(links,link);
if(name != "";)
{
llSetLinkTexture(linknum,name,facenum);
llSetLinkAlpha(linknum,1.0,facenum);
}
else
{
llSetLinkTexture(linknum,TEXTURE_BLANK,facenum);
llSetLinkAlpha(linknum,0.0,facenum);
}
face++;
texture++;
}
llOwnerSay("done texturing";);
}

default
{
state_entry()
{
init();
}
touch_start(integer blah)
{
state display;
}
}
state display
{
state_entry()
{
textureit();
}
link_message(integer sendernum, integer num, string str, key id)
{
if(str == "next";)
{
texture = texture+start;
textureit();
}
else if(str == "back";)
{
texture = texture-start;
if(start <= 0){start = 0;}
textureit();
}
else
{
integer number = (integer)str-1;
string name = llGetInventoryName(INVENTORY_TEXTURE,number+start);
llOwnerSay("Texture Named " + name + " on display number " + str);
}
}
changed(integer change)
{
if(change & CHANGED_INVENTORY)
{
llResetScript();
}
else if (change & CHANGED_LINK)
{
llResetScript();
}
}
}


the panel script (make sure you name each panel "Panel#blah" leaving the number sign in there)

From: someone

list faces = [3,7,4,6,1];
list panelface = [1,2,3,4,5];
integer panelnum;
integer productnum;
string BLANK = TEXTURE_BLANK;
setup()
{
llSetPrimitiveParams([
PRIM_TYPE, PRIM_TYPE_PRISM, PRIM_HOLE_SQUARE, <0.199, 0.8, 0.0>, 0.30,
ZERO_VECTOR, <1.0, 1.0, 0.0>, ZERO_VECTOR,

PRIM_TEXTURE, 1, BLANK, <2.48, 1.0, 0.0>, <-0.740013, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 6, BLANK, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 4, BLANK, <16, 1.0, 0.0>, <-0.2, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 7, BLANK, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 3, BLANK, <2.48, 1.0, 0.0>, <-0.255989, 0.0, 0.0>, 0.0,

PRIM_TEXTURE, 0, BLANK, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 2, BLANK, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 5, BLANK, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,

PRIM_SIZE, <0.03, 2.89, 0.5>
]);
}
default
{
state_entry()
{
setup();
}

touch_start(integer total_number)
{
integer face = llDetectedTouchFace(0);
integer facenum = llListFindList(faces,[face]);
if(facenum != -1)
{
panelnum = (integer)llList2String(llParseString2List(llGetObjectName(),["#"],[]),1);
productnum = llList2Integer(panelface,facenum);
integer addnum = panelnum - 1;
integer add = addnum * 5;
productnum = productnum + add;
llOwnerSay((string)productnum);
llMessageLinked(LINK_ROOT,0,(string)productnum,"";);
}
}
}


and then the button script is simple, just name the button appropriately
From: someone

default
{
touch_start(integer total_number)
{
llMessageLinked(LINK_ROOT,0,llGetObjectName(),"";);
}
}



can anyone figure what i did wrong with that? it can use up to 10 panels as it is written currently

edit: uploaded these pics to give you a general idea of how it looks


Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-06-2009 16:00
alright, i spotted 2 problems, so i modified that, and added an ownersay to make sure it was changing the index, but it doesn't seem to be carrying over when it begins to texture

From: someone

textureit()
{
integer i;
for (i = start; i < end; i++){
if(face == 5)
{
face = 0;
link++;
}
string name = llGetInventoryName(INVENTORY_TEXTURE,texture);
integer facenum = llList2Integer(faces,face);
integer linknum = llList2Integer(links,link);
if(name != "";)
{
llSetLinkTexture(linknum,name,facenum);
llSetLinkAlpha(linknum,1.0,facenum);
}
else
{
llSetLinkTexture(linknum,TEXTURE_BLANK,facenum);
llSetLinkAlpha(linknum,0.0,facenum);
}
face++;
texture++;
}
llOwnerSay("done texturing";);
texture = texture-end;
llOwnerSay((string)texture);
}


From: someone

state display
{
state_entry()
{
textureit();
}
link_message(integer sendernum, integer num, string str, key id)
{
if(str == "next";)
{
texture = texture+FACES;
llOwnerSay((string)texture);
textureit();
}
else if(str == "back";)
{
texture = texture-FACES;
if(texture <= 0){texture = 0;}
llOwnerSay((string)texture);
textureit();
}
else
.....
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-06-2009 16:16
Hi Ruthven,

Your init method would probably be healthier if it looked more like the following...

CODE

init() {
links = [];
integer number = llGetNumberOfPrims();
integer i;
while (number > 0) {
if (llSubStringIndex(llGetLinkName(number), "Panel#") == 0) {
links += number;
llSetLinkTexture(number, TEXTURE_BLANK, ALL_SIDES);
llSetLinkAlpha(number, 0.0, ALL_SIDES);
}
number--;
}
FACES = llGetListLength(links) * llGetListLength(faces);
textnum = llGetInventoryNumber(INVENTORY_TEXTURE);
if(textnum <= FACES){
end = textnum + 1;
} else {
end = FACES + 1;
}
llOwnerSay("there are " + (string)llGetListLength(links) + " panels");
llOwnerSay((string)FACES + " faces available ");
llOwnerSay("Touch Me To Activate");
}

...I have other comments but it's time for FOOD hehe :)
/esc
_____________________
http://slurl.com/secondlife/Together
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-06-2009 16:20
From: Escort DeFarge
Hi Ruthven,

Your init method would probably be healthier if it looked more like the following...

CODE

init() {
links = [];
integer number = llGetNumberOfPrims();
integer i;
while (number > 0) {
if (llSubStringIndex(llGetLinkName(number), "Panel#") == 0) {
links += number;
llSetLinkTexture(number, TEXTURE_BLANK, ALL_SIDES);
llSetLinkAlpha(number, 0.0, ALL_SIDES);
}
number--;
}
FACES = llGetListLength(links) * llGetListLength(faces);
textnum = llGetInventoryNumber(INVENTORY_TEXTURE);
if(textnum <= FACES){
end = textnum + 1;
} else {
end = FACES + 1;
}
llOwnerSay("there are " + (string)llGetListLength(links) + " panels");
llOwnerSay((string)FACES + " faces available ");
llOwnerSay("Touch Me To Activate");
}

...I have other comments but it's time for FOOD hehe :)
/esc


thanks lol, i was gonna get to that when i figured out the next/back button problem, but your method skipped Panel#1???

and i did it that way so it would know which panel is 1st, 2nd,3rd. etc regardless of the link order
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-06-2009 16:38
ok, i'm not sure if you changed it after i responded, i thought i copied and pasted it correctly, but when i went back to look at it in world i noticed the while function was different so here's what i did and it worked
From: Escort DeFarge

CODE

init() {
links = [];
integer number = llGetNumberOfPrims()+1;// added 1 so it would start before the last link because the decrement in the while loop skipped the last link otherwise
integer i;
while (number-- > 0) {//what did i do? lol
if (llSubStringIndex(llGetLinkName(number), "Panel#") == 0) {
links += number;
llSetLinkTexture(number, TEXTURE_BLANK, ALL_SIDES);
llSetLinkAlpha(number, 0.0, ALL_SIDES);
}
//number--;//left this out
}
FACES = llGetListLength(links) * llGetListLength(faces);
textnum = llGetInventoryNumber(INVENTORY_TEXTURE);
if(textnum <= FACES){
end = textnum + 1;
} else {
end = FACES + 1;
}
llOwnerSay("there are " + (string)llGetListLength(links) + " panels");
llOwnerSay((string)FACES + " faces available ");
llOwnerSay("Touch Me To Activate");
}

Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-06-2009 17:10
lol, i'm so retarded, i realized i needed to reset the texture index after it finished texturing all the panels, but i forgot to reset the face and link #'s to 0. got it working perfectly
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-06-2009 22:20
Secondly, you can drop your panel scripts and button scripts (less lag!) if you replace your link_message event in the main script with a functionally equivalent "touch_start" e.g.
CODE

touch_start(integer number) {
string link_name = llToLower(llGetLinkName(llDetectedLinkNumber(0)));
if (link_name == "next") {
texture = texture + start;
textureit();
} else if (link_name == "back") {
texture = texture - start;
if(start <= 0) {
start = 0;
}
textureit();
} else if (llSubStringIndex(link_name, "panel#") == 0) {
integer number = (integer)llGetSubString(link_name, 6, -1) - 1;
string name = llGetInventoryName(INVENTORY_TEXTURE,number + start) ;
llOwnerSay("Texture Named " + name + " on display number " + command);
}
}
_____________________
http://slurl.com/secondlife/Together
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-06-2009 22:21
...and make your changed event a touch more elegant like this...
CODE

changed(integer change) {
if(change & (CHANGED_INVENTORY | CHANGED_LINK)) {
llResetScript();
}
}
_____________________
http://slurl.com/secondlife/Together
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-06-2009 22:26
yep, got that, was also trying to figure out the face touch. using llDetectedTouchFace works for all links when used in the root, now to just figure out which panel it came from
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-06-2009 22:31
...of course we now have a problem with the panel prim and texture setup so we change the init method to include and llSetLinkPrimitiveParams and drop the rest of the llSetLink calls...
CODE

init() {
links = [];
integer number = llGetNumberOfPrims();
integer i;
while (number > 0) {
if (llSubStringIndex(llGetLinkName(number), "Panel#") == 0) {
links += number;
llSetLinkPrimitiveParams(number, [
PRIM_TYPE, PRIM_TYPE_PRISM, PRIM_HOLE_SQUARE, <0.199, 0.8, 0.0>, 0.30,
ZERO_VECTOR, <1.0, 1.0, 0.0>, ZERO_VECTOR,
PRIM_SIZE, <0.03, 2.89, 0.5>,
PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.0,
PRIM_TEXTURE, ALL_SIDES, BLANK, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 1, BLANK, <2.48, 1.0, 0.0>, <-0.740013, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 6, BLANK, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 4, BLANK, <16, 1.0, 0.0>, <-0.2, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 7, BLANK, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 3, BLANK, <2.48, 1.0, 0.0>, <-0.255989, 0.0, 0.0>, 0.0
]);
}
number--;
}
FACES = llGetListLength(links) * llGetListLength(faces);
textnum = llGetInventoryNumber(INVENTORY_TEXTURE);
if(textnum <= FACES){
end = textnum + 1;
} else {
end = FACES + 1;
}
llOwnerSay("there are " + (string)llGetListLength(links) + " panels");
llOwnerSay((string)FACES + " faces available ");
llOwnerSay("Touch Me To Activate");
}

_____________________
http://slurl.com/secondlife/Together
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-06-2009 22:53
Now you have a single 100ish line script and then can ask yourself the question... when does the value of "start" ever change from 0?
_____________________
http://slurl.com/secondlife/Together
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-06-2009 23:21
From: Ruthven Willenov
yep, got that, was also trying to figure out the face touch. using llDetectedTouchFace works for all links when used in the root, now to just figure out which panel it came from

That's going to be the number variable already in the touch start -- then llListFindList(faces, [llDetectedTouchFace(0)]) to find which face on that panel...
_____________________
http://slurl.com/secondlife/Together
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-06-2009 23:29
i got the set of scripts working earlier, now just trying to cut it down to one script like you're describing. i added a floating text prim, a larger display prim, and a button to preview the texture as tiled. this is what i have so far, but i keep getting a weird error at the last bracket

(165,0) : ERROR : Name previously declared within scope

From: someone

list faces = [3,7,4,6,1];
list panelfaces = [1,2,3,4,5];
list links;
integer link = 0;
integer face = 0;
integer FACES;
integer start = 0;
integer end;
integer textnum;
integer texture = 0;
integer display;
integer productnum;
string name;
string BLANK = TEXTURE_BLANK;
key id;
init() {
links = [];
integer number = llGetNumberOfPrims()+1;
integer i;
while (number-- > 0) {
if (llSubStringIndex(llGetLinkName(number), "Panel#";) == 0) {
links += number;
llSetLinkPrimitiveParams(number, [
PRIM_TYPE, PRIM_TYPE_PRISM, PRIM_HOLE_SQUARE, <0.199, 0.8, 0.0>, 0.30,
ZERO_VECTOR, <1.0, 1.0, 0.0>, ZERO_VECTOR,
PRIM_SIZE, <0.01, 2.89, 0.5>,
PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.0,
PRIM_TEXTURE, ALL_SIDES, BLANK, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 1, BLANK, <2.48, 1.0, 0.0>, <-0.740013, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 6, BLANK, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 4, BLANK, <16, 1.0, 0.0>, <-0.2, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 7, BLANK, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 3, BLANK, <2.48, 1.0, 0.0>, <-0.255989, 0.0, 0.0>, 0.0
]);
}
else if (llGetLinkName(number) == "display";)
{display = number;
llSetLinkTexture(number, TEXTURE_BLANK, 0);
}
}
FACES = llGetListLength(links) * llGetListLength(faces);
textnum = llGetInventoryNumber(INVENTORY_TEXTURE);
if(textnum <= FACES){
end = textnum + 1;
} else {
end = FACES + 1;
}
llOwnerSay("there are " + (string)llGetListLength(links) + " panels";);
llOwnerSay((string)FACES + " faces available ";);
llOwnerSay("Touch Me To Activate";);
}
textureit()
{
llSetLinkTexture(display,llGetInventoryName(0,texture),0);
llMessageLinked(display,0,llGetInventoryName(0,texture),"";);
integer i;
for (i = start; i < end; i++){
if(face == 5)
{
face = 0;
link++;
}
name = llGetInventoryName(INVENTORY_TEXTURE,texture);
integer facenum = llList2Integer(faces,face);
integer linknum = llList2Integer(links,link);
if(name != "";)
{
llSetLinkPrimitiveParams(linknum,[PRIM_TEXTURE,facenum, name,<1.0,1.0,0.0>,ZERO_VECTOR,0.0]);
}
else
{
llSetLinkPrimitiveParams(linknum,[PRIM_TEXTURE,facenum, BLANK,<1.0,1.0,0.0>,ZERO_VECTOR,0.0]);
}
face++;
texture++;
}
llOwnerSay("done texturing";);
texture = texture-end;
link = 0;
face = 0;
llOwnerSay((string)texture);
name = llGetInventoryName(0,texture);
}

default
{
state_entry()
{
init();
}
touch_start(integer blah)
{
state display;
}
}
state display
{
state_entry()
{
textureit();
}
touch_start(integer num)
{
string button = llGetLinkName(llDetectedLinkNumber(0));
list BUTTON = llParseString2List(button,["#"],[]);
panelnum = (integer)llList2String(BUTTON,1);
id = llDetectedKey(0);
if(button == "next";)
{
texture = texture+FACES;
llOwnerSay((string)newnum);
textureit();
}
else if(button == "back";)
{
texture = texture-FACES;
if(texture <= 0){texture = 0;}
llOwnerSay((string)texture);
textureit();
}
else if (button == "display";)
{
llGiveInventory(id,name);
}
else if (button == "tile";)
{
llSetLinkPrimitiveParams(display,[PRIM_TEXTURE,0,name,<3.0,3.0,0.0>,ZERO_VECTOR,0.0]);
}
else if (llList2String(BUTTON,0) == "Panel";)
{
panelnum = (integer)llList2String(BUTTON,1);
integer face = llDetectedTouchFace(0);
integer facenum = llListFindList(faces,[face]);
if(facenum != -1)
{
productnum = llList2Integer(panelfaces,facenum);
integer addnum = panelnum - 1;
integer add = addnum * 5;
productnum += add;
llOwnerSay((string)productnum);
integer number = productnum-1;
name = llGetInventoryName(INVENTORY_TEXTURE,number+texture);
if(name)
{
llOwnerSay("Texture Named " + name + " on display number " + productnum);
llSetLinkTexture(display,name,0);
llMessageLinked(LINK_SET,0,name,"";);
}
else
{
llOwnerSay("no texture on display number " + str);
llSetLinkTexture(display,BLANK,0);
llMessageLinked(LINK_SET,0,"","";);
}
}
}
}
changed(integer change)
{
if(change & (CHANGED_INVENTORY|CHANGED_LINK))
{
llResetScript();
}
}
}


edit: spotted some duplicated lines from copying and pasting
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-06-2009 23:44
this is of course "paging" functionality so you could rationalize/simplify a bit more in the init function to work out the page and then increment/decrement that value...

i.e. say you put this into init instead of working out start/end
CODE

integer num_textures = llGetInventoryNumber(INVENTORY_TEXTURE);
page_size = llGetListLength(panel_links) * llGetListLength(faces);
num_pages = num_textures / page_size + (num_textures % page_size > 0);
current_page = 0;


then in your touch start you could do the following...

CODE

touch_start(integer number) {
string link_name = llToLower(llGetLinkName(llDetectedLinkNumber(0)));
if (link_name == "next") {
current_page = (current_page + 1) % num_pages;
textureit();
} else if (link_name == "back") {
current_page = (current_page - 1 + num_pages) % num_pages;
textureit();
} else if (llSubStringIndex(link_name, "panel#") == 0) {
integer panel = (integer)llGetSubString(link_name, 6, -1) - 1;
integer face = llListFindList(faces, [llDetectedTouchFace(0)]);
integer texture_index = current_page * page_size + panel * llGetListLength(faces) + face;
string texture = llGetInventoryName(INVENTORY_TEXTURE, texture_index);
llOwnerSay("Texture Named " + texture + " on panel " + (string)panel + ", face " + (string)face);
}
}
_____________________
http://slurl.com/secondlife/Together
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-07-2009 00:30
Here's what I ended up with after reworking "textureit" -- I noticed that using llSetLinkTexture doesn't honor the "flip bit" so the middle texture is reversed and so that call in "textureit" will need a touch more work.. anyways - good luck and hope this was helpful!!
CODE

//
list faces = [3,7,4,6,1];
list panel_links;

integer page_size;
integer num_pages;
integer current_page;
integer num_textures;

init() {
panel_links = [];
integer number = llGetNumberOfPrims();
while (number > 0) {
if (llSubStringIndex(llToLower(llGetLinkName(number)), "panel#") == 0) {
panel_links += number;
llSetLinkPrimitiveParams(number, [
PRIM_TYPE, PRIM_TYPE_PRISM, PRIM_HOLE_SQUARE, <0.199, 0.8, 0.0>, 0.30,
ZERO_VECTOR, <1.0, 1.0, 0.0>, ZERO_VECTOR,
PRIM_SIZE, <0.03, 2.89, 0.5>,
PRIM_COLOR, ALL_SIDES, <1.0, 1.0, 1.0>, 0.0,
PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 1, TEXTURE_BLANK, <2.48, 1.0, 0.0>, <-0.740013, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 6, TEXTURE_BLANK, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 4, TEXTURE_BLANK, <16, 1.0, 0.0>, <-0.2, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 7, TEXTURE_BLANK, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 3, TEXTURE_BLANK, <2.48, 1.0, 0.0>, <-0.255989, 0.0, 0.0>, 0.0
]);
}
number--;
}
num_textures = llGetInventoryNumber(INVENTORY_TEXTURE);
page_size = llGetListLength(panel_links) * llGetListLength(faces);
num_pages = num_textures / page_size + (num_textures % page_size > 0);
current_page = 0;
}

textureit() {
llOwnerSay("one moment...");
integer num_faces = llGetListLength(faces);
integer i;
for (i = 0; i < page_size; i++){
integer panel = llList2Integer(panel_links, i / num_faces);
integer face = llList2Integer(faces, i % num_faces);
string texture = TEXTURE_BLANK;
float alpha = 0.0;
integer texture_index = current_page * page_size + i;
if (texture_index < num_textures) {
texture = llGetInventoryName(INVENTORY_TEXTURE, texture_index);
alpha = 1.0;
}
// NOTE!! flip bit not set, (image reversed on the middle face
// - so the next two will have be changed to llSetPrimitiveParams...
llSetLinkTexture(panel, texture, face);
llSetLinkAlpha(panel, alpha, face);
}
llOwnerSay("done");
}


default {
state_entry() {
init();
llOwnerSay("there are " + (string)llGetListLength(panel_links) + " panels");
llOwnerSay((string)page_size + " faces available [" + (string)num_pages + " pages for " + (string)llGetInventoryNumber(INVENTORY_TEXTURE) + " textures]");
llOwnerSay("Touch Me To Activate");
}

touch_start(integer blah) {
state display;
}
}

state display {
state_entry() {
textureit();
}

touch_start(integer number) {
string link_name = llToLower(llGetLinkName(llDetectedLinkNumber(0)));
if (link_name == "next") {
current_page = (current_page + 1) % num_pages;
textureit();
} else if (link_name == "back") {
current_page = (current_page - 1 + num_pages) % num_pages;
textureit();
} else if (llSubStringIndex(link_name, "panel#") == 0) {
integer panel = (integer)llGetSubString(link_name, 6, -1) - 1;
integer face = llListFindList(faces, [llDetectedTouchFace(0)]);
integer texture_index = current_page * page_size + panel * llGetListLength(faces) + face;
if (texture_index < num_textures) {
string texture_name = llGetInventoryName(INVENTORY_TEXTURE, texture_index);
llOwnerSay("Texture Named " + texture_name + " on panel " + (string)panel + ", face " + (string)face);
}
}
}

changed(integer change) {
if (change & (CHANGED_INVENTORY | CHANGED_LINK)) {
llResetScript();
}
}
}

_____________________
http://slurl.com/secondlife/Together
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-07-2009 01:06
..it's also struck me that the init function is still dependent on link order -- so if you want a top to bottom "refresh" there's a bit of work in there also.. ;)
/esc
_____________________
http://slurl.com/secondlife/Together
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-07-2009 02:36
....so there i was replicating the idea that llSetLinkTexture doesn't honor the flip bit but then i discovered that it's actually the original prim param setup vector that was wrong...

PRIM_TEXTURE, 4, TEXTURE_BLANK, <16, 1.0, 0.0>, <-0.2, 0.0, 0.0>, 0.0,

...should be more like...

PRIM_TEXTURE, 4, TEXTURE_BLANK, <-16.5, 1.0, 0.0>, <0.25, 0.0, 0.0>, 0.0,

...and the llSetLinkTexture works just fine :)
_____________________
http://slurl.com/secondlife/Together
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-07-2009 06:50
From: Escort DeFarge
....so there i was replicating the idea that llSetLinkTexture doesn't honor the flip bit but then i discovered that it's actually the original prim param setup vector that was wrong...

PRIM_TEXTURE, 4, TEXTURE_BLANK, <16, 1.0, 0.0>, <-0.2, 0.0, 0.0>, 0.0,

...should be more like...

PRIM_TEXTURE, 4, TEXTURE_BLANK, <-16.5, 1.0, 0.0>, <0.25, 0.0, 0.0>, 0.0,

...and the llSetLinkTexture works just fine :)

yeah i got that fixed in the previous panel setup. i didn't realize it needed to be flipped until i noticed a texture with words on it showed backwords
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-07-2009 08:00
added in the display and i've getting that error again about the name

From: someone

//
list faces = [3,7,4,6,1];
list panel_links;

integer page_size;
integer num_pages;
integer current_page;
integer num_textures;
integer display;
integer firstindex;

string current;
string linkname;

init() {
panel_links = [];
integer number = llGetNumberOfPrims();
while (number > 0) {
linkname = llGetLinkName(number);
if (llSubStringIndex(llToLower(linkname) , "panel#";) == 0) {
panel_links += number;
llSetLinkPrimitiveParams(number, [
PRIM_TYPE, PRIM_TYPE_PRISM, PRIM_HOLE_SQUARE, <0.199, 0.8, 0.0>, 0.30,
ZERO_VECTOR, <1.0, 1.0, 0.0>, ZERO_VECTOR,
PRIM_SIZE, <0.01, 2.89, 0.5>,
PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <0.1, 0.1, 0>, ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 1, TEXTURE_BLANK, <2.48, 1.0, 0.0>, <-0.740013, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 6, TEXTURE_BLANK, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 4, TEXTURE_BLANK, <-16, 1.0, 0.0>, <0.2, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 7, TEXTURE_BLANK, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 3, TEXTURE_BLANK, <2.48, 1.0, 0.0>, <-0.255989, 0.0, 0.0>, 0.0
]);
}
else if(linkname == display)
{display = number;
llSetLinkTexture(number, TEXTURE_BLANK, 0);
}
number--;
}
num_textures = llGetInventoryNumber(INVENTORY_TEXTURE);
page_size = llGetListLength(panel_links) * llGetListLength(faces);
num_pages = num_textures / page_size + (num_textures % page_size > 0);
current_page = 0;
}

textureit() {
llOwnerSay("one moment...";);
integer num_faces = llGetListLength(faces);
firstindex = current_page * page_size;
current = llGetInventoryName(INVENTORY_TEXTURE,firstindex);
llSetLinkTexture(display,current,0);
llMessageLinked(LINK_SET,0,current,"";);

integer i;
for (i= 0; i < page_size; i++){
integer panel = llList2Integer(panel_links, i / num_faces);
integer face = llList2Integer(faces, i % num_faces);
string texture = TEXTURE_BLANK;
float alpha = 0.0;
integer texture_index = current_page * page_size + i;
if (texture_index < num_textures) {
texture = llGetInventoryName(INVENTORY_TEXTURE, texture_index);
alpha = 1.0;
}
// NOTE!! flip bit not set, (image reversed on the middle face
// - so the next two will have be changed to llSetPrimitiveParams...
llSetLinkTexture(panel, texture, face);
llSetLinkAlpha(panel, alpha, face);
}
llOwnerSay("done";);
}


default {
state_entry() {
init();
llOwnerSay("there are " + (string)llGetListLength(panel_links) + " panels";);
llOwnerSay((string)page_size + " faces available [" + (string)num_pages + " pages for " + (string)llGetInventoryNumber(INVENTORY_TEXTURE) + " textures]";);
llOwnerSay("Touch Me To Activate";);
}

touch_start(integer doit) {
state display;
}
}

state display {
state_entry() {
textureit();
}

touch_start(integer number) {
string link_name = llToLower(llGetLinkName(llDetectedLinkNumber(0)));
if (link_name == "next";) {
current_page = (current_page + 1) % num_pages;
textureit();
} else if (link_name == "back";) {
current_page = (current_page - 1 + num_pages) % num_pages;
textureit();
} else if (llSubStringIndex(link_name, "panel#";) == 0) {
integer panel = (integer)llGetSubString(link_name, 6, -1) - 1;
integer face = llListFindList(faces, [llDetectedTouchFace(0)]);
integer texture_index = current_page * page_size + panel * llGetListLength(faces) + face;
if (texture_index < num_textures) {
string texture_name = llGetInventoryName(INVENTORY_TEXTURE, texture_index);
llMessageLinked(LINK_SET,0,texture_name,"";);
llSetLinkTexture(display,texture_name,0);
llOwnerSay("Texture Named " + texture_name + " on panel " + (string)panel + ", face " + (string)face);
}
}
}

changed(integer change) {
if (change & (CHANGED_INVENTORY | CHANGED_LINK)) {
llResetScript();
}
}
}
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
01-07-2009 12:08
You have added a global with the same name as a state! (i.e. display).
_____________________
http://slurl.com/secondlife/Together
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
01-07-2009 12:37
From: Escort DeFarge
You have added a global with the same name as a state! (i.e. display).


lol, omg i didn't even think about that, it was puzzling me cause it kept giving the error at the last bracket i also forgot to put quotes when checking for the link name "display" in init(). works perfectly now, thanks for your help!

i made some other versions with less panels and less faces for each panel, now i just need to go back and work this script into it
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
Final Script (as of 1/7/09)
01-07-2009 21:01
So here's the latest version of this script, and it is only 1 script. 2 really, but the first one is just the setup for the panels. You'll need to make sure the link order is right for the panels to be calculated, textured, etc. within the script.

you need as many panels as you want each named "Panel#" plus the number
drop the panel setup script into each one

you need a button named "tile"
a button named "next"
and a button named "back"

To Link everything
Select the Panels 1 by one starting with the first and going up, select the buttons, and then any other prims you use (maybe a backdrop prim) and then the root
The root will be the display prim, with the texture display one face 4 and will also display the hover text.

put any textures you like to use into the root, and then the main script

edit: uploaded a snapshot to flickr for an example

layed out like this:

PANEL#1.................................PANEL#6
PANEL#2.................................PANEL#7
PANEL#3......MAIN DISPLAY......PANEL#8
PANEL#4...........(ROOT)...........PANEL#9
PANEL#5.................................PANEL#10
...........BACK.......TILE........NEXT


CODE

//Panel Setup Script
default
{
state_entry()
{
string offline = "05589e3c-cae6-84bf-7791-ba9c26b0a571";
llSetPrimitiveParams(
[PRIM_TYPE, PRIM_TYPE_PRISM, PRIM_HOLE_SQUARE,
<0.199, 0.8, 0.0>, 0.30,ZERO_VECTOR,
<1.0, 1.0, 0.0>, ZERO_VECTOR,
PRIM_TEXTURE, 1, offline, <2.48, 1.0, 0.0>, <-0.740013, 0, 0>,0.0,
PRIM_TEXTURE, 6, offline, <1.0, 1.0, 0.0>,
<0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 4, offline, <-16.0, 1.0, 0.0>, <0.2, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 7, offline, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 3, offline, <2.48, 1.0, 0.0>,
<-0.255989, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 0, offline, <0.1, 0.1, 0>,
ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 2, TEXTURE_BLANK,<0.1, 0.1, 0>,
ZERO_VECTOR, 0.0,
PRIM_TEXTURE, 5,offline, <0.1, 0.1, 0>,
ZERO_VECTOR, 0.0,
PRIM_FULLBRIGHT,ALL_SIDES,TRUE,
PRIM_SIZE, <0.03, 2.89, 0.5>]);
llRemoveInventory(llGetScriptName());
}
}


CODE

//Main Script
list faces = [3,7,4,6,1];
list panel_links;
list onbuttons = ["Go Offline","Cancel"];
list offbuttons = ["Go Online","Cancel"];
list buttons;

integer page_size;
integer num_pages;
integer current_page;
integer num_textures;
integer chan;
integer listencontrol;

string offline = "05589e3c-cae6-84bf-7791-ba9c26b0a571";
string blank = "84d969e2-be65-11f9-94ec-452f727b43c5";
string texture_name;

key avatar;

vector color;

dialog()
{
chan = (integer)llFrand(-10000)-1000;
listencontrol = llListen(chan,"",avatar,"");
llDialog(avatar,"What Would You Like To Do?",buttons,chan);
llSetTimerEvent(30.0);
}


init() {
llSetText("Offline",color,1.0);
llSetPrimitiveParams([17,4,offline,<1.0,1.0,0.0>,<0,0,0>,0]);
panel_links = [];
integer number = llGetNumberOfPrims();
while (number > 0) {
string linkname = llGetLinkName(number);
if (llSubStringIndex(llToLower(linkname) , "panel#") == 0) {
panel_links += number;
llSetLinkPrimitiveParams(number, [9, 2, 0x20, <0.199, 0.8, 0.0>, 0.30,<0,0,0>, <1.0, 1.0, 0.0>, <0,0,0>,7, <0.01, 2.89, 0.5>,17, -1, offline, <0.1, 0.1, 0>, <0,0,0>, 0.0,17, 1, offline, <2.48, 1.0, 0.0>, <-0.740013, 0.0, 0.0>, 0.0,17, 6, offline, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,17, 4, offline, <-16, 1.0, 0.0>, <0.2, 0.0, 0.0>, 0.0,17, 7, offline, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,17, 3, offline, <2.48, 1.0, 0.0>, <-0.255989, 0.0, 0.0>, 0.0]);
}
number--;
}
num_textures = llGetInventoryNumber(0);
page_size = llGetListLength(panel_links) * llGetListLength(faces);
num_pages = num_textures / page_size + (num_textures % page_size > 0);
current_page = 0;
}

textureit() {
llOwnerSay("one moment...");
integer num_faces = llGetListLength(faces);
integer firstindex = current_page * page_size;
texture_name = llGetInventoryName(0,firstindex);
llSetPrimitiveParams([17,4,texture_name,<1.0,1.0,0.0>,<0,0,0>,0]);
integer textnum = firstindex+1;
llSetText(texture_name + "\n" + (string)textnum + " of " + (string)num_textures,color,1.0);

integer i;
for (i= 0; i < page_size; i++){
integer panel = llList2Integer(panel_links, i / num_faces);
integer face = llList2Integer(faces, i % num_faces);
string texture = blank;
float alpha = 0.0;
integer texture_index = current_page * page_size + i;
if (texture_index < num_textures) {
texture = llGetInventoryName(0, texture_index);
alpha = 1.0;
}
llSetLinkTexture(panel, texture, face);
}
llOwnerSay("done");
}



default {
state_entry() {
init();
llOwnerSay("there are " + (string)llGetListLength(panel_links) + " panels");
llOwnerSay((string)page_size + " faces available [" + (string)num_pages + " pages for " + (string)llGetInventoryNumber(0) + " textures]");
buttons = offbuttons;
}

touch_start(integer doit)
{
avatar = llDetectedKey(0);
if(avatar == llGetOwner())
{
dialog();
}
}

listen(integer chan, string name, key id, string str)
{
if(str == "Cancel")
{
llSetTimerEvent(0.0);
llListenRemove(listencontrol);
}
else if(str == "Go Online")
{
state online;
}
}

timer()
{
llSetTimerEvent(0.0);
llListenRemove(listencontrol);
}
changed(integer change)
{
if (change & (0x001 | 0x020)){llResetScript();}
}
}

state online {
state_entry() {
buttons = onbuttons;
textureit();
}

touch_start(integer number)
{
avatar = llDetectedKey(0);
string link_name = llToLower(llGetLinkName(llDetectedLinkNumber(0)));
if (link_name == "next") {
current_page = (current_page + 1) % num_pages;
textureit();
} else if (link_name == "back") {
current_page = (current_page - 1 + num_pages) % num_pages;
textureit();
}
else if(link_name == "tile")
{
llSetPrimitiveParams([17,4,texture_name,<3,3,0>,<0,0,0>,0]);
}
else if (llSubStringIndex(link_name, "panel#") == 0) {
integer panel = (integer)llGetSubString(link_name, 6, -1) - 1;
integer face = llListFindList(faces, [llDetectedTouchFace(0)]);
integer texture_index = current_page * page_size + panel * llGetListLength(faces) + face;
if (texture_index < num_textures) {
texture_name = llGetInventoryName(0, texture_index);
integer textnum = texture_index+1;
llSetText(texture_name + "\n" + (string)textnum + " of " + (string)num_textures,color,1.0);
}
llSetPrimitiveParams([17,4,texture_name,<1.0,1.0,0.0>,<0,0,0>,0]);
}
else
{
if(avatar == llGetOwner())
{
dialog();
}
}
}

listen(integer chan, string name, key id, string str)
{
if(str == "Cancel")
{
llSetTimerEvent(0.0);
llListenRemove(listencontrol);
}
else if(str == "Go Offline")
{
llResetScript();
}
}

timer()
{
llSetTimerEvent(0.0);
llListenRemove(listencontrol);
}

changed(integer change)
{
if (change & (0x001 | 0x020)){llResetScript();}
}
}

}
}
Ruthven Willenov
Darkness in your light
Join date: 16 Jan 2008
Posts: 965
New Update 1/9/09
01-09-2009 14:05
here's another update, just use the regular setup script as described above.
in this version i added the ability to delete the current texture, or to purge all the textures. the script will reset upon link change, but it will only recount the textures and pages when deleting or adding textures. it will remember what page you were on instead of starting over at the beginning. if there was only 1 texture on the current page when you delete, it will go to the previous page. if there's no textures it won't go online. if you were online and you deleted the only texture in the inventory, it will go offline. only the owner can, turn it on/off. only the owner can delete textures (unless a friend with mod perms deletes them manually)

edit: init() also doesn't do anything to the scale of the panels. so if you decide to change the size, to use a hud or whatever it won't mess it up

CODE

list faces = [3,7,4,6,1];
list panel_links;
list onbuttons = ["Go Offline","Delete","Purge","Cancel"];
list offbuttons = ["Go Online","Purge","Cancel"];
list buttons;

integer page_size;
integer num_pages;
integer current_page;
integer num_textures;
integer chan;
integer listencontrol;

string offline = "05589e3c-cae6-84bf-7791-ba9c26b0a571";
string blank = "84d969e2-be65-11f9-94ec-452f727b43c5";
string texture_name;

key avatar;

vector color = <1.0,1.0,1.0>;

purge()
{
integer i = 0;
integer n = llGetInventoryNumber(INVENTORY_TEXTURE);
while (n > i)
{
string name = llGetInventoryName(INVENTORY_TEXTURE, i);
llOwnerSay("deleting " + name);
llRemoveInventory(name);
n = llGetInventoryNumber(INVENTORY_TEXTURE);
}
llResetScript();
}

dialog()
{
chan = (integer)llFrand(-10000)-1000;
listencontrol = llListen(chan,"",avatar,"");
llDialog(avatar,"What Would You Like To Do?",buttons,chan);
llSetTimerEvent(30.0);
}

recount()
{
llOwnerSay("recounting textures, one moment");
num_textures = llGetInventoryNumber(0);
if(!num_textures)
{
llOwnerSay("no textures here");
llResetScript();
}
else{
num_pages = num_textures / page_size + (num_textures % page_size > 0);
llOwnerSay((string)num_pages + " pages for " + (string)llGetInventoryNumber(0) + " textures");
}
}

init() {
buttons = offbuttons;
llOwnerSay("Setting Up");
llSetText("Offline",color,1.0);
llSetPrimitiveParams([PRIM_TEXTURE,4,offline,<1.0,1.0,0.0>,<0,0,0>,0]);
panel_links = [];
integer number = llGetNumberOfPrims();
while (number > 0) {
string linkname = llGetLinkName(number);
if (llSubStringIndex(llToLower(linkname) , "panel#") == 0) {
llOwnerSay(linkname);
panel_links += number;
llSetLinkPrimitiveParams(number,
[PRIM_TYPE, PRIM_TYPE_PRISM, PRIM_HOLE_SQUARE, <0.199, 0.8, 0.0>, 0.30,<0,0,0>, <1.0, 1.0, 0.0>, <0,0,0>,
PRIM_TEXTURE, ALL_SIDES, TEXTURE_BLANK, <1.0, 1.0, 0>, <0,0,0>, 0.0,
PRIM_TEXTURE, 1, offline, <2.48, 1.0, 0.0>, <-0.740013, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 6, offline, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 4, offline, <-16, 1.0, 0.0>, <0.2, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 7, offline, <1.0, 1.0, 0.0>, <0.0, 0.0, 0.0>, 0.0,
PRIM_TEXTURE, 3, offline, <2.48, 1.0, 0.0>, <-0.255989, 0.0, 0.0>, 0.0]);
}
number--;
}
num_textures = llGetInventoryNumber(0);
page_size = llGetListLength(panel_links) * llGetListLength(faces);
num_pages = num_textures / page_size + (num_textures % page_size > 0);
current_page = 0;
llOwnerSay("Done Setting Up");
llOwnerSay("there are " + (string)llGetListLength(panel_links) + " panels");
llOwnerSay((string)page_size + " faces available [" + (string)num_pages + " pages for " + (string)llGetInventoryNumber(0) + " textures]");
}


textureit() {
buttons = onbuttons;
llOwnerSay("texturing, one moment...");
integer num_faces = llGetListLength(faces);
integer firstindex = current_page * page_size;
texture_name = llGetInventoryName(0,firstindex);
if(texture_name == ""){texture_name = blank;}
llSetPrimitiveParams([PRIM_TEXTURE,4,texture_name,<1.0,1.0,0.0>,<0,0,0>,0]);
integer textnum = firstindex+1;
integer pagenum = current_page+1;
llSetText(texture_name + "\n" + (string)textnum + " of " + (string)num_textures + " \n Page " + (string)pagenum + " of " + (string)num_pages,color,1.0);
integer i;
for (i= 0; i < page_size; i++){
integer panel = llList2Integer(panel_links, i / num_faces);
integer face = llList2Integer(faces, i % num_faces);
string texture = blank;
integer texture_index = firstindex + i;
if (texture_index < num_textures) {
texture = llGetInventoryName(0, texture_index);
}
llSetLinkTexture(panel, texture, face);
}
llOwnerSay("done");
}



default {
state_entry() {
init();
}

touch_start(integer doit)
{
avatar = llDetectedKey(0);
if(avatar == llGetOwner())
{
dialog();
}
}

listen(integer chan, string name, key id, string str)
{
if(str == "Cancel")
{
llSetTimerEvent(0.0);
llListenRemove(listencontrol);
}
else if(str == "Purge")
{
llDialog(id,"Are you sure you want to delete everything?",["Yes.", "No."],chan);
}
else if(str =="Yes.")
{
purge();
}
else if(str == "Go Online")
{
if (num_textures)
{
state online;
}
else
{
llOwnerSay("There are no textures to display");
}
}
}

timer()
{
llSetTimerEvent(0.0);
llListenRemove(listencontrol);
}
changed(integer change)
{
if (change & CHANGED_LINK){llResetScript();}
else if (change & CHANGED_INVENTORY){recount();}
}
}

state online {
state_entry() {
textureit();
}

touch_start(integer number)
{
avatar = llDetectedKey(0);
string link_name = llToLower(llGetLinkName(llDetectedLinkNumber(0)));
if (link_name == "next") {
current_page = (current_page + 1) % num_pages;
textureit();
} else if (link_name == "back") {
current_page = (current_page - 1 + num_pages) % num_pages;
textureit();
}
else if(link_name == "tile")
{
llSetPrimitiveParams([PRIM_TEXTURE,4,texture_name,<3,3,0>,<0,0,0>,0]);
}
else if (llSubStringIndex(link_name, "panel#") == 0) {
integer panel = (integer)llGetSubString(link_name, 6, -1) - 1;
integer face = llListFindList(faces, [llDetectedTouchFace(0)]);
integer texture_index = current_page * page_size + panel * llGetListLength(faces) + face;
if (texture_index < num_textures) {
texture_name = llGetInventoryName(0, texture_index);
integer textnum = texture_index+1;
integer pagenum = current_page+1;
llSetText(texture_name + "\n" + (string)textnum + " of " + (string)num_textures + " \n Page " + (string)pagenum + " of " + (string)num_pages,color,1.0);
}
llSetPrimitiveParams([PRIM_TEXTURE,4,texture_name,<1.0,1.0,0.0>,<0,0,0>,0]);
}
else
{
if(avatar == llGetOwner())
{
dialog();
}
}
}

listen(integer chan, string name, key id, string str)
{
if(str == "Cancel")
{
llSetTimerEvent(0.0);
llListenRemove(listencontrol);
}
else if(str == "Go Offline")
{
llResetScript();
}
else if(str == "Purge")
{
llDialog(id,"Are you sure you want to delete everything?",["Yes.", "No."],chan);
}
else if(str =="Yes.")
{
purge();
}
else if (str == "Delete")
{
llDialog(id,"Are You Sure you \n want to delete " + texture_name + "?",["Yes","No"],chan);
}
else if(str == "Yes")
{
llRemoveInventory(texture_name);
recount();
if(current_page == num_pages){current_page--;}
textureit();
}
}

timer()
{
llSetTimerEvent(0.0);
llListenRemove(listencontrol);
}

changed(integer change)
{
if (change & CHANGED_LINK){llResetScript();}
else if (change & CHANGED_INVENTORY){recount();
if(current_page == num_pages){current_page--;}
textureit();}
}
}