Jump to content
Sunbleached

Multiple GIF animation script

Recommended Posts

Hello! Please help to remake the random order multiple GIF animation script into a script playing it in a strict order, one after another.

I suspect this line but I can’t fix it yet    

gTexture = llGetInventoryName(
        INVENTORY_TEXTURE,
        (integer) llFrand(llGetInventoryNumber(INVENTORY_TEXTURE))
    );

integer gFrameX = 0;
integer gFrameY = 0;
float gRate = 0.0;

string gTexture;

setTex()
{
    gTexture = llGetInventoryName(
        INVENTORY_TEXTURE,
        (integer) llFrand(llGetInventoryNumber(INVENTORY_TEXTURE))
    );

    llSetTexture(gTexture, 2);

    if (llSubStringIndex(gTexture, ".anim") != -1)
    {
        list lParams = llParseString2List(gTexture, [";"], []);

        gFrameX = llList2Integer(lParams, 1);
        gFrameY = llList2Integer(lParams, 2);
        gRate = llList2Float(lParams, 3);

        llSetTextureAnim(ANIM_ON | LOOP, 2, gFrameX, gFrameY, 0, 0, gRate);
    }
    else
        llSetTextureAnim(LOOP, 2, gFrameX, gFrameY, 0, 0, gRate);
}

default
{
    state_entry()
    {
        llAllowInventoryDrop(TRUE);
        llSetTimerEvent

            (10.0);
        setTex();
    }

    timer()
    {
        setTex();
    }

    touch_start(integer touches)
    {
        llSetTimerEvent

            (10.0);
        setTex();
    }

    changed(integer change)
    {
        if (change & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY))
            setTex();
    }
}

 

Share this post


Link to post
Share on other sites
13 hours ago, Rolig Loon said:

Good guess.  Set a global integer variable as a counter and start counting.

Hello! Thank you for answer! I did this but something is wrong...

integer count;

setTex()
{
    gTexture = llGetInventoryName(
        INVENTORY_TEXTURE,
        (integer)llFrand( llGetInventoryNumber(INVENTORY_TEXTURE))
        
    );    
    
    llSetTexture(llList2Key(gTexture,count), ALL_SIDES );
    ++count;
    count %=llGetListLength(gTexture);

 

I can see that i misused llList2Key and llGetListLength ... but still dont get it

Edited by Sunbleached

Share this post


Link to post
Share on other sites

the script code you posted is all a bit over-complicated. Try to simplify stuff down to the bare basics. Basics example

integer index;

integer number = llGetInventoryNumber(INVENTORY_TEXTURE);

if (number) 
{
   string name = llGetInventoryName(INVENTORY_TEXTURE, index);
   if (name != "") llSetTexture(name, ALL_SIDES);
   index = (++index) % number;
}

 

  • Thanks 1

Share this post


Link to post
Share on other sites
40 minutes ago, Mollymews said:

the script code you posted is all a bit over-complicated. Try to simplify stuff down to the bare basics. Basics example


integer index;

integer number = llGetInventoryNumber(INVENTORY_TEXTURE);

if (number) 
{
   string name = llGetInventoryName(INVENTORY_TEXTURE, index);
   if (name != "") llSetTexture(name, ALL_SIDES);
   index = (++index) % number;
}

 

Wooow! Thank you so much! Now everything works perfectly!!!

integer index;
integer gFrameX = 0;
integer gFrameY = 0;
float gRate = 0.0;

string name;

setTex()
{

    integer number = llGetInventoryNumber(INVENTORY_TEXTURE);

    if (number)
    {
        string name = llGetInventoryName(INVENTORY_TEXTURE, index);
        if (name != "") llSetTexture(name, ALL_SIDES);
        index = (++index) % number;
        llSubStringIndex(name, ".anim") != -1;
        list lParams = llParseString2List(name, [";"], []);
        gFrameX = llList2Integer(lParams, 1);
        gFrameY = llList2Integer(lParams, 2);
        gRate = llList2Float(lParams, 3);

        llSetTextureAnim(ANIM_ON | LOOP, ALL_SIDES, gFrameX, gFrameY, 0, 0, gRate);
    }
    else
        llSetTextureAnim(LOOP, ALL_SIDES, gFrameX, gFrameY, 0, 0, gRate);
}

default
{
    state_entry()
    {
        llAllowInventoryDrop(TRUE);
        llSetTimerEvent(10.0);
        setTex();
    }

    timer()
    {
        setTex();
    }

    touch_start(integer touches)
    {
        llSetTimerEvent(10.0);
        setTex();
    }

    changed(integer change)
    {
        if (change & (CHANGED_ALLOWED_DROP | CHANGED_INVENTORY))
            setTex();
    }
}

(may come in handy to somebody else!)

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...