Texture Cycle
Jump to navigation
Jump to search
Cycle through textures on touch
Cycles through textures in object inventory on touch
<lsl> // Cycle thru textures in inventory on touch // @author: JB Kraft // ------------------------------------------------------------------------
// counter integer g_NDX = 0;
// ------------------------------------------------------------------------ // D E F A U L T // ------------------------------------------------------------------------ default {
// --------------------------------------------------------------------
touch_start(integer total_number)
{
// get the number of texture in inventory
integer count = llGetInventoryNumber( INVENTORY_TEXTURE );
// if there are none, do nothing
if( count == 0 )
return;
// if we are past the last one, set th the first one
if( g_NDX > count - 1 )
g_NDX = 0;
// set the texture
llSetTexture( llGetInventoryName(INVENTORY_TEXTURE, g_NDX), ALL_SIDES);
// increase the count
++g_NDX;
}
} </lsl>