Jump to content

Lessening amount of scripts in wings


Vehementi Nacon
 Share

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

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

Recommended Posts

I was trying to find a way for a script to search the primitives in an object that's worn by the player. Let's say 'closed' will close when they land and then 'open' when they fly. I was hoping to do this based on prim name but I can't find the handle for scanning the prims in an object and then telling them what to do based on that name. Otherwise I'm stuck polluting with 34 something scripts going off. I've tried searching but I keep getting some post about someone doing puppeteering with airplanes or somethin.
Link to comment
Share on other sites

Not sure what you're asking for. Alpha swapping? Position changing?

Alpha swapping could be like this:

// Swaps prim alpha when flying/landingstring gsOpen = "open";string gsClosed = "closed";list glPrimCacheOpen;list glPrimCacheClosed;float gfTimer = 0.25; // Don't recommend lower.integer gbFlying;cachePrims() {    glPrimCacheOpen = [];    glPrimCacheClosed = [];    integer x = llGetNumberOfPrims();    do {        string sName = llGetLinkName(x);        if (sName == gsOpen) {            glPrimCacheOpen += [x];        }        else if (sName == gsClosed) {            glPrimCacheClosed += [x];        }    } while (--x);}default {    attach(key id) {        if (id != NULL_KEY) {            llSetTimerEvent(gfTimer);            if (!llGetListLength(glPrimCacheOpen)) {                cachePrims();            }        }        else {            llSetTimerEvent(0.0);            gbFlying = FALSE;        }    }    timer() {        integer i = llGetAgentInfo(llGetOwner());        if (i & AGENT_FLYING && !gbFlying) {            gbFlying = TRUE;            i = llGetListLength(glPrimCacheClosed);            while (i--) {                llSetLinkAlpha(i,0.0,ALL_SIDES);            }            i = llGetListLength(glPrimCacheOpen);            while (i--) {                llSetLinkAlpha(i,1.0,ALL_SIDES);            }        }        else if (!(i & AGENT_FLYING) && gbFlying) {            gbFlying = FALSE;            i = llGetListLength(glPrimCacheOpen);            while (i--) {                llSetLinkAlpha(i,0.0,ALL_SIDES);            }            i = llGetListLength(glPrimCacheClosed);            while (i--) {                llSetLinkAlpha(i,1.0,ALL_SIDES);            }        }    }

    changed(integer c) {
        if (c & CHANGED_LINK) {
            cachePrims();
        }
    }
}

I wrote the script above without testing, so it may have a bug or two for you to work out. It compiles, though!

The above script uses "prim caching" so it doesn't have to walk through the linkset every time. (which may not be a bad thing, needs benchmarking) It will only do that when it changed, or if there's no stored data (first wear). It also doesn't work except when worn, since that's always led to problems in everything I've worked on.

Since it does use caching, and can only detect if the linkset changes, if you rename prims you'll need to manually reset the script for it to detect those changes.

If you were changing the prims around when flying, physically relocating them, I would recommend storing the position, scale, and rotation values for each state in invisible hovertext and looping thought he linkset to change them. Seems like it'd use less script memory that way, as storing prim properties for two states of all prims could be real expensive on a high prim setup.

Link to comment
Share on other sites

To find the names of prims in a linkset you can use llGetLinkName(). 
To later do someting to prims with specific names, you can put their linknumbers in a list.

Like:

list LinkNums;default {      state_entry() {        integer i;        while ( ++i <= llGetNumberOfPrims() ) {            if ( llToLower( llStringTrim( llGetLinkName( i), STRING_TRIM ) ) == "prim name" ) LinkNums += [i];        }    }}

 

  • Like 1
Link to comment
Share on other sites

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