Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Texture cycling script

Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
09-12-2008 13:14
Hello ;
I am novice in scripting, I get basic texture cycle on touch script and add some functionality but there is one thing not working. I want it show the current texture name as hover text and change the name as touched. it shows the first texture's name but I think there must be something more to cycle the names with textures .
Here is the code :

From: someone

integer number;
string name;
integer choice = 0;

default
{
state_entry()
{
number = llGetInventoryNumber(INVENTORY_TEXTURE);
number -= 1;
name = llGetInventoryName(INVENTORY_TEXTURE, choice);
if (name != "";)
{
llSetTexture(name, ALL_SIDES);
choice = choice + 1;
}
{
string msg= llGetObjectName() ;
msg+="\n " + (string)llGetInventoryNumber(INVENTORY_TEXTURE) + " Textures L$" + llGetObjectDesc();
msg+="\n " + name ;

llSetText(msg ,<1,1,1>,1);

}

}

touch_start(integer total_number)
{
if (choice < number)
{
name = llGetInventoryName(INVENTORY_TEXTURE, choice);
if (name != "";)
{
llSetTexture(name, ALL_SIDES);
choice = choice + 1;
}
}
else
{
name = llGetInventoryName(INVENTORY_TEXTURE, choice);
if (name != "";)
{
llSetTexture(name, ALL_SIDES);
choice = 0;
}
}
}

changed(integer change)
{
if (change & CHANGED_INVENTORY)
{
llResetScript();
}
}
}
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
09-12-2008 15:06
CODE
string name;
integer number;
integer choice = 0;


set_texture(){
name = llGetInventoryName(INVENTORY_TEXTURE, choice);
if (name != "") llSetTexture(name, ALL_SIDES);
string msg = llGetObjectName();
msg += "\n " + (string)llGetInventoryNumber(INVENTORY_TEXTURE)
+ " Textures L$" + llGetObjectDesc();
msg += "\n " + name ;
llSetText(msg ,<1,1,1>,1);
}

default{
state_entry(){
number = llGetInventoryNumber(INVENTORY_TEXTURE);
set_texture();
}

touch_start(integer total_choice){
if (choice == --number) choice = 0;
else ++choice;
set_texture();
}

changed(integer change){
if (change & CHANGED_INVENTORY) llResetScript();
}
}
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum
Ilayda Reina
Registered User
Join date: 21 Nov 2007
Posts: 31
09-12-2008 15:33
Aww , this worked perfectly, thanks a lot Jesse.
Jesse Barnett
500,000 scoville units
Join date: 21 May 2006
Posts: 4,160
09-12-2008 17:00
From: Ilayda Reina
Aww , this worked perfectly, thanks a lot Jesse.

NP Ilayda, glad to see new people learning.

Just in case you don't know yet here are some links that help:

http://wiki.secondlife.com/wiki/LSL_Portal

http://lslwiki.net/lslwiki/wakka.php?wakka=HomePage

and:

http://www.lsleditor.org/checkforupdate/Default.aspx?beta

The last is LSLEditor which helps tremedously. You can script offline, has autocomplete to speed things up and even has a built in copy of a wiki.

Finally the most important tip is to not be afraid to post questions here.
_____________________
I (who is a she not a he) reserve the right to exercise selective comprehension of the OP's question at anytime.
From: someone
I am still around, just no longer here. See you across the aisle. Hope LL burns in hell for archiving this forum