Jump to content

Facetrigger Click Script Help


Nymoo
 Share

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

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

Recommended Posts

Hiya, I've made a mesh head with 5 eyelid faces or states, as well as the jaw, seamlessly laid on top of each other. As such:

 

I moved the eyes forward to show what I mean. I copied a script from another source, that involves clicking on the eyelids/jaw and making it cycle trough transparencies of each frame and loop. 

I wouldn't know even where to begin looking for an advanced script with blinking + HUD attatchments for face states, I tried looking but it looks like I'd need to commission an actual scripter to do it for me.

So for now I opted for a simple click script, merely to test things out as the head is nearly completed, and here's the text;

 

integer direction;
integer value;
integer previousvalue;

facetrigger()
{
         previousvalue = value;
         value += direction;
         if (value = 0) direction = 1;
         if (value = 4) direction = -1;
         llSetText("Showing face " + (string)value, <1,1,1>, 1);
        //show next part/face
         llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_COLOR, value, <1,1,1>, 1]);
        //hide previous part/face
         llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_COLOR, previousvalue, <1,1,1>, 0]);
}

default
{
        state_entry()
        {
                direction=0;
                value=4;
        }
        
        touch_start (integer total_number) {
        facetrigger();
        }
        
        
}

It just so happens that only the first frame moves, from frame 5 (which is completely closed) to frame 4 (almost closed), and then it gets stuck. I tried putting in values from 1 to 5, but it seems like the code fails to loop, it gets stuck somewhere, I just don't understand where, so I was hoping for some insight?

Thank you.

Link to comment
Share on other sites

LINK_THIS means that 'value' is being applied to the prim that the script is in

try substituting 'value' for LINK_THIS and see what happens, when the script is in the root prim (the head) and 'value' is in the range [1..4] where 1 to 4 are the ordered link numbers of the child prims (eyelids)

eta: ref: http://wiki.secondlife.com/wiki/LlSetPrimitiveParams#llSetLinkPrimitiveParamsFast

 

Link to comment
Share on other sites

llSetLinkPrimitiveParamsFast is asynchronous. You can change numbers in the prim properties 1000 times a second. But what do you expect to see? The server will update your viewer with the newest changes maybe 15 times a second if you are lucky and with zero lag of course.

Put the commands for making one face visible and the other one invisible always into a single llSetLinkPrimitiveParamsFast call. Then wait a bit, at least 1/15th of a second, maybe even longer maybe even shorter. You need to try out what works best.
Then do the next llSetLinkPrimitiveParamsFast with your 2nd animation frame.

For testing you can use llSleep for the delay. Keep in mind that your script will be completely unreponsive while in that face animation loop. If that isn't acceptable you need to use the timer.

Link to comment
Share on other sites

I haven't looked through all of your logic.

There is a simple problem in the 'if' statements:

 

if (value = 0) direction = 1; should be
if (value == 0) direction = 1;

 As you have it coded the 1st 'if' sets ' value' to 0 and then the 2nd 'if' sets 'value' to 4 every time.  Which is why you're gettting stuck at that number.

Link to comment
Share on other sites

Hmmm. I can't be the first to think of this: It would be an order of magnitude more efficient all 'round (server, viewer, and network) if all those alternate geometries were collapsed onto a single mesh face, only separated in the UV map, so a single unlooped PING_PONG cel-by-cel texture anim can cycle through the entire "blink", just one object update from the script to the viewer for the whole effect.

Would require one larger (alpha masked) texturemap instead of five smaller (non-alpha) ones.

[EDIT: Is this how animated-mesh tails "wag" these days? It seems far too obvious to be new.]

Link to comment
Share on other sites

This looks very similar to the script for a flying mesh butterfly I got. It is a single prim, with multiple faces, and it cycles through the faces making it appear to fly. But yours appears to be multiple prims (maybe not?), so you would need to create a list of the links you intend to cycle through and use that in place of LINK_THIS. 

Next question, do you want it to blink on touch/command, or constantly? If constantly you'd probably also want to add a delay between each blink cycle so that it looks more natural.

Link to comment
Share on other sites


wherorangi wrote:

OP wrote it as a touch to try work out what was happening

Yes, I realize that, but they also said they wouldn't know where to begin looking for an advanced script. Simply cycling back and forth through the faces/prims is one thing, but adding the logic to pause between blicking is slightly different. Not hard to do, but slightly different. My main observation was that the script was changing the alpha state on the same prim, but the picture appears to me multiple prims, which is why I suggested making a list of the prims being cycled through

 

 

"I wouldn't know even where to begin looking for an advanced script with blinking + HUD attatchments for face states, I tried looking but it looks like I'd need to commission an actual scripter to do it for me.

So for now I opted for a simple click script, merely to test things out..."

Link to comment
Share on other sites

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