Jump to content

alpha prim help needed


Ranya Palmer
 Share

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

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

Recommended Posts

i have a script that i am using for my gun's holster, so far it works when the holster is only one prim. however when a holster is made up of more than one prim it gets complicated.

so heres the script:

integer i;
string gAlpha = "gun";

refresh()
{  
   for( i = llGetNumberOfPrims(); i >= 0; --i )
       
        
      
        {
            if( llGetLinkName( i ) == gAlpha )
            {
                llSetLinkAlpha( i, 0, ALL_SIDES );
            }
        } for( i = llGetNumberOfPrims(); i >= 0; --i )
        {
            if( llGetLinkName( i ) == gAlpha )
            {
                llSetLinkAlpha( i, 1, ALL_SIDES );
            }
        }}
default
{
    state_entry()
    {
        llListen(-13371337,"","","");
        // if you change this number then you must change the one in the Main script as well
    }
    changed(integer c)
    {
        if(c & CHANGED_OWNER)llResetScript();
    }
    listen(integer c,string n,key i,string m)
    {
        string ownerkey = llGetOwner();
        if(m == ownerkey+ "draw")llSetLinkAlpha(LINK_SET,0,ALL_SIDES);
        refresh();
        if(m == ownerkey + "sling")llSetLinkAlpha(LINK_SET, 1, ALL_SIDES);
        refresh();
    }
}

 

 

ok heres how i was hoping it would work, i was hoping that if i named all the gun's prims "gun" then the script would just find all the prims named "gun" within the linkset and turn it invisible while leaving the rest of the prims visible, but instead i eather get just the gun and all the other prim parts go invisible or the gun will go invisible but once the gun appears the holster vanishes. i just need help with making the gun's prim vanish and the holster prims stay visible.

Link to comment
Share on other sites

Your refresh function sets all prims named "gun" to transparent and then immediately sets them all to visible.

It might be easier to just define a global variable called gSeen and then write your listen event to say

 

listen (integer channel, string name, key id, string message){    string ownerkey = llGetOwner();    if (msg == ownerkey + "draw")    {        gSeen = TRUE;    }    else if (msg == ownerkey + "sling")    {        gSeen = FALSE;    }    integer i = llGetNumberOfPrims();    while( i)    {        if (llGetLinkName(i) == "gun")        {            llSetLinkAlpha(i, gSeen,ALL_SIDES);        }        --i;    }}

 

 

Link to comment
Share on other sites

i replaced my code

integer i;integer gSeen = TRUE;default{    state_entry()    {        llListen(-13371337,"","","");        // if you change this number then you must change the one in the Main script as well    }    changed(integer c)    {        if(CHANGED_OWNER)llResetScript();    }    listen (integer channel, string name, key id, string msg){    string ownerkey = llGetOwner();    if (msg == ownerkey + "draw")    {        gSeen = TRUE;    }    else if (msg == ownerkey + "sling")    {        gSeen = FALSE;    }    integer i = llGetNumberOfPrims();    while( i)    {        if (llGetLinkName(i) == "gun")        {            llSetLinkAlpha(i, gSeen,ALL_SIDES);        }        --i;    }}}

 but i the gun's prims is still staying visible while all the holster prims disappear.

i like that its more efficient now but i am still having the same problem.

did i do something wrong?

Link to comment
Share on other sites

The prims named "holster" shouldn't be affected one way or another by this script.  All it's doing is changing the "gun" prims from visible to transparent and back again.  Check to be sure that all of your prims are named the way you think they are. Incidentally, the variable named "i" doesn't need to be global.

Link to comment
Share on other sites

Hmmmm.... That's not possible, at least if this is the only script in the linkset.  The only prims that can be affected by this script are ones named "gun".  Something else is changing the "holster" prims.  It sounds like it's time to put llOwnerSay diagnostic statements in a few strategic spots so see exactly which prims the script is identifying as "gun" prims.

BTW, while you're at it --- this won't affect the outcome of your tests, but will repair an error --- your changed event should look like this...

 

changed (integer c){    if (c & CHANGED_OWNER)    {        llResetScript();    }}

 

 

Link to comment
Share on other sites

 

Finally.......... i got it to work.


Rolig Loon wrote:

 Something else is changing the "holster" prims.

i did some digging around and found a misplaced script hiding in one of the prims(its the same as the first posted script) i removed it and tried it again, but it failed on me again but after tinkering around with it i finally got it to work the way i want it to work, now only the gun prims are disappearing and re-appearing when they are supposed to.

thank you so much for your help :matte-motes-big-grin:

Link to comment
Share on other sites

WooHoo!!!!   Congratulations.  Debugging can be frustrating and tiring, but there's an amazing feeling of relief and satisfaction that comes over you in the instant when you realize that you have finally solved the problem.  You have earned it.

Link to comment
Share on other sites

Yeah?  Well if you think you're fast enough, go for your guns!

This script demonstrates one of the eternal trade-offs in scripting: memory vs speed.  By using memory to store pre-read link-numbers and owner-key this script doesn't have to check them all every time.  It's also not distracted by other people talking and is immediately ready to draw when a new owner grabs it.

 

list DrawRules;list HolsterRules;string Owner;SetOwner(){	Owner = (string) llGetOwner();	llListen(-13371337,"", llGetOwner(),"");}default{	changed(integer Change){		if(CHANGED_OWNER & Change){			SetOwner();		} 	}	listen(integer ChannelIn, string FromName, key FromID, string Message){		if(Owner + "draw" == Message){			llSetLinkPrimitiveParamsFast(0, DrawRules);		}else if(Owner + "sling" == Message){			llSetLinkPrimitiveParamsFast(0, HolsterRules);		}	}	state_entry(){		integer Counter = llGetNumberOfPrims();		while(Counter){			if(llGetLinkName(Counter) == "gun"){				DrawRules += [PRIM_LINK_TARGET, Counter, PRIM_COLOR, ALL_SIDES, llList2Vector(llGetLinkPrimitiveParams(Counter, [PRIM_COLOR, 0]), 0), 1.0];				HolsterRules += [PRIM_LINK_TARGET, Counter, PRIM_COLOR, ALL_SIDES, llList2Vector(llGetLinkPrimitiveParams(Counter, [PRIM_COLOR, 0]), 0), 0.0];			}		}		SetOwner();	}}

 

[i can see this developing into Tombstone if enough people think they can do better ^^]

Link to comment
Share on other sites

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