Jump to content

Making a prim vanish/stop glowing when you touch a worn object


Sion Pearl
 Share

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

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

Recommended Posts

Let's assume that I know only enough about scripting to mess with a script's particulars. Not a complete novice, but not exactly an expert. So let's assume that this is a stupid question but that even if it's ridiculously straightforward, people will be nice enough to go, "look, fool - you can find the script here..." or "here's a good tutorial, try this". :)

Say I have a helmet or cyberpunk visor-y thing, and the "glass" bit is all textured and glowy. Let's say I love it and think it is awesome, but that it would be even more awesome if I could touch the glass and make it vanish and stop glowing (because if it still glows when the alpha gets turned to 0, you can still see the glow). And if you touch it again, there it is, back in all its glory.

Let's assume I know the link number of the prim I want to vanish, because I do.

But how do you get it to behave so you touch it (any part of the object) and it's gone (well, 100% trans and not glowy), touch again and it's there?

  • Like 1
Link to comment
Share on other sites

If yopu wanted to, you could use the function llSetPrimitivParameter if the script is in the prim you want the parameters for or llSetLinkPrimitiveParams or prim(s) other the one that contains the script.

If you know the link number (this can be tricky, since the link number can change) you simply call the function several times for each prim. I prefer to identify the prims in question by names or part of their names. Let's say all prims that have to have changing glow and alpha parameters are named: glow1, glow2, glow3 ..., you could use something like:

 

default {        touch_end(integer num_detected) {        integer i;        for(i = 1; i <= llGetNumberOfPrims(); ++i) {            if (llSubStringIndex(llList2String(llGetLinkPrimitiveParams(i, [PRIM_NAME]), 0), "glow") > -1) {                llSetLinkPrimitiveParams(i, [PRIM_GLOW, -1, 1.0, PRIM_COLOR, -1, <0,0,0>, 1.0]);                            }                    }    }}

 

 

Link to comment
Share on other sites

 


default {        touch_end(integer num_detected) {        integer i;        for(i = 1; i <= llGetNumberOfPrims(); ++i) {            if (llSubStringIndex(llList2String(llGetLinkPrimitiveParams(i, [PRIM_NAME]), 0), "glow") > -1) {                llSetLinkPrimitiveParams(i, [PRIM_GLOW, -1, 1.0, PRIM_COLOR, -1, <0,0,0>, 1.0]);                            }                    }    }}

 

(I actually have a nifty script I was given that tells you a prim's link number when you touch it, so that isn't a problem. )

 

So in this example, I name all the prims I want to vanish/reappear "glow" and you touch it, it disappears? And reappears as well?

Say the glow on the prim is (when it's visible) 0.15? Does this make it glow again when it's touched?

Forgive me - I'm still a novice, so I'm looking at this trying to parse it.

 

Link to comment
Share on other sites

The example above is just to demonstrate the basic idea - it just sets the glow to 1; color to <0,0,0> and alpha to 1.0.

You could introduce a global integer, e.g. giVisible - on attaching you can set the prims to visible (the function also requires you to set the color) and giVisible to 1.

This example extends the first one in that it switsches the "states"

 

integer giVisible = 1;switchVisible(vector col, float glow, float alpha) {    integer i;    for(i = 1; i <= llGetNumberOfPrims(); ++i) {        if (llSubStringIndex(llList2String(llGetLinkPrimitiveParams(i, [PRIM_NAME]), 0), "glow") > -1) {            llSetLinkPrimitiveParams(i, [PRIM_GLOW, -1, glow, PRIM_COLOR, -1,col, alpha]);                    }            }}default {        touch_end(integer num_detected) {         if(giVisible == 0) {             switchVisible(<0, 0, 0>, 1.0, 1.0);             } else {             switchVisible(<1, 0, 0>, 0.15, 0.0);             }          giVisible = !giVisible;    }        attach(key id) {        switchVisible(<0, 0, 0>, 1.0, 1.0);        giVisible = 1;    }}

 

 

  • Like 2
Link to comment
Share on other sites

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