Jump to content

Modifying touch change texture script


Kuda Oh
 Share

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

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

Recommended Posts

I am not a scripter just a tinkerer. I have a script I got from script library that changes the texture of a prim at a touch, pops up a menu to select texture desired. How would one edit the script so it would change only one face ie: the inside face of a hollow sphere for example. I see the script has a parameter? ALL_SIDES, would that be the part to edit? What would I change  ALL_SIDES to? I been searching through the forums and looking at the wiki, but I  can't seem to find what to change it to so it would only do the face wanted.

Here is the script I am tinkering with: 

// CATEGORY:Texture

// DESCRIPTION:texture swithcer menu driven

// ARCHIVED BY:Ferd Frederix

list MENU1 = [];

list MENU2 = []; integer listener;

integer MENU_CHANNEL = 1000;

// opens menu channel and displays dialog

Dialog(key id, list menu)

{

llListenRemove(listener);

listener = llListen(MENU_CHANNEL, "", NULL_KEY, "");

llDialog(id, "Select one object below: ", menu, MENU_CHANNEL);

}

default

{

on_rez(integer num)

{

// reset scripts on rez

llResetScript();

}

touch_start(integer total_number)

{

integer i = 0;

MENU1 = [];

MENU2 = [];

// count the textures in the prim to see if we need pages

integer c = llGetInventoryNumber(INVENTORY_TEXTURE);

if (c <= 12)

{

for (; i < c; ++i)

MENU1 += llGetInventoryName(INVENTORY_TEXTURE, i);

}

else

{

for (; i < 11; ++i)

MENU1 += llGetInventoryName(INVENTORY_TEXTURE, i);

if(c > 22) c = 22;

for (; i < c; ++i)

MENU2 += llGetInventoryName(INVENTORY_TEXTURE, i);

MENU1 += ">>";

MENU2 += "<<";

}

// display the dialog Dialog(llDetectedKey(0), MENU1);

}

listen(integer channel, string name, key id, string message)

{

if (channel == MENU_CHANNEL)

{

llListenRemove(listener);

if (message == ">>")

{

Dialog(id, MENU2);

}

else if (message == "<<")

{

Dialog(id, MENU1);

}

else

{

// display the texture from menu selection

llSetTexture(message, ALL_SIDES);

      }

   }

 }

}

// END //

Link to comment
Share on other sites

You put the number of the side in question instead of ALL_SIDES (which is -1) - in the case of a atandard box that would be 0 to 5. I don't know which number would do what you want, but just try starting with 0.

And please:

If you post code, format it in a readable way

ETA: Ahh - I see - you formatted the code - thanks!

Link to comment
Share on other sites

Sorry about that it kept pasting all bunched up so I spaced it and just realized I had it pasted to a notecard like it would normaly appear instead I had  cut and pasted from SL. I have a script to give me face numbers so that is no problem, I am just toying with the inside face of a hollow sphere. What was stumping me was what to replace ALL_SIDES with. I had tired FACE_5 or FACE_FIVE for example but knew that was not gonna work lol. So it is as simple as changind ALL_SIDES to just a specific number? Wow I feel dumb, never thought to do that.

 

P.S. ie: llSetTexture(message, ALL_SIDES);  into llSetTexture(message, 5);    for face 5?

Link to comment
Share on other sites

There is a free script around called 'side numbering' that has been in use for several years.  When you drop it in a prim it displays a number on each face to show what you should use instead of ALL_SIDES.  Very handy, Use it on a copy of the prim you actually want to adjust though as it changes all sorts of texture parameters which can be a pain to reset.

I can't get in-world at the moment otherwise I'd pass you a copy but you should be able to find it all over the place.

  • Like 1
Link to comment
Share on other sites

Be warned, though, that face numbering changes if you cut the prim.    There's a (rather complicated) explanation of how it all works at http://wiki.secondlife.com/wiki/Face plus a handy keyboard shortcut.   In V2, enable the Develop menu  (if you haven't already done so) with CTRL-ALT-Q.  In V1, enable the Advanced menu with CTRL-ALT-D.

Then select the face in which you're interested with the select texture tool and press CTRL-ALT-SHIFT-T, and it tells you, in local chat, what the face number is.

Another caveat, which I learned the hard way -- the side numbering script resets the prim's texture repeats and offsets rather drastically. Not a big deal, but you get a shock when you put another texture on, particularly if you've spent ages adjusting them and didn't make a note.

Link to comment
Share on other sites

adding a note: in V2, the ctrl+alt+t command sends the information to chat history, but not to chat console (console is the default that scriolls up from the bottom of the screen and fades out over time, history is the window you get when you click on the icon on the right hand side of the chat bar where you type.)

Link to comment
Share on other sites

  • 11 months later...

How would one go about modifying the above script to give the menu to everyone and say in local chat that it was touched by someone other than the wearer and the texture was changed by that person?

Example would be say a hair bow that everyone has access to touch and brings up the menu with differant textures for the bow to be. When someone other than the wearer of the bow touches the bow, they would get the dialog menu, select what texture they want for the bow and it would say in chat that the person change the wearers bow to texture A.

i am also just a script tinker but not maker, so adding this to the texture change script i am totally lost on where to begin.

Link to comment
Share on other sites

the listen event passes information about the sener which in the case of the dialog is the one who got and touched the dialog. So in the case that an ava chose a texture, just add something like

else {			// display the texture from menu selection			llSetTexture(message, ALL_SIDES);			if(llGetOwner() != id) {				llSay(0, name + " has changed the texture.");			}      	}

 

Link to comment
Share on other sites

There are many problems with the script given.  Don't start from that script, it doesn't work as-is and you'll probably just confuse yourself more trying to make it work.  Look in the script library for a better model to work from, especially Rolig's http://community.secondlife.com/t5/LSL-Library/Dialog-Choices-from-Numbered-Buttons/m-p/786825/message-uid/786825#U786825.

Link to comment
Share on other sites

  • 2 weeks later...

You guys seemed so helpful with the original posters problem.... maybe you all can help me.... my question runs along the same lines. I have a touch menu texture change script also but I would like the texture to be changed on 2 faces instead of just 1.  How would I get the script to do that? The face numbers i want to be changed are 0 and 5

Link to comment
Share on other sites

  • 6 years later...
10 hours ago, KillianMacrieve said:

what about if I want to change only the inner faces of a cube, for example?

The Firestorm viewer (and some other TPVs, I believe) will tell you which face you have selected while you are using the Build editor's Select Face option. The face number is part of the edit display.  In practice, that number is sometimes unreliable.  A better way to figure out which face is which is to make yourself a handy utility script that you can drop into an object's root prim temporarily.  My "Touched What?" script, for example, looks like this:

default
{
    touch_start(integer num)
    {
        llRegionSayTo( llGetOwner(), 0, "Touched face " + (string)llDetectedTouchFace(0) + " on link #" + (string)llDetectedLinkNumber(0) + "." );
    }
}

Just remember to remove the script once you have mapped the face numbers for yourself so that it doesn't interfere with other scripts.  A script like this is particularly helpful if you are scripting a mesh object, because it is by no means obvious how the creator may have designated areas on the object as faces.  Even on standard prims, you can easily be confused about how faces are numbered once the prim has been cut, sliced, hollowed, or twisted.  As Steph pointed out, for example, all of the interior surfaces on a hollowed cube are a single face -- a non-intuitive result if you are new to SL.

Edited by Rolig Loon
  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2002 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...