Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Menu Driven Texture Script

Nerolus Mosienko
Registered User
Join date: 3 Aug 2006
Posts: 145
04-12-2008 21:34
Hey everyone. Got a question about a Menu Driven Texture Selection script. Basically, say I've got an attachment, that I want people to be able to click on it and pick a button from the dropdown list, and for whatever button they pick, that texture set would be loaded. For instance, if I had a hat with 5 different texture sets (black and gold, red and green, etc) I want people to be able to choose.

I've delt with something similiar like this before, but it was setting opacity. This seems a little more complex. I'm no script genious, but I'd like to learn a little about it. I could just as easily buy it from here:
http://www.slexchange.com/modules.php?name=Marketplace&file=item&ItemID=536779
...but I want to understand how it works, and to spread the knowledge to my wife, if she makes anything that requires this.

If anyone can help us, that would be great! I've also found a couple things to point me in the right direction...but they don't explain alot.
http://optikal.net.nz/SL/Scripts/Texture-Touch.txt
http://optikal.net.nz/SL/Scripts/Menu.txt
http://optikal.net.nz/SL/Scripts/Menu%20Example.txt
http://optikal.net.nz/SL/Scripts/Menu%20Example2.txt

Any help with this is grealtly appreciated.
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
04-12-2008 23:40
Should be able to use your other script except use llSetTexture

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

This is one I use for a lamp with colors. Change it around for your needs.
CODE


integer CHANNEL = -44567;
float INTENSITY = 10.0;
float RADIUS = 6.0;
float FALLOFF = .25;

list COLOR_LIST = ["white", "red", "green", "blue", "yellow", "orange", "purple", "pink", "cyan", "off"];


default {
state_entry()
{
llListen(CHANNEL, "", NULL_KEY, "");

}

touch_start(integer total_number)
{
llDialog(llDetectedKey(0), "Color?", COLOR_LIST, CHANNEL);
}

listen(integer channel, string name, key id, string message)
{
if (message == "white")
{
llSetColor(<1, 1, 1>,5);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1, 1, 1>, INTENSITY, RADIUS, FALLOFF]);

}
else if (message == "pink")
{
llSetColor(<1, .02, .02>,5);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1, 0.5, 0.5>, INTENSITY, RADIUS, FALLOFF]);

}
else if (message == "red")
{
llSetColor(<1, .0, .0>,5);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1, 0, 0>, INTENSITY, RADIUS, FALLOFF]);

}
else if (message == "orange")
{
llSetColor(<1, .05, .0>,5);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1, 0.5, 0>, INTENSITY, RADIUS, FALLOFF]);

}
else if (message == "yellow")
{
llSetColor(<1, 1, 0>,5);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1, 1, 0>, INTENSITY, RADIUS, FALLOFF]);

}
else if (message == "green")
{
llSetColor(<0, 1, 0>,5);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <0, 1, 0>, INTENSITY, RADIUS, FALLOFF]);

}
else if (message == "blue")
{
llSetColor(<0, 0, 1>,5);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <0, 0, 1>, INTENSITY, RADIUS, FALLOFF]);

}
else if (message == "purple")
{
llSetColor(<1, 0, 1>,5);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <1, 0, 1>, INTENSITY, RADIUS, FALLOFF]);

}
else if (message == "cyan")
{
llSetColor(<0, 1, 1>,5);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, <0, 1, 1>, INTENSITY, RADIUS, FALLOFF]);

}
else if (message == "off")
{
llSetColor(<.95, .95, .95>,5);
llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <0, 0, 0>, 0, 0, 0]);
llWhisper(0,"Lights out");

}


}
}
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
This is Scripting Tips, after all :p
04-13-2008 02:58
I hope you're not going to hate me for this, Max, :o but here's your script tidied up a bit and with added Glow!

CODE

integer PRIM_GLOW = 25;
integer HANDLE;
integer CHANNEL = -44567;
float INTENSITY = 10.0;
float RADIUS = 6.0;
float FALLOFF = .25;
integer FACE = 5;

list COLOR_LIST = ["white", "red", "green",
"blue", "yellow", "orange",
"purple", "pink", "cyan", "off"];
list COLOR_VALUE = [<1, 1, 1>, <1, .0, .0>, <0, 1, 0>,
<0, 0, 1>, <1, 1, 0>, <1, .05, .0>,
<1, 0, 1>, <1, .02, .02>, <0, 1, 1>];

default
{
touch_start(integer total_number)
{
HANDLE = llListen(CHANNEL, "", NULL_KEY, "");
llDialog(llDetectedKey(0), "Color?", COLOR_LIST, CHANNEL);
}

listen(integer channel, string name, key id, string message)
{
llListenRemove(HANDLE);

if(message == "off")
{
llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <0, 0, 0>, 0, 0, 0,
PRIM_COLOR, FACE, <.95, .95, .95>, llGetAlpha(FACE),
PRIM_GLOW, FACE, 0.0]);
llWhisper(0,"Lights out");
}
else
{
integer i = llListFindList(COLOR_LIST, [message]);
vector color = llList2Vector(COLOR_VALUE, i);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, color, INTENSITY, RADIUS, FALLOFF,
PRIM_COLOR, FACE, color, llGetAlpha(FACE),
PRIM_GLOW, FACE, 1.0]);
}
}
}
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
04-13-2008 07:57
From: Pale Spectre
I hope you're not going to hate me for this, Max, :o but here's your script tidied up a bit and with added Glow!


Of course not! I never claimed to be a scripter :)
And thanks!
Dragger Lok
(loading ...)
Join date: 10 Sep 2006
Posts: 228
04-14-2008 05:43
Nice Script Pale,

But had to comment out the glow line to get it to compile- then of course lost the glow....
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
04-14-2008 06:46
From: Dragger Lok
Nice Script Pale,

But had to comment out the glow line to get it to compile- then of course lost the glow....

Replace the glow constant with the integer 25.
_____________________
Max Pitre
Registered User
Join date: 19 Jul 2006
Posts: 370
04-14-2008 08:11
From: Dragger Lok
Nice Script Pale,

But had to comment out the glow line to get it to compile- then of course lost the glow....

It worked for me with the glow although I did change a few other things around...
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
04-14-2008 10:55
From: Dragger Lok
...had to comment out the glow line to get it to compile- then of course lost the glow....
I've lost the plot with Glow but I think it has something to do with what Client software is running. Hence this: integer PRIM_GLOW = 25; because my client doesn't support the 'PRIM_GLOW' constant ...maybe yours does and that's the problem. I think if you're running the RC Dazzle thingumee then the PRIM_GLOW constant will work for you and it won't like my interfering with it.

Once you're compiled I think you're good to go. Change your client and new hurdles may appear if you need to recompile the script. Good, innit. :D
Dragonlady Boa
Registered User
Join date: 13 Jul 2007
Posts: 18
04-20-2008 04:32
my problem is a bit similar to this one, so i didn't want to start a whole new thread about it. i have a touch change color menue, but I need to keep some of the prims not colored, and some others a different color. Is there a script I can find/buy/beg for that can do this for me. Like trim on shoes, the base is one color, the trim another and the gems stay as they are?
Mind you, I'm a scripting idiot, so a very moddable script with very clear instructions would help a lot!
Dragger Lok
(loading ...)
Join date: 10 Sep 2006
Posts: 228
oops
06-05-2008 15:43
Syntax error right off the bat, @ integer PRIM_GLOW = 25;
Been here before I think, what is acceptable to the latest client?
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
06-05-2008 16:33
From: Dragger Lok
Syntax error right off the bat, @ integer PRIM_GLOW = 25;
Been here before I think, what is acceptable to the latest client?

If you have a newer viewer that has PRIM_GLOW built in, comment out that line.
_____________________
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
06-05-2008 16:40
From: Dragonlady Boa
my problem is a bit similar to this one, so i didn't want to start a whole new thread about it. i have a touch change color menue, but I need to keep some of the prims not colored, and some others a different color. Is there a script I can find/buy/beg for that can do this for me. Like trim on shoes, the base is one color, the trim another and the gems stay as they are?
Mind you, I'm a scripting idiot, so a very moddable script with very clear instructions would help a lot!


The easiest way to do this would be one of 2 ways:
1. a notecard with a list of link numbers that are tintable, and the main script looping through and doing the tint on each link read from the notecard (harder, but 1 script)
2. a a second script that you drop in each tintable link, then rather than tinting in the main script, sending a link message so any listening prim could tint itself (easier, more script copies, sim resources, but no annoying notecard hassles)

The script could also be modified to take a list of textures from the object inventory and present a texturing option in addition to a tinting option, so you could pick a fabric texture, and a tint color, or something like that.

I am sure its been done many times, but not sure where to point you for an existing script that does what you're after.
ArchTx Edo
Mystic/Artist/Architect
Join date: 13 Feb 2005
Posts: 1,993
06-05-2008 16:46
From: Dragonlady Boa
my problem is a bit similar to this one, so i didn't want to start a whole new thread about it. i have a touch change color menue, but I need to keep some of the prims not colored, and some others a different color. Is there a script I can find/buy/beg for that can do this for me. Like trim on shoes, the base is one color, the trim another and the gems stay as they are?
Mind you, I'm a scripting idiot, so a very moddable script with very clear instructions would help a lot!


Dragonlady, the script examples above will make only the prim it is in (and the face of that prim that is defined) change color/texture. In a multiprim object, you would need to add a "MessageLinked" call for each color/texture change, and a "LinkedMessage" script in each seperate prim that you wanted to respond to the "MessageLinked" call.

Here is an example of how MessageLinked" and "LinkedMessage" scripts work to control different prims.

/15/4c/138878/1.html

Incorporating this with a menu script is a little more complicated, and for me at least it would be easier to do with the example that Max Pitre posted above. Simply because it is easier to see what the menu is doing with each color choice.
_____________________

VRchitecture Model Homes at http://slurl.com/secondlife/Shona/60/220/30
http://www.slexchange.com/modules.php?name=Marketplace&MerchantID=2240
http://shop.onrez.com/Archtx_Edo
Dragonlady Boa
Registered User
Join date: 13 Jul 2007
Posts: 18
06-05-2008 18:00
wow! I forgot all about this post LOL. i ended up paying a very nice scripter to make one for me from the script from the color change braided prom shoes. And she added texture change to it as well. TX to all who replied!
DjBlacky McMahon
Registered User
Join date: 26 May 2008
Posts: 10
question
08-06-2008 14:03
From: Pale Spectre
I hope you're not going to hate me for this, Max, :o but here's your script tidied up a bit and with added Glow!

CODE

integer PRIM_GLOW = 25;
integer HANDLE;
integer CHANNEL = -44567;
float INTENSITY = 10.0;
float RADIUS = 6.0;
float FALLOFF = .25;
integer FACE = 5;

list COLOR_LIST = ["white", "red", "green",
"blue", "yellow", "orange",
"purple", "pink", "cyan", "off"];
list COLOR_VALUE = [<1, 1, 1>, <1, .0, .0>, <0, 1, 0>,
<0, 0, 1>, <1, 1, 0>, <1, .05, .0>,
<1, 0, 1>, <1, .02, .02>, <0, 1, 1>];

default
{
touch_start(integer total_number)
{
HANDLE = llListen(CHANNEL, "", NULL_KEY, "");
llDialog(llDetectedKey(0), "Color?", COLOR_LIST, CHANNEL);
}

listen(integer channel, string name, key id, string message)
{
llListenRemove(HANDLE);

if(message == "off")
{
llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <0, 0, 0>, 0, 0, 0,
PRIM_COLOR, FACE, <.95, .95, .95>, llGetAlpha(FACE),
PRIM_GLOW, FACE, 0.0]);
llWhisper(0,"Lights out");
}
else
{
integer i = llListFindList(COLOR_LIST, [message]);
vector color = llList2Vector(COLOR_VALUE, i);
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, color, INTENSITY, RADIUS, FALLOFF,
PRIM_COLOR, FACE, color, llGetAlpha(FACE),
PRIM_GLOW, FACE, 1.0]);
}
}
}


can somebody put a random mode inside this script?!?
Laurence Corleone
Registered User
Join date: 12 Oct 2006
Posts: 126
08-06-2008 15:43
From: DjBlacky McMahon
can somebody put a random mode inside this script?!?


Sure, go ahead.
_____________________
There are no stupid questions, just stupid people.
Dragger Lok
(loading ...)
Join date: 10 Sep 2006
Posts: 228
08-06-2008 16:33
errors out at "integer PRIM_GLOW = 25;" viewer?

this works in the new release candidate:

CODE

float FADE_PERIOD = 6.0;
float TIMER_PERIOD = 0.25;

float MIN_GLOW = 0.0;
float MAX_GLOW = 1.0;

float glowAtTime(float t)
{
float midPoint = 0.5*(MAX_GLOW+MIN_GLOW);
float amplitude = 0.5*(MAX_GLOW-MIN_GLOW);

return midPoint+amplitude*llSin(TWO_PI*t/FADE_PERIOD);
}

default
{
state_entry()
{
llSetTimerEvent(TIMER_PERIOD);
}

timer()
{
float glow = glowAtTime(llGetTime());
llSetPrimitiveParams([ PRIM_GLOW, ALL_SIDES, glow ]);
}
}
[/PHP
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
08-06-2008 20:54
In clients where "integer PRIM_GLOW = 25;" produces an error, simply comment it out. :cool:
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
08-07-2008 00:11
From: ArchTx Edo
In a multiprim object, you would need to add a "MessageLinked" call for each color/texture change, and a "LinkedMessage" script in each seperate prim that you wanted to respond to the "MessageLinked" call.


WRONG!

All you need is llSetLinkPrimitiveParams() to apply color/texture stuff to just about any prim in a given linkset using only a *single* script.
Dragger Lok
(loading ...)
Join date: 10 Sep 2006
Posts: 228
08-07-2008 02:35
...
Innula Zenovka
Registered User
Join date: 20 Jun 2007
Posts: 1,825
08-07-2008 05:14
From: Squirrel Wood
WRONG!

All you need is llSetLinkPrimitiveParams() to apply color/texture stuff to just about any prim in a given linkset using only a *single* script.


When I asked about this topic some time ago, Hewee Zetkin shared a method I find invaluable for colouring/texturing particular groups of prims in a linkset. To change all child prims called "Target",
CODE

string TARGET_PRIM_NAME = "Target";
changeAllTargetPrims(list primParams)
{
integer i;
for (i = llGetNumberOfPrims(); i > 0; --i)
{
if (llGetLinkName(i) == TARGET_PRIM_NAME)
{
llSetLinkPrimitiveParams(i, primParams);
}
}
}


/54/06/265951/1.html
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
Adding a 'random' Button
08-07-2008 12:04
CODE

integer HANDLE;
integer CHANNEL = -44567;
float INTENSITY = 10.0;
float RADIUS = 6.0;
float FALLOFF = .25;
integer FACE = 5;

list COLOR_LIST = ["white", "red", "green",
"blue", "yellow", "orange",
"purple", "pink", "cyan", "off", "random"];
list COLOR_VALUE = [<1, 1, 1>, <1, .0, .0>, <0, 1, 0>,
<0, 0, 1>, <1, 1, 0>, <1, .05, .0>,
<1, 0, 1>, <1, .02, .02>, <0, 1, 1>];

pColor(vector color)
{
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, color, INTENSITY, RADIUS, FALLOFF,
PRIM_COLOR, FACE, color, llGetAlpha(FACE),
PRIM_GLOW, FACE, 1.0]);
}

default
{
touch_start(integer total_number)
{
HANDLE = llListen(CHANNEL, "", NULL_KEY, "");
llDialog(llDetectedKey(0), "Color?", COLOR_LIST, CHANNEL);
}

listen(integer channel, string name, key id, string message)
{
llListenRemove(HANDLE);

if(message == "off")
{
llSetTimerEvent(0.0);
llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <0, 0, 0>, 0, 0, 0,
PRIM_COLOR, FACE, <.95, .95, .95>, llGetAlpha(FACE),
PRIM_GLOW, FACE, 0.0]);
llWhisper(0,"Lights out");
}
else if(message == "random") llSetTimerEvent(1.0);
else
{
llSetTimerEvent(0.0);
integer i = llListFindList(COLOR_LIST, [message]);
vector color = llList2Vector(COLOR_VALUE, i);
pColor(color);
}
}

timer()
{
vector color = llList2Vector(COLOR_VALUE, (integer)(llFrand(llGetListLength(COLOR_VALUE))));
pColor(color);
}
}
DjBlacky McMahon
Registered User
Join date: 26 May 2008
Posts: 10
nice nice
08-12-2008 06:34
From: Pale Spectre
CODE

integer HANDLE;
integer CHANNEL = -44567;
float INTENSITY = 10.0;
float RADIUS = 6.0;
float FALLOFF = .25;
integer FACE = 5;

list COLOR_LIST = ["white", "red", "green",
"blue", "yellow", "orange",
"purple", "pink", "cyan", "off", "random"];
list COLOR_VALUE = [<1, 1, 1>, <1, .0, .0>, <0, 1, 0>,
<0, 0, 1>, <1, 1, 0>, <1, .05, .0>,
<1, 0, 1>, <1, .02, .02>, <0, 1, 1>];

pColor(vector color)
{
llSetPrimitiveParams([PRIM_POINT_LIGHT, TRUE, color, INTENSITY, RADIUS, FALLOFF,
PRIM_COLOR, FACE, color, llGetAlpha(FACE),
PRIM_GLOW, FACE, 1.0]);
}

default
{
touch_start(integer total_number)
{
HANDLE = llListen(CHANNEL, "", NULL_KEY, "");
llDialog(llDetectedKey(0), "Color?", COLOR_LIST, CHANNEL);
}

listen(integer channel, string name, key id, string message)
{
llListenRemove(HANDLE);

if(message == "off")
{
llSetTimerEvent(0.0);
llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, <0, 0, 0>, 0, 0, 0,
PRIM_COLOR, FACE, <.95, .95, .95>, llGetAlpha(FACE),
PRIM_GLOW, FACE, 0.0]);
llWhisper(0,"Lights out");
}
else if(message == "random") llSetTimerEvent(1.0);
else
{
llSetTimerEvent(0.0);
integer i = llListFindList(COLOR_LIST, [message]);
vector color = llList2Vector(COLOR_VALUE, i);
pColor(color);
}
}

timer()
{
vector color = llList2Vector(COLOR_VALUE, (integer)(llFrand(llGetListLength(COLOR_VALUE))));
pColor(color);
}
}


that works realy good
how can i set that the prim changes the color to?!?
Pale Spectre
Registered User
Join date: 2 Sep 2005
Posts: 586
08-12-2008 10:56
From: DjBlacky McMahon
how can i set that the prim changes the color to?!?
The buttons and their corresponding colours are controlled by these two lists:

list COLOR_LIST = ["white", "red", "green","blue", "yellow", "orange","purple", "pink", "cyan", "off", "random"];
list COLOR_VALUE = [<1, 1, 1>, <1, .0, .0>, <0, 1, 0>, <0, 0, 1>, <1, 1, 0>, <1, .05, .0>, <1, 0, 1>, <1, .02, .02>, <0, 1, 1>];

So, white = <1, 1, 1,>, red = <1, 0, 0>, etc. ...change these values to whatever colours you want.

Note: in RBG World, 1 = 255, so, for example, <1, 0.05, 0> is approximately the same as RBG(255, 13, 0).

See:
Amy Stork
Way past use by date
Join date: 26 Feb 2006
Posts: 646
08-13-2008 06:53
I didn't have any trouble getting this to work... but how do I keep the blue menu up so that you can change colour many times without clicking?
1 2