Jump to content

LSL Scripting help Please!!


joshua Bumbo
 Share

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

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

Recommended Posts

I have this bandana mask that I made that has one on the face and one on the neck. The prim needs to move down by 0.08 on Z because there is a clickible I always wear (Not linked to mask) and when the mask is up it bocks the clickible tom make it more realistic . The clickiblemakes a click noise when clicked. There is 10 prims total and it listens for the command "maskup" or "maskdown" . If possible id like to make it not move if it's allready in the position requested. (ex. up or down) Here is what I have so far. Any will help will be much appreciated.

Thank you,

 

default
{
    state_entry()
    {
        // listen on channel zero for any chat spoken by the object owner.
        llListen(2,"",llGetOwner(),"");
    }
    
    listen(integer channel, string name, key id, string message)
    {
        // check if the message corresponds to a predefined string.
        // llToLower converts the message to lowercase.
        // This way, "HELLO", "Hello" or "HeLLo" will all work the same way.
        if (llToLower(message) == "maskup")
        {
         llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
//-----> needs to go up
        }
       else if (llToLower(message) == "maskdown")
       {
        llSetLinkAlpha(LINK_SET, 0.0, ALL_SIDES);
//-----> needs to go down
        }
        else if (llToLower(message) == "maskhide")
       {
       llSetLinkAlpha(LINK_SET, 1.0, ALL_SIDES);
//-----> need to go down
        } 
    }
}
Link to comment
Share on other sites

I'm not quite sure how "has one on the face and one on the neck" makes sense with "there is 10 prims total", but let's run with it.

All you need to do is think through the logic.  You have two conditions. Either the mask goes up or the mask goes down, and you want to carry a flag to know where it is at the moment. So, basically, your conditions are:

(1) if you hear the message "maskup" and the mask is not already up, make it go up and be visible.

(2) otherwise, if the mask isn't already down, make it go down when it hears a message.

    (2a) if the message is "maskdown", make the mask visible.

    (2b) if the message is "maskhide", make the mask invisible.

So, build your if and else if code blocks around that logic.  Mechanically, create a global integer variable (call it something like iUP maybe) that is either TRUE or FALSE, depending on whether you have just raised or lowered the mask, and then use it in your if and else if tests as appropriate.  To raise or lower the mask, it's probably easiest to use llSetLinkPrimitiveParams, as in

llSetLinkPrimitiveParams(LINK_THIS,[PRIM_POS_LOCAL, llGetLocalPos() + <0.0,0.0,0.08>]);

(or -0.08, if you want it to go down).  That ought to work, unless I have misinterpreted the contradictory statements I noted above.

Link to comment
Share on other sites

Thanks for getting back to me so quickly. The bandana has a link set of 10 prims that looks like it is on the face and then there is a different link set of 10 prims that looks like it is down around the neck. I am fimmiar with writing code logic it is just that I did not know how to move a whole linkset together as one. Not to mention the wiki is not much help. Sometimes the logic blocks get a little confusing in LSL. But I got it to work

 

Thank you.

Link to comment
Share on other sites

That's terrific. Yeah, the wiki is much better than it was many years ago, but it has always been more helpful for people who already know their way around LSL than for those who are just beginning. LSL is an odd language, and the wiki is a compilation of what users have discovered rather than a manual written by the system's designers.  As a result, a lot of the practical lore of LSL is passed along by word of mouth and in examples, both in world and in forums like this one.  

I'm glad you got your script to work.

Oh, and the linkset principle here is that if you move the root prim, the entire linkset moves. In the case of an attached linkset, local movement is always relative to the attachment point.  The reason I was a little cautious in my reply earlier was that I could not be 100% confident that you were moving the root prim.

Link to comment
Share on other sites

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