Jump to content

LSL_Help_Post_15


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

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

Recommended Posts

Tried to make a puppeteer recorder but isn't show preview (playback):

 

string filename;
integer n;
list size;
list pos;
list rot;
integer c;
list s;
list prim;
integer delay = 1;
    
rec()
{
    c++; 
    n = llGetNumberOfPrims();
        integer x;
        while(x<=(n-1))
        {
            s += (list)c;
            prim += (list)x;
            size += llGetLinkPrimitiveParams(x,[PRIM_SIZE]);
        pos += llGetLinkPrimitiveParams(x,[ PRIM_POSITION ]);
         rot += llGetLinkPrimitiveParams(x,[PRIM_ROTATION]);
         x++;
         
         }
}


default
{
   
   touch_start(integer total_number)
    {
        
         llDialog(llGetOwner(),"choose",["Name","Record","Preview","Dump"],489);
         llListen(489,"",llGetOwner(),"");
    }
    listen(integer channel, string name, key id, string msg)
    {
        if (msg=="Name")
        {
            llTextBox(llGetOwner(),"choose",490);
            llListen(490,"",llGetOwner(),"");
        }
        else if (channel==490)
        {
            filename = msg;
        }
        
        else if (msg=="Record" && filename != "")
        {
            rec();
        }
        else if (msg=="Record" && filename == "")
        {
            llInstantMessage(llGetOwner(),"Process requires a name.");
        }
        else if (msg=="Dump" && c>0)
        {
            llInstantMessage(llGetOwner(),filename+"|"+(string)(n*c));
            integer x;
            while(x<n*c)
            {
            llInstantMessage(llGetOwner(),llList2String(s,x)+"|"+llList2String(prim,x)+"|"+llList2String(pos,x)+"|"+llList2String(size,x)+"|"+llList2String(rot,x));
             x++;
            }
             
        }
         else if (msg=="Dump" && c==0)
        {
            llInstantMessage(llGetOwner(),"No record found");
        }
         else if (msg=="Preview" && c==0)
        {
            integer x;
            while(x<n*c)
            {
            integer p;
            while(p<n)
            {
            
            llSetLinkPrimitiveParams(x,[PRIM_SIZE,(vector)llList2String(size,x)]);
            llSleep(delay);
            llSetLinkPrimitiveParams(x,[PRIM_POSITION,(vector)llList2String(pos,x)]);
            llSleep(delay);
            llSetLinkPrimitiveParams(x,[PRIM_ROTATION,llEuler2Rot((vector)llList2String(rot,x))]);
            llSleep(delay);
            p++;
            if (p=n)
            {
                p = 0;
            }
            }
            x++;
            }
        }
    }
}
 

Link to comment
Share on other sites

1 hour ago, childhoodbestfriend489 said:

else if (msg=="Preview" && c==0)
        {
            integer x;
            while(x<n*c)

Interesting. This will generate the expression test while ( 0 < n* 0) and so will never execute the following lines.  I suspect it should be c !=0

All the other functions report an 'impossible to obey' command when c==0

Edited by Profaitchikenz Haiku
  • Like 1
Link to comment
Share on other sites

Another (potential) problem; getting the PRIM_POSITION and PRIM_ROTATION will fetch you the absolute position and rotation of the object, but for all child prims, whose position and rotation are defined relative to the root, I believe you want to fetch PRIM_POS_LOCAL and PRIM_ROT_LOCAL. Additionally when you fetch a rotation directly from an in-world object, you don't need to use euler2Rot etc. type functions. you can (should) just use something like:

llSetLinkPrimitiveParamsFast(x,[PRIM_ROT_LOCAL,llList2Rot(Rot,x)]);

also note the word fast in the above. personally I would use the fast version for setting all of your parameters,  then have a single sleep after all of them.

if(x!=1) //check that we're setting parameters for a child prim

{ llSetLinkPrimitiveParamsFast(x,[PRIM_ROT_LOCAL,llList2Rot(Rot,x), PRIM_SIZE,llList2Vector(size,x),PRIM_POS_LOCAL,llList2Vector(pos,x)]); llSleep(Delay); }

Link to comment
Share on other sites

9 minutes ago, Quistessa said:

I believe you want to fetch PRIM_POS_LOCAL and PRIM_ROT_LOCAL.

Indeed, but if you look at the other post by the OP on puppeteering, they're working from a 2011/2013 script which uses global positions and rotations instead of locals. It's a subtle case, it's tempting to say the original scripter should have known better, but it's possible their script was developed when there weren't functions for getting local positions and rotations?

I wish there was the same sort of caveat when people pick up really old scripts that we get when we go to reply to a really old thread in the forums.

  • Like 2
Link to comment
Share on other sites

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