Jump to content

how to add the "owner only" line?


MadameThespian Underhill
 Share

You are about to reply to a thread that has been inactive for 1530 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

I'm not a scripter but can do simple alterations.  Would sure appreciate the line of code (and where to put it!) that would make the following script usable by OWNER ONLY.  This is a texture change-on-click script that I'm using to make the windows in my house opaque or alpha:  Much thanks in advance!

 

integer choice = 0;

default
{

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

Link to comment
Share on other sites

If you are the Owner of the prim that contains the script then you need to check that your name matches the name of the creator or owner of the prim.

Putting a line such as

if (llDetectedKey(0)  == llGetOwner())

after the line

touch_start(integer total_number) {

followed by the rest of the script will only allow you to execute the remainder of the script.

remember to enclose the  rest in braces.

How does that sound

 

 

 

  • Like 1
Link to comment
Share on other sites

That not the correct type, you need an alpha script.

http://wiki.secondlife.com/wiki/LlSetAlpha

float cloakSpeed = 0.1;integer open = TRUE;default{	touch_end(integer total_number)	{		if (llDetectedKey(0)==llGetOwner())		{			if(open = !open)			{				float alpha = 1.0;				while(alpha > 0.0)				{					alpha -= 0.1;					llSetAlpha(alpha, ALL_SIDES);					llSleep(cloakSpeed);					open = TRUE;				}			}			else			{				float alpha;				while (alpha < 1.0)				{					alpha += 0.1;					llSetAlpha(alpha, ALL_SIDES);					llSleep(cloakSpeed);					open = FALSE;				}			}		}	}}

 

  • Like 1
Link to comment
Share on other sites

Depends on how what the build is like, I would have thought.

If you want to switch a prim between being transparent and opaque, then I agree that swtiching the alpha is usually a better way to do it.

However, I've seen plenty of builds where the windows are simple single prims, with a texture showing the frame, panels, transparent panes and open curtains all on the one prim, and you then switch to a texture showing the same window with the curtains closed when you want some privacy.

  • Like 1
Link to comment
Share on other sites

Just to be pedantic and because nobody else has suggested it, if the windows are a texture with frame then the BEST way to do it is to use a texture atlas method.

In other words, a SINGLE texture (example, 512x256 in size) with both textures for open and closed on it and then because the texture has already loaded, there's no reloading of a texture, you just change the texture offset via script to show the correct part of the texture.  Either the opened or closed version.

:matte-motes-nerdy:

 

Link to comment
Share on other sites

Keeping things simple, for the sake of two textures. Drop the textures into the prim and just use this script. I did not bother with scrolling, it hardly worth the effort for a window.

ADDED: The texture  name needs changing to what ever the texture name is in the inventory of the object.

integer open;default{	touch_end(integer total_number)	{		if (llDetectedKey(0)==llGetOwner())		{			if(open)			{				llSetTexture("TEXTURE NAME",ALL_SIDES);				open = FALSE;			}			else			{				llSetTexture("TEXTURE NEXT NAME",ALL_SIDES);				open = TRUE;			}		}	}}

 

Link to comment
Share on other sites

::i like that idea Sassy :)  ::

some ideas:

if you have many windows in your house, you could make a control switch to send a msg,

and put a script in each window to listen for a message on how to change each window..

.or.....you could  link the control to the house and check prim names for "window"  and

then you would only need one script.

// **** note: the following code is just a guide / gathering of possiblities

you could use a user function to do the change...

// _______Example window control function________________________

windowCntrl()
{
    integer x;
    for(; x < winListLength; ++x)
    {
       llSetLinkPrimitiveParamsFast( llList2Integer(windowLinks,x),
       [ PRIM_COLOR, ALL_SIDES, winColor, alpha ] );
    }
 }

// an example dialog function .....

mainDialog()
{
     llDialog(ID,page,controls + buttons , channel);
}

default
{
    state_entry()
    {

         integer prims = llGetNumberOfPrims(); // number of prims in the house
         integer n;
         list primName;
        
         for(n = 1; n <= prims; ++n)
         {
           primName = llGetLinkPrimitiveParams(n, [PRIM_NAME] );          
           if(llList2String(primName,0) == "window")     // look for prims named "window"
           {  windowLinks += n; }                                  // if found,, add that prim's link number to a list
        }
     winListLength = llGetListLength(windowLinks);  // how many windows ( link numbers)

}

 touch_start(integer count)
    {   if (llDetectedKey(0)  == llGetOwner())

       {  llListenControl(handle,TRUE);
          llSetTimerEvent(30);  
          ID = llDetectedKey(0);
          mainDialog();               // open the dialog function to send the msg to the windows

         }
    } 

 listen(integer chan, string name, key id, string mes)
    {

        if(mes == "Open")
        {
            alpha = 0.40;  winColor =  <0.502, 1.000, 1.000>;
            windowCntrl();
            mainDialog();
        }
         if(mes == "Shade")
        {
          alpha = 0.70; winColor =  <0.200, 0.200, 0.200>;
          windowCntrl();
            mainDialog();
        }
         if(mes == "Closed")
        {
          alpha = 1.0;  winColor =  <0.000, 0.000, 0.000>;
          windowCntrl();
            mainDialog();
        }

}

 timer()
    {   
          llInstantMessage(ID,"Dialog Closed");
          llListenControl(handle, FALSE);
          llSetTimerEvent(0);          
    }

}

Link to comment
Share on other sites

  • 6 years later...

Hi,

I've the same problem as Madame thespian.

I'd like to use my texture changer script on my mesh object but which could  be used by the owner only.

I tried what ppl say up there, so i added the line  if (llDetectedKey(0)==llGetOwner()) as it say.

But now, when another avatar click on the object, the menu pop on my window !

Somebody knows why ?

Here's the script:

//Drop this script into an object with up to 22 textures inside. 

//When anyone Touches they will get a menu with all the textures available. Button names in menu will be first 10 characters from that item's name.  

//NOTE: Texture Names may not exceed 24 characters or script error and menu fails. 


integer side = ALL_SIDES; //ALL_SIDES or any face number 0 through 5 

list texture_list; 
list texture_list2; 
key user = NULL_KEY; 

composelist() 

    integer currenttexture = 0; 
    integer totaltextures = llGetInventoryNumber(INVENTORY_TEXTURE); 
     
    if(totaltextures > 0 & totaltextures <= 12) 
    { 
        texture_list = []; 
        do 
        { 
            texture_list = texture_list + llGetInventoryName(INVENTORY_TEXTURE, currenttexture); 
            currenttexture++; 
        } 
        while (currenttexture > 0 & currenttexture < totaltextures); 
    } 
     
    if(totaltextures > 12 & totaltextures <= 22) 
    { 
        texture_list = ["Next Page"]; 
        do 
        { 
            texture_list = texture_list + llGetInventoryName(INVENTORY_TEXTURE, currenttexture); 
            currenttexture++; 
        } 
        while (currenttexture > 0 & currenttexture < 11); 
         
        texture_list2 = ["Last Page"]; 
        do 
        { 
            texture_list2 = texture_list2 + llGetInventoryName(INVENTORY_TEXTURE, currenttexture); 
            currenttexture++; 
        } 
        while (currenttexture >= 11 & currenttexture < totaltextures); 
    } 
     
    if(totaltextures > 22) 
    { 
        llWhisper(0, "You may only have a maximimum of 22 Textures. Please remove any extra ones."); 
    } 
    if(totaltextures == 0) 
    { 
        llWhisper(0, "Please add up to 22 Textures inside this object."); 
    } 


//The Menu 
integer menu_handler; 
integer menu_channel; 
menu(key user,string title,list texture_list) 

    menu_channel = (integer)(llFrand(99999.0) * -1); //random channel 
    menu_handler = llListen(menu_channel,"","",""); 
    llDialog(user,title,texture_list,menu_channel); 
    llSetTimerEvent(30.0); //menu channel open for 30 seconds 

default 

    state_entry() 
    { 
        composelist(); //make list from inventory textures 
    } 

    touch_start(integer total_number) 
    {   if (llDetectedKey(0)  == llGetOwner())
        user = llDetectedKey(0); 
        menu(user,"nnPlease select one below.",texture_list); 
    } 
     
    listen(integer channel,string name,key id,string message) 
    { 
        if (channel == menu_channel) 
        { 
            llSetTimerEvent(0.0); 
            llListenRemove(menu_handler); 
            if(message == "Next Page") 
            { 
                menu(user,"nnPlease select one below.",texture_list2); 
            } 
            else if(message == "Last Page") 
            { 
                menu(user,"nnPlease select one below.",texture_list); 
            } 
            else 
            { 
                llSetTexture(message, side); 
            } 
        } 
    } 
     
    timer() //Close the Menu Listen or we'll get laggy 
    { 
        llSetTimerEvent(0.0);  
        llListenRemove(menu_handler); 
    } 
     
    changed(integer change)  
    { 
        if (change & CHANGED_INVENTORY) //inventory has changed 
        { 
            llSleep(0.5); 
            composelist(); //rebuild the list 
        } 
    } 
}

Link to comment
Share on other sites

You left out the braces, "{}", around the code that should be executed only when the if statement is true. As it stands, only the user = llDetectedKey (0); statement is conditional.

You want

if (llDetectedKey (0) == llGetOwner ())
{
    user = llDetectedKey (0);
    menu (user, "\nPlease select one below.", texture_list); 
}

  • Confused 1
Link to comment
Share on other sites

I've copied the whole script, with my suggestion bolded and in place, and with the original lines commented and crossed out.

//Drop this script into an object with up to 22 textures inside. 

//When anyone Touches they will get a menu with all the textures available. Button names in menu will be first 10 characters from that item's name.  

//NOTE: Texture Names may not exceed 24 characters or script error and menu fails. 


integer side = ALL_SIDES; //ALL_SIDES or any face number 0 through 5 

list texture_list; 
list texture_list2; 
key user = NULL_KEY; 

composelist() 

    integer currenttexture = 0; 
    integer totaltextures = llGetInventoryNumber(INVENTORY_TEXTURE); 
     
    if(totaltextures > 0 & totaltextures <= 12) 
    { 
        texture_list = []; 
        do 
        { 
            texture_list = texture_list + llGetInventoryName(INVENTORY_TEXTURE, currenttexture); 
            currenttexture++; 
        } 
        while (currenttexture > 0 & currenttexture < totaltextures); 
    } 
     
    if(totaltextures > 12 & totaltextures <= 22) 
    { 
        texture_list = ["Next Page"]; 
        do 
        { 
            texture_list = texture_list + llGetInventoryName(INVENTORY_TEXTURE, currenttexture); 
            currenttexture++; 
        } 
        while (currenttexture > 0 & currenttexture < 11); 
         
        texture_list2 = ["Last Page"]; 
        do 
        { 
            texture_list2 = texture_list2 + llGetInventoryName(INVENTORY_TEXTURE, currenttexture); 
            currenttexture++; 
        } 
        while (currenttexture >= 11 & currenttexture < totaltextures); 
    } 
     
    if(totaltextures > 22) 
    { 
        llWhisper(0, "You may only have a maximimum of 22 Textures. Please remove any extra ones."); 
    } 
    if(totaltextures == 0) 
    { 
        llWhisper(0, "Please add up to 22 Textures inside this object."); 
    } 


//The Menu 
integer menu_handler; 
integer menu_channel; 
menu(key user,string title,list texture_list) 

    menu_channel = (integer)(llFrand(99999.0) * -1); //random channel 
    menu_handler = llListen(menu_channel,"","",""); 
    llDialog(user,title,texture_list,menu_channel); 
    llSetTimerEvent(30.0); //menu channel open for 30 seconds 

default 

    state_entry() 
    { 
        composelist(); //make list from inventory textures 
    } 

    touch_start(integer total_number) 
    {   //if (llDetectedKey(0)  == llGetOwner())
//        user = llDetectedKey(0); 
//        menu(user,"nnPlease select one below.",texture_list); 
        if (llDetectedKey (0) == llGetOwner ())
        {
            user = llDetectedKey (0);
            menu (user, "\nPlease select one below.", texture_list); 
        }

    } 
     
    listen(integer channel,string name,key id,string message) 
    { 
        if (channel == menu_channel) 
        { 
            llSetTimerEvent(0.0); 
            llListenRemove(menu_handler); 
            if(message == "Next Page") 
            { 
                menu(user,"nnPlease select one below.",texture_list2); 
            } 
            else if(message == "Last Page") 
            { 
                menu(user,"nnPlease select one below.",texture_list); 
            } 
            else 
            { 
                llSetTexture(message, side); 
            } 
        } 
    } 
     
    timer() //Close the Menu Listen or we'll get laggy 
    { 
        llSetTimerEvent(0.0);  
        llListenRemove(menu_handler); 
    } 
     
    changed(integer change)  
    { 
        if (change & CHANGED_INVENTORY) //inventory has changed 
        { 
            llSleep(0.5); 
            composelist(); //rebuild the list 
        } 
    } 
}

Link to comment
Share on other sites

Thank you, but the script does not work at all now … there's no syntax error but it doesnt work … ugh

it drive me crazy lol thank for your help, in case someone knows why the script doesnt work let me know ^^

Edited by LAHIN Milo
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1530 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...