Jump to content

LINK_SET -- Need a hand here.


Lightesword Xue
 Share

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

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

Recommended Posts

So, I'm ''new'' to the coding world, compared to all you other coders out there.. I'm still in middle school.

So here's my problem. I am making some items that require to have as little script usage as possible.

I'm making toes and masks right now. Here's what I want them to do:

 

I'm trying to create a script that when  placed into the mother primitive, it can then tell the children primitives how to respond.

I'm trying to create a script like this so when I click the primary prim, a specific prim set will go invisible as the rest of the children prims remain uneffected and visa versa.

 

Example of what I mean:

 

Sergals: When the Sergal is not in flight, it's toes are seen flat.. however when you fly, the toes curl inwards. This is all done with one script and multiple prims. The toes that are flat are named something like ]toeflat] while the toes used in flight are called ]toefly]. So when you fly, all prims named ]toefly] are seen.. when you land all toes named ]toeflat] are seen.

However in my case, I want this not to be done by flying, but by a touch instead. Is it possible to have someone script it in the forum for me? If so, I've been trying to figure it out but I'm simply not that advanced to do so since this is new to me.

 

Help would be appreciated! Anyone who helps me will get the mask I've made for free.. and it's an epic mask too let me remind you. 

Link to comment
Share on other sites

The type of script you are describing is not really very difficult to make (I can say that because I am not a scripting guru :) and I have used both llSetLinkAlpha and llSetLinkPrimitiveParamsFast to accomplish this task, usually with a touch event as the trigger.  However, to write a working script requires knowing a few things such as the actual link numbers of the prims you want to control, and the parameters of the touch event (owner only?  probably), as well as any other conditions that you may wish to apply.

Link to comment
Share on other sites

Thanks for the input! That explains a few things, however, where would I begin that?

Here's a script I'm trying to edit to make it control one set of prims. So far you can see I have not done that.. as I do not know where to begin with it. I'm trying to apply what you said though, but I have this feeling it's not going to click on in my little brain until I see the code someone else makes.

 

integer isOn;

on()
{
isOn = TRUE;
llSetLinkAlpha(LINK_SET, 0.9,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.8,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.7,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.6,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.5,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.4,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.3,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.2,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.1,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0,ALL_SIDES);
}

off()
{
isOn = FALSE;
llSetLinkAlpha(LINK_SET, 0.1,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.2,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.3,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.4,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.5,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.6,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.7,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.8,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 0.9,ALL_SIDES);
llSleep(0.04);
llSetLinkAlpha(LINK_SET, 1,ALL_SIDES);
}

default
{
state_entry()
{
off();
}

touch_start(integer numAvs)
{
if (isOn)
off();
else
on();
}
}
 

Link to comment
Share on other sites

So it seems perhaps this is what I want according to the wiki I was directed to.

 

 

list PrimList;
default
{
state_entry()
{
integer NumLink = llGetNumberOfPrims();
llListen(37,"","","");
integer i;
for (i=1;i<=NumLink;++i)
{
PrimList += llGetLinkName(i);
}
}
listen( integer channel, string name, key id, string msg)
{
list temp = llCSV2List(msg);
integer len = llGetListLength (temp);
string Alpha = llToUpper(llList2String(temp,0));
integer i;
for (i=1;i<len;++i)
{
string ThisPrim = llStringTrim(llList2String(temp,i),STRING_TRIM);
integer idx = llListFindList(PrimList, [ThisPrim]);
if (~idx)
{
if (Alpha == "SHOW")
{
llSetLinkAlpha(idx+1, 1.0, ALL_SIDES); //Ex: SHOW,plate,spoon, napkin <---- makes named prims visible
}
else if (Alpha == "HIDE")
{
llSetLinkAlpha(idx+1,0.0, ALL_SIDES); //Ex: HIDE, butter knife, glass, fork, spoon <--- makes named prims transparent
}
}
else if (llToUpper(ThisPrim) == "ALL")
{
if (Alpha == "SHOW")
{
llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES); //Ex: SHOW, ALL <--- makes the entire linkset visible
}
else if (Alpha == "HIDE")
{
llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES); //Ex: HIDE, All <--- makes the entire linkset transparent
}
}

}
}
changed (integer change)
{
if (change & CHANGED_LINK)
{
llResetScript();
}
}

}


Link to comment
Share on other sites

(Edit: I added the possibility to have colored prims.)

Here is something else... Only caveat is that the prims must have only one color each.

 

integer FirstToe;
list ShowToes;
list HideToes;

integer FirstFlyToe;
list ShowFlyToes;
list HideFlyToes;

integer theSWITCH;

uuSetToes(integer switch)
{
    theSWITCH = switch; // Don't forget this!
    if (switch)
    {
        // Show fly toes and hide regular toes.
        llSetLinkPrimitiveParamsFast(FirstFlyToe, ShowFlyToes
                            + [PRIM_LINK_TARGET, FirstToe] + HideToes);
    }
    else
    {
        // Show regular toes and hide fly toes.
        llSetLinkPrimitiveParamsFast(FirstToe, ShowToes
                            + [PRIM_LINK_TARGET, FirstFlyToe] + HideFlyToes);
    }
}

default
{
    on_rez(integer param) { llResetScript(); }
   
    state_entry()
    {
        integer i = llGetNumberOfPrims();
        for (; i > 1; --i) // Checking all the prims, except the root.
        {
            string name = llGetLinkName(i);
            if (name == "toeflat")
            {
                if (ShowToes != []) // Params list for regular toes not empty
                {
                    // We need PRIM_LINK_TARGET...
                    ShowToes += [PRIM_LINK_TARGET, i];
                    HideToes += [PRIM_LINK_TARGET, i];
                }
                else
                {
                    // ...otherwise not.
                    FirstToe = i; // Store that link number.
                }
                // Primitive params are needed in all cases.
                vector color = llList2Vector(llGetLinkPrimitiveParams(i, [PRIM_COLOR, 0]), 0);
                ShowToes += [PRIM_COLOR, ALL_SIDES, color, 1.0];
                HideToes += [PRIM_COLOR, ALL_SIDES, color, 0.0];
            }
            else if (name == "toefly")
            {
                if (ShowFlyToes != []) // Params list for fly toes not empty
                {
                    // We need PRIM_LINK_TARGET...
                    ShowFlyToes += [PRIM_LINK_TARGET, i];
                    HideFlyToes += [PRIM_LINK_TARGET, i];
                }
                else
                {
                    // ...otherwise not.
                    FirstFlyToe = i; // Store that link number.
                }
                // Primitive params are needed in all cases.
                vector color = llList2Vector(llGetLinkPrimitiveParams(i, [PRIM_COLOR, 0]), 0);
                ShowFlyToes += [PRIM_COLOR, ALL_SIDES, color, 1.0];
                HideFlyToes += [PRIM_COLOR, ALL_SIDES, color, 0.0];
            }
        }
        uuSetToes(FALSE); // Set the switch.
    }
   
    touch_end(integer num)
    {
        if (llDetectedKey(0) != llGetOwner()) { return; } // Owner only!
        //
        uuSetToes(!theSWITCH); // Invert and use the switch.
    }
}


Tested in-world. It compiles and works... fast!

Just don't forget to change the toe names in the script to match your build. And reset the script if you re-link anything.

 

Link to comment
Share on other sites

Aha.  I see what you're trying to do.  llSleep is an awkward way to make the alpha fade in or out when you touch, though.  That function stops the entire script.  It would be wiser to use a fast timer to do the same thing.  Otherwise, your overall idea is not bad.  Here's a way to do it with a timer .....

 

integer IsOn;integer count;default{    state_entry()    {        IsOn = TRUE;  //This is a trigger that makes sure that the timer sequence starts the first time the object is touched    }        touch_start(integer num)    {        llSetTimerEvent(0.2); // Make 0,2 second time steps    }    timer()    {        if(IsOn)  // True only the first time after a script reset        {            count = 1;            IsOn = FALSE;        }          if ((llAbs(count) == 10)|| count == 0)        {            count = -count; // Set to reverse direction next time object is clicked            llSetTimerEvent(0.0);  // Shut off timer when fully visible or fully invisible        }        llSetLinkAlpha(2, 1.0 -(0.1 * llAbs(count)),  ALL_SIDES);  // Change alpha on link #2        ++count;  // Next time step    }}

 The only real cheat is the use of IsOn to jump start the timer the very first time you click the object after a script reset. If you don't include that little cheat, you have to click twice that first time.  After the first time, though, the script either fades on or fades off and then stops, waiting for you to click it again.  BTW, I just guiessed that you want to use the alpha fader on link #2.  If you have another link in mind, change the number.

 ETA: This is only meant to respond to your attempt to make the prim fade in and out, not to handle the multi-prim part of the question.  You could combine this with Kaluura's very lovely script to address both problems, although it's hard to do it efficiently.

Link to comment
Share on other sites


Lightesword Xue wrote:

So, I'm ''new'' to the coding world, compared to all you other coders out there.. I'm still in middle school.

 

"Middle school" means too young to be in Second Life, doesn't it?  I ahve no idea which country you're in, of course, so can't be sure what age-range 'middle school' covers.

Link to comment
Share on other sites


PeterCanessa Oh wrote:


Lightesword Xue wrote:

So, I'm ''new'' to the coding world, compared to all you other coders out there.. I'm still in middle school.

 

"Middle school" means too young to be in Second Life, doesn't it?  I ahve no idea which country you're in, of course, so can't be sure what age-range 'middle school' covers.

Thus proving the purpose of correct punctuation.

Link to comment
Share on other sites

Lol.. No.. I meant ''middle school'' as a statement showing how my skill level is compared to other scriptors in SL. Not that I'm ACTUALLY in middle school.. I haven't been in MS for like...13+ years.

 

Also I had help with it. You are all wonderful for helping, reading, and/or trying to help.. I appreciate that!! :) 

 

Also thanks for the help everyone. The mask is done.. whomever wants it please click the link below to see it first. If you do want it IM me inworld and please request it. I will hand it to you for free as my gift to you. 

 

MASK LINK

Link to comment
Share on other sites

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