Jump to content

Animated Texture stops after 'Take a Copy'


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

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

Recommended Posts

I'm having a problem with an 1-prim animated door texture i've made for a space station.  It works great except when i 'Take a Copy' or 'Save back to inventory' and i believe other editing related actions cause it also.  Normal usage (opening,closing) works fine.

 

The problem is that after 'Take a Copy' the animation stops and shows the entire 6-frame texture instead of the desired frame (opened or closed).  I've posted a picture at https://my.secondlife.com/ariagirl/snapshots/516442a6ee679e1c9f000001

I can't seem to find a scripting solution and I am wondering if this is just a viewer glitch (Phoenix Firestorm Release v2.2.29837).  I thought detecting and responding to appropriate 'changed' events might work, but did nothing.

The problem can be temporarily fixed by Reseting all scripts from the viewer but will just reoccur with the next 'Take a Copy'.

 

Here is my script if it matters:

i

integer DOOR_OPEN = 283;
integer DOOR_ACTIVATE = 282;
integer open = FALSE;
integer x = 3;
integer y = 2;
float speed = 8.0;
string closesound = "close";
string opensound  = "open";
string doorcode;
float  doortime = 10.0;


Close()
{
    llPlaySound( closesound, 1.0 );
    llSetTextureAnim( ANIM_ON | REVERSE, ALL_SIDES, x,y,0.0,0.0,speed );  //play in reverse to close the door
   
    llSetLinkPrimitiveParams( LINK_THIS,[PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_PRIM] ); //make door solid
    llSleep(1.0);  
    llSetTextureAnim( ANIM_ON | SMOOTH, ALL_SIDES, x, y, 0.001, 1.0, speed); //adding this line fixed a problem i was having where the door would be invisible sometimes when i logged in.  Removing this line doesn't fix the current problem.  Using 0.0 instead of 0.001 didn't fix my original problem if you're wondering.
    
    open = FALSE;    
}

Open()
{
    if ( !open )
    {
        llPlaySound( opensound, 1.0 );
        llSetTextureAnim( ANIM_ON, ALL_SIDES, x,y,0.0,0.0,speed ); //play forward to open the door
       
        llSetLinkPrimitiveParams( LINK_THIS,[PRIM_PHYSICS_SHAPE_TYPE, PRIM_PHYSICS_SHAPE_NONE] ); //make door phantom
        llSleep(1.0);
        llSetTextureAnim( ANIM_ON | SMOOTH, ALL_SIDES, x, y, 5.001, 1.0, speed);//adding this line fixed a problem i was having where the door would be invisible sometimes when i logged in.  Removing this line doesn't fix the current problem.  Using 5.0 instead of 5.001 didn't fix my original problem if you're wondering.
        
        
        open = TRUE;
        llSetTimerEvent( doortime ); // close door after specified amount of time
    }
}

string GetCode()
{
    return llList2String( llGetPrimitiveParams( [PRIM_DESC] ), 0 );   
}


default
{
    on_rez( integer param )
    {
        llResetScript();    
    }
    
    state_entry()
    {
        doorcode = GetCode();
        Close();
        
    }

    link_message( integer sender, integer num, string msg, key id )
    {   
        if ( num == DOOR_ACTIVATE && doorcode == msg )
        {
            if ( open ) Close();
            else Open();
        }
        if (num == DOOR_OPEN && doorcode == msg )
        {
            Open();
        }
    }
    timer()
    {
        Close();
        llSetTimerEvent(0.0);   
    }
}

 

 

 

Link to comment
Share on other sites

I guess i should mention that the animation is not continuous...it's supposed to stop in either the 'open' or 'closed' frame depending on the circumstance.  You can see that from the code but thought i'd mention this so you don't have to parse through all my code if you don't want to.

Link to comment
Share on other sites

The notes in your script explain why you are using values of 0.001 and 5.001 for the starting frame in two of your calls to llSetTextureAnim, but that doesn't work.  That parameter is a float because it doubles as a rotation (in degrees), in case you are activating the ROTATE mode.  When you are in any other mode, a frame is an integral value.  You can't start on frame 5.001.  I don't know if that's enough to confuse the script into failing, but it's the first thing I would fix.

  • Like 1
Link to comment
Share on other sites

I find the whole script puzzling, to be honest. I don't understand why the SMOOTH animation doesn't screw-up everything, even if it somehow magically gets around a viewer bug that fails to render the door at first. I also don't understand why the cel animation uses 0.0 as its length instead of 6.0 (or (float)(x*y)), but apparently it works so maybe the function defaults to playing once through all the cels.

One thing I might try would be to set the face's texture scale and offset to match the "fully closed" portion of the image. The texture animation will override that when it runs, but it seems that the Take Copy operation is causing your viewer to draw the surface with its native scale and offset, rather than how it looks after the texture has been animated.

  • Like 1
Link to comment
Share on other sites

The good news is- I can tell why that is happening. The bad news is- there's no work around apparently.

 

When you do a "Take Copy" or "Save to Inventory", you are doing (equivantly) the same action as a shift-drag copy. A number of prim properties (client-side rotation, particles, hover text, etc) are lost when this happens, one of them being texture animation.

 

Unfortunately, though it has been discussed before, no one has yet come up with a way to detect that since the script is not reset when the copy takes place..

  • Like 1
Link to comment
Share on other sites

After my posting, I got to thinking- since it was a texture animation problem, what would happen if you turned it off after each opening and closing of the door? This will not only work, but get rid of the first problem you were having with the door going invisible on you at times.

Replace all occurances of:

 llSetTextureAnim( ANIM_ON | SMOOTH, ALL_SIDES, x, y, 0.001, 1.0, speed); //adding this line fixed ...

With:

llSetTextureAnim( FALSE, ALL_SIDES, 0, 0, 0.0, 0.0, 1.0);
  • Like 1
Link to comment
Share on other sites

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