|
Hesius Heron
Registered User
Join date: 21 May 2007
Posts: 11
|
06-27-2007 13:45
I have just this minute scrapped up a simple bit of code for changing a texture when you click on the item. What this perticular cose does is, when the item is click on, it makes anything inside it invisible (except certain flexi stuff etc....very annoying). Then, when you click on it again, it stop making things invisible (the texture "alpha" is simply a clear texture. Code as follows: string cloak = "38b86f85-2575-52a9-a531-23108d8da837"; integer counter;
default { state_entry() { counter = 0; }
touch_start(integer total_number) { if ( counter == 0 ) { llSetPrimitiveParams([PRIM_TEXTURE, ALL_SIDES, cloak, <0,0,0>, <0.475, 0.5, 0>, 0.0, PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_NONE, PRIM_BUMP_BRIGHT]); counter = 1; }else if (counter == 1){ llSetTexture("alpha",ALL_SIDES); counter = 0; } } }
My problem is this...I have the prim I want to be invisible attatched to another prim. It is this second prim that I want to be clicked(and not become invisible itself). Is there a simple way to call the script in the other prim, or maybe getting one parent prim to alter a child prim textures?
|
|
DoteDote Edison
Thinks Too Much
Join date: 6 Jun 2004
Posts: 790
|
06-27-2007 14:33
You should use llSetLinkAlpha() as your function. Use LINK_ALL_OTHERS to tell which prims get the effect. http://lslwiki.net/lslwiki/wakka.php?wakka=llSetLinkAlphayour new code: From: someone integer switch;
default { touch_start(integer num_detected) { llSetLinkAlpha(LINK_ALL_OTHERS, switch, ALL_SIDES); switch = !switch; } }
On each touch, all other prims in the link set have their alpha value switch to "switch". switch equals either 0 (clear) or 1 (solid) after each touch. Note: The above works great for cloaking. If you simply want to switch textures, then use llSetLinkTexture() http://lslwiki.net/lslwiki/wakka.php?wakka=llSetLinkTexture
|
|
Hesius Heron
Registered User
Join date: 21 May 2007
Posts: 11
|
06-27-2007 15:54
This script is most excellent, but doesn't quite suit my purpose. The reference to "38b86f85-2575-52a9-a531-23108d8da837" is quite important, as this makes this invisible.
However, as I typed that, I realised. I mad the item use that texture and bingo, works! Simple and lovely script. I owe you.
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
06-27-2007 16:33
Try something like this, what it does is controls both objects separately.
the script in the root object allows you to toggle the alpha of the cloak (to alternatively SHOW your 'invisible' texture, or hide it)
the script in the cloak sets the texture to your magic UUID texture and leaves it set like that forever.
in the root object (that you click on to control the cloak): **************** integer VISIBLE=0; integer INVISIBLE=1;
integer cloak_state=VISIBLE;
default { state_entry() { counter = 0; cloak_state=VISIBLE; llSetLinkAlpha(LINK_ALL_OTHERS, (float)cloak_state, ALL_SIDES); }
touch_start(integer total_number) { if ( cloak_state=VISIBLE ) { llSetLinkAlpha(LINK_ALL_OTHERS, (float)cloak_state, ALL_SIDES); cloak_state=INVISIBLE; } else if (cloak_state == INVISIBLE) { llSetLinkAlpha(LINK_ALL_OTHERS, (float)cloak_state, ALL_SIDES); cloak_state = VISIBLE; } } }
in the cloak object ***************** string cloak = "38b86f85-2575-52a9-a531-23108d8da837"; default { state_entry() { llSetPrimitiveParams([PRIM_TEXTURE, ALL_SIDES, cloak, <0,0,0>, <0.475, 0.5, 0>, 0.0, PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_NONE, PRIM_BUMP_BRIGHT]); }
on_rez() { llSetPrimitiveParams([PRIM_TEXTURE, ALL_SIDES, cloak, <0,0,0>, <0.475, 0.5, 0>, 0.0, PRIM_BUMP_SHINY, ALL_SIDES, PRIM_SHINY_NONE, PRIM_BUMP_BRIGHT]); } }
|