Jump to content

Help scripting appearing objects in linkset...


Oralbuddy
 Share

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

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

Recommended Posts

Hi I am trying to script an object I created to make some parts of its linkset opaque when another  prim in the linkset changes size. This is my first project with code entirely from scratch so please be gentle I'm sure its a mess lol. if possible I would like to call the primit watches for change by name rather than link number to allow for further build changes.

Ok heres what I came up with:

 

default
{
changed(integer change)
list Object1 = llGetLinkPrimitiveParams(17, [PRIM_SIZE]);
{
if (change & CHANGED_SCALE)
{
if (Object1 < "<0.012500, 0.012500, 0.0660>") llSetLinkPrimitiveParamsFast(20,[PRIM_COLOR, all, <0, 0, 0>, 0.00];
else if (Object1 >= "<0.012500, 0.012500, 0.0660>") llSetLinkPrimitiveParamsFast(20,[PRIM_COLOR, all, <0, 0, 0>, 1.00]);
else if (Object1 < "<0.012500, 0.012500, 0.1220>") llSetLinkPrimitiveParamsFast(21,[PRIM_COLOR, all, <0, 0, 0>, 1.00];
else if (Object1 >= "<0.012500, 0.012500, 0.1220>") llSetLinkPrimitiveParamsFast(21,[PRIM_COLOR, all, <0, 0, 0>, 0.00];
else if (Object1 < "<0.012500, 0.012500, 0.1780>") llSetLinkPrimitiveParamsFast(22,[PRIM_COLOR, all, <0, 0, 0>, 1.00];
else if (Object1 >="<0.012500, 0.012500, 0.1780>") llSetLinkPrimitiveParamsFast(22,[PRIM_COLOR, all, <0, 0, 0>, 0.00];
else if (Object1 >= <0.012500, 0.012500, 0.2340>) llSetLinkPrimitiveParamsFast(23,[PRIM_COLOR, all, <0, 0, 0>, 0.00];
else if (Object1 < <0.012500, 0.012500, 0.2340>) llSetLinkPrimitiveParamsFast(23,[PRIM_COLOR, all, <0, 0, 0>, 1.00];
else if (Object1 >= <0.012500, 0.012500, 0.2800>) llSetLinkPrimitiveParamsFast(24,[PRIM_COLOR, all, <0, 0, 0>, 0.00];
else if (Object1 < <0.012500, 0.012500, 0.2800>) llSetLinkPrimitiveParamsFast(24,[PRIM_COLOR, all, <0, 0, 0>, 1.00];
}
}
}

Link to comment
Share on other sites

A few observations.....

1. You are only interested in whether link #17 changes its Z dimension, so there's no need to test the others.

2. In each case, you are not changing the child prim's color.  You are changing its alpha.  You can do that much more simply with llSetLinkAlpha.

3. Object1 is defined as a list.  You can't test whether a list is less than a vector.

4. If you want to apply the changed alpha to all sides of the prim, say ALL_SIDES, not "all".

5. The logic of your stack of if ... else if tests will never get past the second test, so only prim #20 will ever change.  After all, the Z dimension of prim #17 is either larger than 0.0660 or it's not. Once that question is settled, there's nothing more to do.

6.  Most seriously, though ..... CHANGED_SCALE applies to the object.  The changed event won't be triggered by a change in the size of child prim #17.

So, your approach isn't going to work, even after you clean up the syntax.  You could run a timer, perhaps, and look at each time step to see whether  llList2Vector(llGetLinkPrimitiveParams(17,[PRIM_SIZE]),0) has changed.  If it has, then you can ask whether the Z component is greater or less than each of your critical values.  You'll have to rethink your logic, though.

  • Like 1
Link to comment
Share on other sites

Ok thank you for the help Like I said I've only modified scripts before not made my own so I still have a lot of confusion.

what if I changed the "else if"'s to there own "if" conditionals so it looks more like:

 

vector Object1 = llGetLinkPrimitiveParams(17, [PRIM_SIZE]);
default
{
if (Object1 < <0.012500, 0.012500, 0.0660>)
{
llSetLinkAlpha(20, 1.0, ALL_SIDES)
}
if (Object1 >= <0.012500, 0.012500, 0.0660>)
{
llSetLinkAlpha(20, 0.0, ALL_SIDES)
}
if (Object1 < <0.012500, 0.012500, 0.1220>)
{
llSetLinkAlpha(21, 1.0, ALL_SIDES)
}
if (Object1>= <0.012500, 0.012500, 0.1220>)
{
llSetLinkAlpha(21, 0.0, ALL_SIDES)
}
if (Object1 < <0.012500, 0.012500, 0.1780>)
{
llSetLinkAlpha(22, 1.0, ALL_SIDES)
{
if (Object1 >= <0.012500, 0.012500, 0.1780>)
{
llSetLinkAlpha(22, 0.0, ALL_SIDES)
}
if (Object1 < <0.012500, 0.012500, 0.2340>)
{
llSetLinkAlpha(23, 1.0, ALL_SIDES)
}
if (Object1 >= <0.012500, 0.012500, 0.2340>)
{
llSetLinkAlpha(23, 0.0, ALL_SIDES)
}
if (Object1 < <0.012500, 0.012500, 0.2800>)
{
llSetLinkAlpha(24, 1.0, ALL_SIDES)
}
if (Object1 >= <0.012500, 0.012500, 0.2800>)
{
llSetLinkAlpha(24, 0.0, ALL_SIDES)
}
}

Link to comment
Share on other sites

Hmmmmm.... Better, but let's do this another way.  Here's a script that ought to work.  I haven't tested it in world, but it compiles and the logic is probably right.  Go back and look at the things I listed in my first reply to see why this works (and yours won't).   In writing this example, I assumed that you might want to change the size of prim #17 manually, then click on the object to reset the alphas of the other child prims.

list Zsize = [0.066,0.122,0.178,0.234,0.280];   // Limiting Z dimensions for prims 20 through 24default{    touch_start(integer num)    {        vector Size = llList2Vector(llGetLinkPrimitiveParams(17, [PRIM_SIZE]),0);   //Get the size of child prim 17        float Z = Size.z;   // What is its Z dimension?        integer i;        for (i=20;i<=24;++i)    // Loop through child prims 20 through 24        {            if ( Z < llList2Float(Zsize,i-20))  // Is the Z dimension if 17 smaller than the size limit for this child prim?            {                llSetLinkAlpha(i,1.0,ALL_SIDES);    // Yes?  Make it visible            }            else            {                llSetLinkAlpha(i,0.0,ALL_SIDES);    // No?  Make it transparent            }        }    }}

 Scripting isn't inherently difficult, but it can be challenging at first because you have to think of two things at once.  One is syntax -- the structure of the language you're using and the way each line has to be written so the at the script will compile.  The other one, more important, is logic.  Even if you have the syntax perfect, poor logic will give you poor results.  If I were you, I'd focus on logic first.  Then figure out how you're going to turn your logic into something that will compile.

  • Like 1
Link to comment
Share on other sites

Yes, so the trick will be to keep track of what the Z dimension oif prim #17 is.  Each time that the changed event is triggered, ask whether that dimension is any different than it was the last time the event was triggered.  If so, then jump into the looping process that changes the alpha of prims #20 through #24.

Link to comment
Share on other sites

Thank you everyone this has been extreamly helpful and very enlightening. I am happy to report that thanks to the help I got I was able to get the script together and setup and fix the start event so its all working perfectly. you guys are amazing and worthy of extreamly high praise. please keep doing what your doing becasue without resources like this people like me would give up on what was otherwise a very rewarding process. 

Link to comment
Share on other sites

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