Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Owner Change texture Script

beverly Zauberflote
Registered User
Join date: 22 Nov 2006
Posts: 26
01-05-2009 21:02
i am sure this probably really easy but the answer evades me. i have the following script that i got off of the internet to cycle textures. i want to modify it so that only the owner of the prim can cycle them. can anyone help me?

// 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;
}
}
beverly Zauberflote
Registered User
Join date: 22 Nov 2006
Posts: 26
Doh!
01-05-2009 21:06
i redid my search and found the answer myself: here is the modified code that does the trick:
// 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)
{
if (llDetectedKey(0) != llGetOwner())
return;


// 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;
}
}